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


Java ConvolveOp.getKernel方法代码示例

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


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

示例1: enableConvolveOp

import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
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));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:BufferedBufImgOps.java

示例2: ConvolveWidget

import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
/**
 * 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 ()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ConvolveWidget.java

示例3: isConvolveOpValid

import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
/**************************** ConvolveOp support ****************************/

    public static boolean isConvolveOpValid(ConvolveOp cop) {
        Kernel kernel = cop.getKernel();
        int kw = kernel.getWidth();
        int kh = kernel.getHeight();
        // REMIND: we currently can only handle 3x3 and 5x5 kernels,
        //         but hopefully this is just a temporary restriction;
        //         see native shader comments for more details
        if (!(kw == 3 && kh == 3) && !(kw == 5 && kh == 5)) {
            return false;
        }
        return true;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:BufferedBufImgOps.java

示例4: paint

import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void paint(Graphics g) {
	if (bio == null && alpha == 1 || !(g instanceof Graphics2D)) {
		super.paint(g);
		return;
	}

	final Graphics2D g2 = (Graphics2D) g.create();

	Rectangle clipBounds = g2.getClipBounds();

	if (clipBounds == null) {
		clipBounds = new Rectangle(getSize());
	}
	if (clipBounds.isEmpty()) {
		return;
	}

	final boolean isConvolveOp = bio instanceof ConvolveOp;

	if (isConvolveOp) {
		final ConvolveOp cop = (ConvolveOp) bio;
		final Kernel kernel = cop.getKernel();
		clipBounds.grow(kernel.getWidth() / 2, kernel.getHeight() / 2);
	}

	createTempImagesIfNecessary(clipBounds);

	final Graphics2D bufg = (Graphics2D) tempSrc.getGraphics();
	bufg.translate(-clipBounds.x, -clipBounds.y);
	bufg.setClip(clipBounds);
	super.paint(bufg);
	bufg.dispose();

	applyFilter(g2, clipBounds, isConvolveOp);
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:38,代码来源:JXLayer.java

示例5: toSVG

import java.awt.image.ConvolveOp; //导入方法依赖的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


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