public HeapView() {
// Configure structures needed for rendering drop shadow.
int kw = KERNEL_SIZE, kh = KERNEL_SIZE;
float blurFactor = BLUR_FACTOR;
float[] kernelData = new float[kw * kh];
for (int i = 0; i < kernelData.length; i++) {
kernelData[i] = blurFactor;
}
blur = new ConvolveOp(new Kernel(kw, kh, kernelData));
format = new MessageFormat("{0,choice,0#{0,number,0.0}|999<{0,number,0}}/{1,choice,0#{1,number,0.0}|999<{1,number,0}}MB");
heapSizeText = "";
// Enable mouse events. This is the equivalent to adding a mouse
// listener.
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
updateUI();
}
java类java.awt.image.Kernel的实例源码
HeapView.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
ConvolutionFilter.java 文件源码
项目:GIFKR
阅读 25
收藏 0
点赞 0
评论 0
@Override
public final BufferedImage apply(BufferedImage img) {
float[][] matrix = getMatrix();
float[] data = getKernelData(matrix);
if(normalize)
normalize(data);
scale(data);
if(isZero(data))
return new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
Kernel k = new Kernel(matrix[0].length, matrix.length, data);
ConvolveOp op = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null);
BufferedImage img2 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
img2.getGraphics().drawImage(img, 0, 0, null);
return op.filter(img2, null);
}
BufferedBufImgOps.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
ChessBoardUtils.java 文件源码
项目:ChessBot
阅读 38
收藏 0
点赞 0
评论 0
public static BufferedImage blur(BufferedImage src) {
BufferedImage bufferedImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);
int s1 = 7;
int s2 = 7;
float level = .1f / 9f;
float[] filter = new float[s1 * s2];
for (int i = 0; i < s1 * s2; i++) {
filter[i] = level;
}
Kernel kernel = new Kernel(s1, s2, filter);
BufferedImageOp op = new ConvolveOp(kernel);
bufferedImage = op.filter(src, null);
return bufferedImage;
}
BufferedBufImgOps.java 文件源码
项目:jdk8u-jdk
阅读 23
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
BufferedBufImgOps.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
BufferedBufImgOps.java 文件源码
项目:openjdk9
阅读 20
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
Sprite.java 文件源码
项目:LibZ
阅读 24
收藏 0
点赞 0
评论 0
/**
* Blur the image
* @param amount
*/
public void effect_blur(int amount) { // TODO
int radius = amount;
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size * size];
for (int i = 0; i < data.length; i++) {
data[i] = weight;
}
Kernel kernel = new Kernel(size, size, data);
ConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
image = op.filter(image, null);
}
GaussianBlur.java 文件源码
项目:vortex
阅读 43
收藏 0
点赞 0
评论 0
public static Image getBlurredImg(BufferedImage img) {
final int kernel_size = 15;
float[] blurKernel = new float[kernel_size * kernel_size];
final float blurPeakHeight = 0.35f;
double[][] sigma = new double[2][2];
sigma[0] = new double[]{1.2, 0.0};
sigma[1] = new double[]{0.0, 1.2};
double mid = (kernel_size / 2.0);
float cent = (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{mid, mid});
for (int i = 0; i < blurKernel.length; i++) {
int x = i / kernel_size;
int y = i % kernel_size;
blurKernel[i] = blurPeakHeight * (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{x, y}) / cent;
}
ConvolveOp op = new ConvolveOp(new Kernel(kernel_size, kernel_size, blurKernel));
return op.filter(img, null);
}
GaussianBlur.java 文件源码
项目:vortex
阅读 20
收藏 0
点赞 0
评论 0
public static Image getBlurredImg(BufferedImage img) {
final int kernel_size = 15;
float[] blurKernel = new float[kernel_size * kernel_size];
final float blurPeakHeight = 0.35f;
double[][] sigma = new double[2][2];
sigma[0] = new double[]{1.2, 0.0};
sigma[1] = new double[]{0.0, 1.2};
double mid = (kernel_size / 2.0);
float cent = (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{mid, mid});
for (int i = 0; i < blurKernel.length; i++) {
int x = i / kernel_size;
int y = i % kernel_size;
blurKernel[i] = blurPeakHeight * (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{x, y}) / cent;
}
ConvolveOp op = new ConvolveOp(new Kernel(kernel_size, kernel_size, blurKernel));
return op.filter(img, null);
}
GaussianFilter.java 文件源码
项目:pumpernickel
阅读 25
收藏 0
点赞 0
评论 0
/**
* Make a Gaussian blur kernel.
*/
public static Kernel makeKernel(float radius) {
int r = (int)Math.ceil(radius);
int rows = r*2+1;
float[] matrix = new float[rows];
float sigma = radius/3;
float sigma22 = 2*sigma*sigma;
float sigmaPi2 = 2*ImageMath.PI*sigma;
float sqrtSigmaPi2 = (float)Math.sqrt(sigmaPi2);
float radius2 = radius*radius;
float total = 0;
int index = 0;
for (int row = -r; row <= r; row++) {
float distance = row*row;
if (distance > radius2)
matrix[index] = 0;
else
matrix[index] = (float)Math.exp(-(distance)/sigma22) / sqrtSigmaPi2;
total += matrix[index];
index++;
}
for (int i = 0; i < rows; i++)
matrix[i] /= total;
return new Kernel(rows, 1, matrix);
}
BufferedBufImgOps.java 文件源码
项目:jdk8u_jdk
阅读 22
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
BufferedBufImgOps.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 26
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
SmartBlurFilter.java 文件源码
项目:iSeleda
阅读 70
收藏 0
点赞 0
评论 0
@Override
public BufferedImage filter(BufferedImage src, BufferedImage dst) {
int width = src.getWidth();
int height = src.getHeight();
if (dst == null) {
dst = createCompatibleDestImage(src, null);
}
int[] inPixels = new int[width * height];
int[] outPixels = new int[width * height];
getRGB(src, 0, 0, width, height, inPixels);
Kernel kernel = GaussianFilter.makeKernel(hRadius);
thresholdBlur(kernel, inPixels, outPixels, width, height, true);
thresholdBlur(kernel, outPixels, inPixels, height, width, true);
setRGB(dst, 0, 0, width, height, inPixels);
return dst;
}
GenLayerBlurAll.java 文件源码
项目:vintagetg
阅读 26
收藏 0
点赞 0
评论 0
@Override
public int[] getInts(int xCoord, int zCoord, int sizeX, int sizeZ) {
int margin = 10;
xCoord -= margin;
zCoord -= margin;
sizeX += 2*margin;
sizeZ += 2*margin;
int[] inInts = this.parent.getInts(xCoord, zCoord, sizeX, sizeZ);
int[] outInts = IntCache.getIntCache(inInts.length);
Kernel kernel = makeKernel(radius);
for (int i = 0; i < iterations; i++) {
gaussBlurGrayScale(kernel, inInts, outInts, sizeX, sizeZ);
gaussBlurGrayScale(kernel, outInts, inInts, sizeZ, sizeX);
}
return cutMargins(inInts, sizeX, sizeZ, margin);
}
ConvolveFilter.java 文件源码
项目:PasswordSafe
阅读 19
收藏 0
点赞 0
评论 0
/**
* Convolve a block of pixels.
* @param kernel the kernel
* @param inPixels the input pixels
* @param outPixels the output pixels
* @param width the width
* @param height the height
* @param alpha include alpha channel
* @param edgeAction what to do at the edges
*/
public static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
{
if(kernel.getHeight() == 1)
{
convolveH(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
}
else if(kernel.getWidth() == 1)
{
convolveV(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
}
else
{
convolveHV(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
}
}
Logic.java 文件源码
项目:AvoinApotti
阅读 19
收藏 0
点赞 0
评论 0
public static BufferedImage blurImage(BufferedImage image)
{
float ninth = 1.0f/9.0f;
float[] blurKernel = {
ninth, ninth, ninth,
ninth, ninth, ninth,
ninth, ninth, ninth
};
Map<RenderingHints.Key, Object> map = new HashMap<RenderingHints.Key, Object>();
map.put(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
map.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
map.put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints hints = new RenderingHints(map);
BufferedImageOp op = new ConvolveOp(new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, hints);
return op.filter(image, null);
}
GaussianFilter.java 文件源码
项目:Lucee
阅读 23
收藏 0
点赞 0
评论 0
/**
* Make a Gaussian blur kernel.
* @param radius the blur radius
* @return the kernel
*/
public static Kernel makeKernel(float radius) {
int r = (int)Math.ceil(radius);
int rows = r*2+1;
float[] matrix = new float[rows];
float sigma = radius/3;
float sigma22 = 2*sigma*sigma;
float sigmaPi2 = 2*ImageMath.PI*sigma;
float sqrtSigmaPi2 = (float)Math.sqrt(sigmaPi2);
float radius2 = radius*radius;
float total = 0;
int index = 0;
for (int row = -r; row <= r; row++) {
float distance = row*row;
if (distance > radius2)
matrix[index] = 0;
else
matrix[index] = (float)Math.exp(-(distance)/sigma22) / sqrtSigmaPi2;
total += matrix[index];
index++;
}
for (int i = 0; i < rows; i++)
matrix[i] /= total;
return new Kernel(rows, 1, matrix);
}
SmartBlurFilter.java 文件源码
项目:Lucee4
阅读 22
收藏 0
点赞 0
评论 0
public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
int width = src.getWidth();
int height = src.getHeight();
if ( dst == null )
dst = createCompatibleDestImage( src, null );
int[] inPixels = new int[width*height];
int[] outPixels = new int[width*height];
getRGB( src, 0, 0, width, height, inPixels );
Kernel kernel = GaussianFilter.makeKernel(hRadius);
thresholdBlur( kernel, inPixels, outPixels, width, height, true );
thresholdBlur( kernel, outPixels, inPixels, height, width, true );
setRGB( dst, 0, 0, width, height, inPixels );
return dst;
}
ImageFilterKernel.java 文件源码
项目:Lucee4
阅读 23
收藏 0
点赞 0
评论 0
public static Object call(PageContext pc, double width, double height, Object oData) throws PageException {
float[] data=null;
if(oData instanceof float[])
data=(float[]) oData;
else if(Decision.isNativeArray(oData)) {
data=toFloatArray(pc,oData);
}
else if(Decision.isArray(oData)) {
data=toFloatArray(pc,Caster.toNativeArray(oData));
}
else
throw new FunctionException(pc, "", 3, "data", "cannot cast data to a float array");
return new Kernel(Caster.toIntValue(width),Caster.toIntValue(height),data);
}
BufferedBufImgOps.java 文件源码
项目:infobip-open-jdk-8
阅读 19
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
BufferedBufImgOps.java 文件源码
项目:jdk8u-dev-jdk
阅读 22
收藏 0
点赞 0
评论 0
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
SmartBlurFilter.java 文件源码
项目:webcamstudio
阅读 34
收藏 0
点赞 0
评论 0
@Override
public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
int width = src.getWidth();
int height = src.getHeight();
if ( dst == null ) {
dst = createCompatibleDestImage( src, null );
}
int[] inPixels = new int[width*height];
int[] outPixels = new int[width*height];
getRGB( src, 0, 0, width, height, inPixels );
Kernel kernel = GaussianFilter.makeKernel(hRadius);
thresholdBlur( kernel, inPixels, outPixels, width, height, true );
thresholdBlur( kernel, outPixels, inPixels, height, width, true );
setRGB( dst, 0, 0, width, height, inPixels );
return dst;
}
SmartBlurFilter.java 文件源码
项目:Lucee
阅读 25
收藏 0
点赞 0
评论 0
@Override
public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
int width = src.getWidth();
int height = src.getHeight();
if ( dst == null )
dst = createCompatibleDestImage( src, null );
int[] inPixels = new int[width*height];
int[] outPixels = new int[width*height];
getRGB( src, 0, 0, width, height, inPixels );
Kernel kernel = GaussianFilter.makeKernel(hRadius);
thresholdBlur( kernel, inPixels, outPixels, width, height, true );
thresholdBlur( kernel, outPixels, inPixels, height, width, true );
setRGB( dst, 0, 0, width, height, inPixels );
return dst;
}
ImageFilterKernel.java 文件源码
项目:Lucee
阅读 22
收藏 0
点赞 0
评论 0
public static Object call(PageContext pc, double width, double height, Object oData) throws PageException {
float[] data=null;
if(oData instanceof float[])
data=(float[]) oData;
else if(Decision.isNativeArray(oData)) {
data=toFloatArray(pc,oData);
}
else if(Decision.isArray(oData)) {
data=toFloatArray(pc,Caster.toNativeArray(oData));
}
else
throw new FunctionException(pc, "", 3, "data", "cannot cast data to a float array");
return new Kernel(Caster.toIntValue(width),Caster.toIntValue(height),data);
}
ShadowEffect.java 文件源码
项目:trashjam2017
阅读 23
收藏 0
点赞 0
评论 0
/**
* Apply blurring to the generate image
*
* @param image The image to be blurred
*/
private void blur(BufferedImage image) {
float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
BufferedImage scratchImage = EffectUtil.getScratchImage();
for (int i = 0; i < blurPasses; i++) {
gaussianOp1.filter(image, scratchImage);
gaussianOp2.filter(scratchImage, image);
}
}
ConvolveWidget.java 文件源码
项目:incubator-netbeans
阅读 19
收藏 0
点赞 0
评论 0
/**
* Creates a convolve widget with a specified ColvolveOp.
* @param scene the scene
* @param convolveOp the convolve operation
*/
public ConvolveWidget (Scene scene, ConvolveOp convolveOp) {
super (scene);
this.convolveOp = convolveOp;
Kernel kernel = convolveOp.getKernel ();
setBorder (BorderFactory.createEmptyBorder (kernel.getWidth (), kernel.getHeight ()));
}
ShadowEffect.java 文件源码
项目:Progetto-C
阅读 20
收藏 0
点赞 0
评论 0
/**
* Apply blurring to the generate image
*
* @param image The image to be blurred
*/
private void blur(BufferedImage image) {
float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
BufferedImage scratchImage = EffectUtil.getScratchImage();
for (int i = 0; i < blurPasses; i++) {
gaussianOp1.filter(image, scratchImage);
gaussianOp2.filter(scratchImage, image);
}
}
ImageProducer.java 文件源码
项目:oscm
阅读 37
收藏 0
点赞 0
评论 0
/**
* @param bimage
*/
private static BufferedImage blurImage(final BufferedImage bimage) {
float[] fs = new float[] { 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f,
1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f };
final Kernel kernel = new Kernel(3, 3, fs);
final BufferedImageOp op = new ConvolveOp(kernel);
return op.filter(bimage, null);
}
ShadowEffect.java 文件源码
项目:BaseClient
阅读 28
收藏 0
点赞 0
评论 0
/**
* Apply blurring to the generate image
*
* @param image The image to be blurred
*/
private void blur(BufferedImage image) {
float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
BufferedImage scratchImage = EffectUtil.getScratchImage();
for (int i = 0; i < blurPasses; i++) {
gaussianOp1.filter(image, scratchImage);
gaussianOp2.filter(scratchImage, image);
}
}