当前位置: 首页>>代码示例>>Java>>正文


Java Kernel.getKernelData方法代码示例

本文整理汇总了Java中java.awt.image.Kernel.getKernelData方法的典型用法代码示例。如果您正苦于以下问题:Java Kernel.getKernelData方法的具体用法?Java Kernel.getKernelData怎么用?Java Kernel.getKernelData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.Kernel的用法示例。


在下文中一共展示了Kernel.getKernelData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setKernel

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Sets the Convolution Kernel to use.
 * @param k Kernel to use for convolution.
 */
public void setKernel(Kernel k) {
    touch();
    this.kernel = k;
    kernelHasNegValues = false;
    float [] kv = k.getKernelData(null);
    for (int i=0; i<kv.length; i++)
        if (kv[i] < 0) {
            kernelHasNegValues = true;
            break;
        }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:16,代码来源:ConvolveMatrixRable8Bit.java

示例2: convolveAndTranspose

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
     * Blur and transpose a block of ARGB pixels.
     *
     * @param kernel     the blur kernel
     * @param inPixels   the input pixels
     * @param outPixels  the output pixels
     * @param width      the width of the pixel array
     * @param height     the height of the pixel array
     * @param alpha      whether to blur the alpha channel
     * @param edgeAction what to do at the edges
     */
    public static void convolveAndTranspose(Kernel kernel, final int[] inPixels, final int[] outPixels, final int width, final int height, final boolean alpha, final boolean premultiply, final boolean unpremultiply, final int edgeAction) {
        final float[] matrix = kernel.getKernelData(null);
        int cols = kernel.getWidth();
        final int cols2 = cols / 2;

        boolean oneThreaded = (ThreadPool.NUM_AVAILABLE_PROCESSORS == 1);
//        boolean oneThreaded = true;

        if(oneThreaded) {
            for (int y = 0; y < height; y++) {
                convolveAndTransposeLine(inPixels, outPixels, width, height, alpha, premultiply, unpremultiply, edgeAction, matrix, cols2, y);
            }
        } else {
            Future<?>[] resultLines = new Future[height];

            for (int y = 0; y < height; y++) {
                final int finalY = y;
                Runnable lineTask = new Runnable() {
                    @Override
                    public void run() {
                        convolveAndTransposeLine(inPixels, outPixels, width, height, alpha, premultiply, unpremultiply, edgeAction, matrix, cols2, finalY);
                    }
                };
                Future<?> future = ThreadPool.executorService.submit(lineTask);
                resultLines[y] = future;
            }

            ThreadPool.waitForFutures(resultLines);
        }
    }
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:42,代码来源:GaussianFilter.java

示例3: gaussBlurGrayScale

import java.awt.image.Kernel; //导入方法依赖的package包/类
private void gaussBlurGrayScale(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height) {
	float[] matrix = kernel.getKernelData(null);
	int cols = kernel.getWidth();
	int cols2 = cols/2;

	int colorClearMask = ~(0xff << rgbselect);
			
	
	
	for (int y = 0; y < height; y++) {
		int index = y;
		int ioffset = y*width;
		
		for (int x = 0; x < width; x++) {
			float gray = 0;
			int moffset = cols2;
			
			for (int col = -cols2; col <= cols2; col++) {
				float f = matrix[moffset+col];

				if (f != 0) {
					int ix = x + col;
					
					if (ix < 0) {
						ix = 0 ;
					} else if ( ix >= width) {
						ix = width - 1;
					}
				
					gray +=  f * ((inPixels[ioffset+ix] >> rgbselect) & 0xff);
				}
			}
			
			outPixels[index] = (inPixels[index] & colorClearMask) + (boundBy((int)(gray + 0.5), 0, 255) << rgbselect);
               index += height;
		}
	}
}
 
开发者ID:tyronx,项目名称:vintagetg,代码行数:39,代码来源:GenLayerBlurSelective.java

示例4: convolveAndTranspose

import java.awt.image.Kernel; //导入方法依赖的package包/类
public static void convolveAndTranspose(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
	float[] matrix = kernel.getKernelData( null );
	int cols = kernel.getWidth();
	int cols2 = cols/2;

	for (int y = 0; y < height; y++) {
		int index = y;
		int ioffset = y*width;
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0, a = 0;
			int moffset = cols2;
			for (int col = -cols2; col <= cols2; col++) {
				float f = matrix[moffset+col];

				if (f != 0) {
					int ix = x+col;
					if ( ix < 0 ) {
						if ( edgeAction == CLAMP_EDGES )
							ix = 0;
						else if ( edgeAction == WRAP_EDGES )
							ix = (x+width) % width;
					} else if ( ix >= width) {
						if ( edgeAction == CLAMP_EDGES )
							ix = width-1;
						else if ( edgeAction == WRAP_EDGES )
							ix = (x+width) % width;
					}
					int rgb = inPixels[ioffset+ix];
					a += f * ((rgb >> 24) & 0xff);
					r += f * ((rgb >> 16) & 0xff);
					g += f * ((rgb >> 8) & 0xff);
					b += f * (rgb & 0xff);
				}
			}
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[index] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
               index += height;
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:44,代码来源:GaussianFilter.java

示例5: convolveHV

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a 2D kernel
 * 
 * @param kernel the kernel to apply
 * @param inPixels the input pixels
 * @param outPixels the output pixels
 * @param width the width of the image
 * @param height the height of the image
 * @param alpha whether alpha is present
 * @param edgeAction one of the edge constants
 */
public static void convolveHV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
	int index = 0;
	float[] matrix = kernel.getKernelData( null );
	int rows = kernel.getHeight();
	int cols = kernel.getWidth();
	int rows2 = rows/2;
	int cols2 = cols/2;

	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0, a = 0;

			for (int row = -rows2; row <= rows2; row++) {
				int iy = y+row;
				int ioffset;
				if (0 <= iy && iy < height)
					ioffset = iy*width;
				else if ( edgeAction == CLAMP_EDGES )
					ioffset = y*width;
				else if ( edgeAction == WRAP_EDGES )
					ioffset = ((iy+height) % height) * width;
				else
					continue;
				int moffset = cols*(row+rows2)+cols2;
				for (int col = -cols2; col <= cols2; col++) {
					float f = matrix[moffset+col];

					if (f != 0) {
						int ix = x+col;
						if (!(0 <= ix && ix < width)) {
							if ( edgeAction == CLAMP_EDGES )
								ix = x;
							else if ( edgeAction == WRAP_EDGES )
								ix = (x+width) % width;
							else
								continue;
						}
						int rgb = inPixels[ioffset+ix];
						a += f * ((rgb >> 24) & 0xff);
						r += f * ((rgb >> 16) & 0xff);
						g += f * ((rgb >> 8) & 0xff);
						b += f * (rgb & 0xff);
					}
				}
			}
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:65,代码来源:ConvolveFilter.java

示例6: convolveH

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a kernel consisting of one row
 * 
 * @param kernel the kernel to apply
 * @param inPixels the input pixels
 * @param outPixels the output pixels
 * @param width the width of the image
 * @param height the height of the image
 * @param alpha whether alpha is present
 * @param edgeAction one of the edge constants
 */
public static void convolveH(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
	int index = 0;
	float[] matrix = kernel.getKernelData( null );
	int cols = kernel.getWidth();
	int cols2 = cols/2;

	for (int y = 0; y < height; y++) {
		int ioffset = y*width;
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0, a = 0;
			int moffset = cols2;
			for (int col = -cols2; col <= cols2; col++) {
				float f = matrix[moffset+col];

				if (f != 0) {
					int ix = x+col;
					if ( ix < 0 ) {
						if ( edgeAction == CLAMP_EDGES )
							ix = 0;
						else if ( edgeAction == WRAP_EDGES )
							ix = (x+width) % width;
					} else if ( ix >= width) {
						if ( edgeAction == CLAMP_EDGES )
							ix = width-1;
						else if ( edgeAction == WRAP_EDGES )
							ix = (x+width) % width;
					}
					int rgb = inPixels[ioffset+ix];
					a += f * ((rgb >> 24) & 0xff);
					r += f * ((rgb >> 16) & 0xff);
					g += f * ((rgb >> 8) & 0xff);
					b += f * (rgb & 0xff);
				}
			}
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:54,代码来源:ConvolveFilter.java

示例7: convolveV

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a kernel consisting of one column
 * @param kernel the kernel to apply
 * @param inPixels the input pixels
 * @param outPixels the output pixels
 * @param width the width of the image
 * @param height the height of the image
 * @param alpha whether alpha is present
 * @param edgeAction one of the edge constants
 */
public static void convolveV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
	int index = 0;
	float[] matrix = kernel.getKernelData( null );
	int rows = kernel.getHeight();
	int rows2 = rows/2;

	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0, a = 0;

			for (int row = -rows2; row <= rows2; row++) {
				int iy = y+row;
				int ioffset;
				if ( iy < 0 ) {
					if ( edgeAction == CLAMP_EDGES )
						ioffset = 0;
					else if ( edgeAction == WRAP_EDGES )
						ioffset = ((y+height) % height)*width;
					else
						ioffset = iy*width;
				} else if ( iy >= height) {
					if ( edgeAction == CLAMP_EDGES )
						ioffset = (height-1)*width;
					else if ( edgeAction == WRAP_EDGES )
						ioffset = ((y+height) % height)*width;
					else
						ioffset = iy*width;
				} else
					ioffset = iy*width;

				float f = matrix[row+rows2];

				if (f != 0) {
					int rgb = inPixels[ioffset+x];
					a += f * ((rgb >> 24) & 0xff);
					r += f * ((rgb >> 16) & 0xff);
					g += f * ((rgb >> 8) & 0xff);
					b += f * (rgb & 0xff);
				}
			}
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:59,代码来源:ConvolveFilter.java

示例8: toSVG

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * @param convolveOp the ConvolveOp to be converted
 * @return a description of the SVG filter corresponding to
 *         convolveOp. The definition of the feConvolveMatrix
 *         filter in put in feConvolveMatrixDefSet
 */
public SVGFilterDescriptor toSVG(ConvolveOp convolveOp){
    // Reuse definition if convolveOp has already been converted
    SVGFilterDescriptor filterDesc =
        (SVGFilterDescriptor)descMap.get(convolveOp);
    Document domFactory = generatorContext.domFactory;

    if (filterDesc == null) {
        //
        // First time filter is converted: create its corresponding
        // SVG filter
        //
        Kernel kernel = convolveOp.getKernel();
        Element filterDef =
            domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FILTER_TAG);
        Element feConvolveMatrixDef =
            domFactory.createElementNS(SVG_NAMESPACE_URI,
                                       SVG_FE_CONVOLVE_MATRIX_TAG);

        // Convert the kernel size
        feConvolveMatrixDef.setAttributeNS(null, SVG_ORDER_ATTRIBUTE,
                                         kernel.getWidth() + SPACE +
                                         kernel.getHeight());

        // Convert the kernel values
        float[] data = kernel.getKernelData(null);
        StringBuffer kernelMatrixBuf = new StringBuffer( data.length * 8 );
        for(int i=0; i<data.length; i++){
            kernelMatrixBuf.append(doubleString(data[i]));
            kernelMatrixBuf.append(SPACE);
        }

        feConvolveMatrixDef.
            setAttributeNS(null, SVG_KERNEL_MATRIX_ATTRIBUTE,
                           kernelMatrixBuf.toString().trim());

        filterDef.appendChild(feConvolveMatrixDef);

        filterDef.setAttributeNS(null, SVG_ID_ATTRIBUTE,
                                 generatorContext.idGenerator.
                                 generateID(ID_PREFIX_FE_CONVOLVE_MATRIX));

        // Convert the edge mode
        if(convolveOp.getEdgeCondition() == ConvolveOp.EDGE_NO_OP)
            feConvolveMatrixDef.setAttributeNS(null, SVG_EDGE_MODE_ATTRIBUTE,
                                             SVG_DUPLICATE_VALUE);
        else
            feConvolveMatrixDef.setAttributeNS(null, SVG_EDGE_MODE_ATTRIBUTE,
                                             SVG_NONE_VALUE);

        //
        // Create a filter descriptor
        //

        // Process filter attribute
        StringBuffer filterAttrBuf = new StringBuffer(URL_PREFIX);
        filterAttrBuf.append(SIGN_POUND);
        filterAttrBuf.append(filterDef.getAttributeNS(null, SVG_ID_ATTRIBUTE));
        filterAttrBuf.append(URL_SUFFIX);

        filterDesc = new SVGFilterDescriptor(filterAttrBuf.toString(),
                                             filterDef);

        defSet.add(filterDef);
        descMap.put(convolveOp, filterDesc);
    }

    return filterDesc;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:75,代码来源:SVGConvolveOp.java

示例9: thresholdBlur

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
     * Convolve with a kernel consisting of one row
     */
    private void thresholdBlur(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha) {
//		int index = 0;
        float[] matrix = kernel.getKernelData(null);
        int cols = kernel.getWidth();
        int cols2 = cols / 2;

        for (int y = 0; y < height; y++) {
            int ioffset = y * width;
            int outIndex = y;
            for (int x = 0; x < width; x++) {
                float r = 0, g = 0, b = 0, a = 0;
                int moffset = cols2;

                int rgb1 = inPixels[ioffset + x];
                int a1 = (rgb1 >> 24) & 0xff;
                int r1 = (rgb1 >> 16) & 0xff;
                int g1 = (rgb1 >> 8) & 0xff;
                int b1 = rgb1 & 0xff;
                float af = 0, rf = 0, gf = 0, bf = 0;
                for (int col = -cols2; col <= cols2; col++) {
                    float f = matrix[moffset + col];

                    if (f != 0) {
                        int ix = x + col;
                        if (!(0 <= ix && ix < width)) {
                            ix = x;
                        }
                        int rgb2 = inPixels[ioffset + ix];
                        int a2 = (rgb2 >> 24) & 0xff;
                        int r2 = (rgb2 >> 16) & 0xff;
                        int g2 = (rgb2 >> 8) & 0xff;
                        int b2 = rgb2 & 0xff;

                        int d;
                        d = a1 - a2;
                        if (d >= -threshold && d <= threshold) {
                            a += f * a2;
                            af += f;
                        }
                        d = r1 - r2;
                        if (d >= -threshold && d <= threshold) {
                            r += f * r2;
                            rf += f;
                        }
                        d = g1 - g2;
                        if (d >= -threshold && d <= threshold) {
                            g += f * g2;
                            gf += f;
                        }
                        d = b1 - b2;
                        if (d >= -threshold && d <= threshold) {
                            b += f * b2;
                            bf += f;
                        }
                    }
                }
                a = af == 0 ? a1 : a / af;
                r = rf == 0 ? r1 : r / rf;
                g = gf == 0 ? g1 : g / gf;
                b = bf == 0 ? b1 : b / bf;
                int ia = alpha ? PixelUtils.clamp((int) (a + 0.5)) : 0xff;
                int ir = PixelUtils.clamp((int) (r + 0.5));
                int ig = PixelUtils.clamp((int) (g + 0.5));
                int ib = PixelUtils.clamp((int) (b + 0.5));
                outPixels[outIndex] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
                outIndex += height;
            }
        }
    }
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:73,代码来源:SmartBlurFilter.java

示例10: convolveHV

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a 2D kernel.
 *
 * @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 convolveHV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
    int index = 0;
    float[] matrix = kernel.getKernelData(null);
    int rows = kernel.getHeight();
    int cols = kernel.getWidth();
    int rows2 = rows / 2;
    int cols2 = cols / 2;

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            float r = 0, g = 0, b = 0, a = 0;

            for (int row = -rows2; row <= rows2; row++) {
                int iy = y + row;
                int ioffset;
                if (0 <= iy && iy < height) {
                    ioffset = iy * width;
                } else if (edgeAction == CLAMP_EDGES) {
                    ioffset = y * width;
                } else if (edgeAction == WRAP_EDGES) {
                    ioffset = ((iy + height) % height) * width;
                } else {
                    continue;
                }
                int moffset = cols * (row + rows2) + cols2;
                for (int col = -cols2; col <= cols2; col++) {
                    float f = matrix[moffset + col];

                    if (f != 0) {
                        int ix = x + col;
                        if (!(0 <= ix && ix < width)) {
                            if (edgeAction == CLAMP_EDGES) {
                                ix = x;
                            } else if (edgeAction == WRAP_EDGES) {
                                ix = (x + width) % width;
                            } else {
                                continue;
                            }
                        }
                        int rgb = inPixels[ioffset + ix];
                        a += f * ((rgb >> 24) & 0xff);
                        r += f * ((rgb >> 16) & 0xff);
                        g += f * ((rgb >> 8) & 0xff);
                        b += f * (rgb & 0xff);
                    }
                }
            }
            int ia = alpha ? PixelUtils.clamp((int) (a + 0.5)) : 0xff;
            int ir = PixelUtils.clamp((int) (r + 0.5));
            int ig = PixelUtils.clamp((int) (g + 0.5));
            int ib = PixelUtils.clamp((int) (b + 0.5));
            outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
        }
    }
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:67,代码来源:ConvolveFilter.java

示例11: convolveH

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a kernel consisting of one row.
 *
 * @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 convolveH(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
    int index = 0;
    float[] matrix = kernel.getKernelData(null);
    int cols = kernel.getWidth();
    int cols2 = cols / 2;

    for (int y = 0; y < height; y++) {
        int ioffset = y * width;
        for (int x = 0; x < width; x++) {
            float r = 0, g = 0, b = 0, a = 0;
            int moffset = cols2;
            for (int col = -cols2; col <= cols2; col++) {
                float f = matrix[moffset + col];

                if (f != 0) {
                    int ix = x + col;
                    if (ix < 0) {
                        if (edgeAction == CLAMP_EDGES) {
                            ix = 0;
                        } else if (edgeAction == WRAP_EDGES) {
                            ix = (x + width) % width;
                        }
                    } else if (ix >= width) {
                        if (edgeAction == CLAMP_EDGES) {
                            ix = width - 1;
                        } else if (edgeAction == WRAP_EDGES) {
                            ix = (x + width) % width;
                        }
                    }
                    int rgb = inPixels[ioffset + ix];
                    a += f * ((rgb >> 24) & 0xff);
                    r += f * ((rgb >> 16) & 0xff);
                    g += f * ((rgb >> 8) & 0xff);
                    b += f * (rgb & 0xff);
                }
            }
            int ia = alpha ? PixelUtils.clamp((int) (a + 0.5)) : 0xff;
            int ir = PixelUtils.clamp((int) (r + 0.5));
            int ig = PixelUtils.clamp((int) (g + 0.5));
            int ib = PixelUtils.clamp((int) (b + 0.5));
            outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
        }
    }
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:56,代码来源:ConvolveFilter.java

示例12: convolveV

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
    * Convolve with a kernel consisting of one column.
    *
    * @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 convolveV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
       int index = 0;
       float[] matrix = kernel.getKernelData(null);
       int rows = kernel.getHeight();
       int rows2 = rows / 2;

       for (int y = 0; y < height; y++) {
           for (int x = 0; x < width; x++) {
               float r = 0, g = 0, b = 0, a = 0;

               for (int row = -rows2; row <= rows2; row++) {
                   int iy = y + row;
                   int ioffset;
                   if (iy < 0) {
                       if (edgeAction == CLAMP_EDGES) {
                           ioffset = 0;
                       } else if (edgeAction == WRAP_EDGES) {
                           ioffset = ((y + height) % height) * width;
                       } else {
                           ioffset = iy * width;
                       }
                   } else if (iy >= height) {
                       if (edgeAction == CLAMP_EDGES) {
                           ioffset = (height - 1) * width;
                       } else if (edgeAction == WRAP_EDGES) {
                           ioffset = ((y + height) % height) * width;
                       } else {
                           ioffset = iy * width;
                       }
                   } else {
                       ioffset = iy * width;
                   }

                   float f = matrix[row + rows2];

                   if (f != 0) {
                       int rgb = inPixels[ioffset + x];
                       a += f * ((rgb >> 24) & 0xff);
                       r += f * ((rgb >> 16) & 0xff);
                       g += f * ((rgb >> 8) & 0xff);
                       b += f * (rgb & 0xff);
				}
			}
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
		}
	}
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:63,代码来源:ConvolveFilter.java

示例13: gaussBlurGrayScale

import java.awt.image.Kernel; //导入方法依赖的package包/类
private void gaussBlurGrayScale(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height) {
	float[] matrix = kernel.getKernelData(null);
	int cols = kernel.getWidth();
	int cols2 = cols/2;

	for (int y = 0; y < height; y++) {
		int index = y;
		int ioffset = y*width;
		
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0/*, a = 0*/;
			int moffset = cols2;
			
			for (int col = -cols2; col <= cols2; col++) {
				float f = matrix[moffset+col];

				if (f != 0) {
					int ix = x + col;
					
					if (ix < 0) {
						ix = 0 ;
					} else if ( ix >= width) {
						ix = width - 1;
					}
				
					int rgb = inPixels[ioffset+ix];
					//a += f * ((rgb >> 24) & 0xff);
					r += f * ((rgb >> 16) & 0xff);
					g += f * ((rgb >> 8) & 0xff);
					b += f * (rgb & 0xff);
				}
			}
			
			//int ia = alpha ? clamped((int)(a+0.5)) : 0xff;
			int ir = clamped((int)(r+0.5));
			int ig = clamped((int)(g+0.5));
			int ib = clamped((int)(b+0.5));
			outPixels[index] = (ir << 16) | (ig << 8) | ib;
			
               index += height;
		}
	}
}
 
开发者ID:tyronx,项目名称:vintagetg,代码行数:44,代码来源:GenLayerBlurAll.java

示例14: convolveH

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a kernel consisting of one row.
 * @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 convolveH(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
{
	int index = 0;
	float[] matrix = kernel.getKernelData(null);
	int cols = kernel.getWidth();
	int cols2 = cols / 2;

	for(int y=0; y<height; y++)
	{
		CKit.checkCancelled();
		
		int ioffset = y * width;
		for(int x=0; x<width; x++)
		{
			float r = 0, g = 0, b = 0, a = 0;
			int moffset = cols2;
			for(int col = -cols2; col <= cols2; col++)
			{
				float f = matrix[moffset + col];
				if(f != 0)
				{
					int ix = x + col;
					if(ix < 0)
					{
						if(edgeAction == CLAMP_EDGES)
						{
							ix = 0;
						}
						else if(edgeAction == WRAP_EDGES)
						{
							ix = (x + width) % width;
						}
					}
					else if(ix >= width)
					{
						if(edgeAction == CLAMP_EDGES)
						{
							ix = width - 1;
						}
						else if(edgeAction == WRAP_EDGES)
						{
							ix = (x + width) % width;
						}
					}
					
					int rgb = inPixels[ioffset + ix];
					a += f * ((rgb >> 24) & 0xff);
					r += f * ((rgb >> 16) & 0xff);
					g += f * ((rgb >> 8) & 0xff);
					b += f * (rgb & 0xff);
				}
			}
			
			int ia = alpha ? PixelUtils.clamp((int)(a + 0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r + 0.5));
			int ig = PixelUtils.clamp((int)(g + 0.5));
			int ib = PixelUtils.clamp((int)(b + 0.5));
			outPixels[index++] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
		}
	}
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:72,代码来源:ConvolveFilter.java

示例15: thresholdBlur

import java.awt.image.Kernel; //导入方法依赖的package包/类
/**
 * Convolve with a kernel consisting of one row
 */
private void thresholdBlur(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha) {
	//int index = 0;
	float[] matrix = kernel.getKernelData( null );
	int cols = kernel.getWidth();
	int cols2 = cols/2;

	for (int y = 0; y < height; y++) {
		int ioffset = y*width;
           int outIndex = y;
		for (int x = 0; x < width; x++) {
			float r = 0, g = 0, b = 0, a = 0;
			int moffset = cols2;

               int rgb1 = inPixels[ioffset+x];
               int a1 = (rgb1 >> 24) & 0xff;
               int r1 = (rgb1 >> 16) & 0xff;
               int g1 = (rgb1 >> 8) & 0xff;
               int b1 = rgb1 & 0xff;
			float af = 0, rf = 0, gf = 0, bf = 0;
               for (int col = -cols2; col <= cols2; col++) {
				float f = matrix[moffset+col];

				if (f != 0) {
					int ix = x+col;
					if (!(0 <= ix && ix < width))
						ix = x;
					int rgb2 = inPixels[ioffset+ix];
                       int a2 = (rgb2 >> 24) & 0xff;
                       int r2 = (rgb2 >> 16) & 0xff;
                       int g2 = (rgb2 >> 8) & 0xff;
                       int b2 = rgb2 & 0xff;

					int d;
                       d = a1-a2;
                       if ( d >= -threshold && d <= threshold ) {
                           a += f * a2;
                           af += f;
                       }
                       d = r1-r2;
                       if ( d >= -threshold && d <= threshold ) {
                           r += f * r2;
                           rf += f;
                       }
                       d = g1-g2;
                       if ( d >= -threshold && d <= threshold ) {
                           g += f * g2;
                           gf += f;
                       }
                       d = b1-b2;
                       if ( d >= -threshold && d <= threshold ) {
                           b += f * b2;
                           bf += f;
                       }
				}
			}
               a = af == 0 ? a1 : a/af;
               r = rf == 0 ? r1 : r/rf;
               g = gf == 0 ? g1 : g/gf;
               b = bf == 0 ? b1 : b/bf;
			int ia = alpha ? PixelUtils.clamp((int)(a+0.5)) : 0xff;
			int ir = PixelUtils.clamp((int)(r+0.5));
			int ig = PixelUtils.clamp((int)(g+0.5));
			int ib = PixelUtils.clamp((int)(b+0.5));
			outPixels[outIndex] = (ia << 24) | (ir << 16) | (ig << 8) | ib;
               outIndex += height;
		}
	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:72,代码来源:SmartBlurFilter.java


注:本文中的java.awt.image.Kernel.getKernelData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。