本文整理汇总了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));
}
示例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 ()));
}
示例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;
}
示例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);
}
示例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;
}