use of java.awt.image.ConvolveOp in project jdk8u_jdk by JetBrains.
the class ImagingLib method filter.
public static WritableRaster filter(RasterOp op, Raster src, WritableRaster dst) {
if (useLib == false) {
return null;
}
// Create the destination tile
if (dst == null) {
dst = op.createCompatibleDestRaster(src);
}
WritableRaster retRaster = null;
switch(getNativeOpIndex(op.getClass())) {
case LOOKUP_OP:
// REMIND: Fix this!
LookupTable table = ((LookupOp) op).getTable();
if (table.getOffset() != 0) {
// Right now the native code doesn't support offsets
return null;
}
if (table instanceof ByteLookupTable) {
ByteLookupTable bt = (ByteLookupTable) table;
if (lookupByteRaster(src, dst, bt.getTable()) > 0) {
retRaster = dst;
}
}
break;
case AFFINE_OP:
AffineTransformOp bOp = (AffineTransformOp) op;
double[] matrix = new double[6];
bOp.getTransform().getMatrix(matrix);
if (transformRaster(src, dst, matrix, bOp.getInterpolationType()) > 0) {
retRaster = dst;
}
break;
case CONVOLVE_OP:
ConvolveOp cOp = (ConvolveOp) op;
if (convolveRaster(src, dst, cOp.getKernel(), cOp.getEdgeCondition()) > 0) {
retRaster = dst;
}
break;
default:
break;
}
if (retRaster != null) {
SunWritableRaster.markDirty(retRaster);
}
return retRaster;
}
use of java.awt.image.ConvolveOp in project jdk8u_jdk by JetBrains.
the class OGLBufImgOps method renderImageWithOp.
/**
* This method is called from OGLDrawImage.transformImage() only. It
* validates the provided BufferedImageOp to determine whether the op
* is one that can be accelerated by the OGL pipeline. If the operation
* cannot be completed for any reason, this method returns false;
* otherwise, the given BufferedImage is rendered to the destination
* using the provided BufferedImageOp and this method returns true.
*/
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img, BufferedImageOp biop, int x, int y) {
// is supported, and that its properties are acceleratable)
if (biop instanceof ConvolveOp) {
if (!isConvolveOpValid((ConvolveOp) biop)) {
return false;
}
} else if (biop instanceof RescaleOp) {
if (!isRescaleOpValid((RescaleOp) biop, img)) {
return false;
}
} else if (biop instanceof LookupOp) {
if (!isLookupOpValid((LookupOp) biop, img)) {
return false;
}
} else {
// No acceleration for other BufferedImageOps (yet)
return false;
}
SurfaceData dstData = sg.surfaceData;
if (!(dstData instanceof OGLSurfaceData) || (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) || (sg.compositeState > SunGraphics2D.COMP_ALPHA)) {
return false;
}
SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
// REMIND: this hack tries to ensure that we have a cached texture
srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
return false;
}
}
// Verify that the source surface is actually a texture and
// that the operation is supported
OGLSurfaceData oglSrc = (OGLSurfaceData) srcData;
OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
if (oglSrc.getType() != OGLSurfaceData.TEXTURE || !gc.isCapPresent(CAPS_EXT_BIOP_SHADER)) {
return false;
}
int sw = img.getWidth();
int sh = img.getHeight();
OGLBlitLoops.IsoBlit(srcData, dstData, img, biop, sg.composite, sg.getCompClip(), sg.transform, sg.interpolationType, 0, 0, sw, sh, x, y, x + sw, y + sh, true);
return true;
}
use of java.awt.image.ConvolveOp in project jdk8u_jdk by JetBrains.
the class D3DBufImgOps method renderImageWithOp.
/**
* This method is called from D3DDrawImage.transformImage() only. It
* validates the provided BufferedImageOp to determine whether the op
* is one that can be accelerated by the D3D pipeline. If the operation
* cannot be completed for any reason, this method returns false;
* otherwise, the given BufferedImage is rendered to the destination
* using the provided BufferedImageOp and this method returns true.
*/
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img, BufferedImageOp biop, int x, int y) {
// is supported, and that its properties are acceleratable)
if (biop instanceof ConvolveOp) {
if (!isConvolveOpValid((ConvolveOp) biop)) {
return false;
}
} else if (biop instanceof RescaleOp) {
if (!isRescaleOpValid((RescaleOp) biop, img)) {
return false;
}
} else if (biop instanceof LookupOp) {
if (!isLookupOpValid((LookupOp) biop, img)) {
return false;
}
} else {
// No acceleration for other BufferedImageOps (yet)
return false;
}
SurfaceData dstData = sg.surfaceData;
if (!(dstData instanceof D3DSurfaceData) || (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) || (sg.compositeState > SunGraphics2D.COMP_ALPHA)) {
return false;
}
SurfaceData srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
if (!(srcData instanceof D3DSurfaceData)) {
// REMIND: this hack tries to ensure that we have a cached texture
srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
if (!(srcData instanceof D3DSurfaceData)) {
return false;
}
}
// Verify that the source surface is actually a texture and that
// shaders are supported
D3DSurfaceData d3dSrc = (D3DSurfaceData) srcData;
D3DGraphicsDevice gd = (D3DGraphicsDevice) d3dSrc.getDeviceConfiguration().getDevice();
if (d3dSrc.getType() != D3DSurfaceData.TEXTURE || !gd.isCapPresent(CAPS_LCD_SHADER)) {
return false;
}
int sw = img.getWidth();
int sh = img.getHeight();
D3DBlitLoops.IsoBlit(srcData, dstData, img, biop, sg.composite, sg.getCompClip(), sg.transform, sg.interpolationType, 0, 0, sw, sh, x, y, x + sw, y + sh, true);
return true;
}
use of java.awt.image.ConvolveOp in project libgdx by libgdx.
the class ShadowEffect method blur.
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);
}
}
use of java.awt.image.ConvolveOp in project jdk8u_jdk by JetBrains.
the class ImagingLib method filter.
public static BufferedImage filter(BufferedImageOp op, BufferedImage src, BufferedImage dst) {
if (verbose) {
System.out.println("in filter and op is " + op + "bufimage is " + src + " and " + dst);
}
if (useLib == false) {
return null;
}
// Create the destination image
if (dst == null) {
dst = op.createCompatibleDestImage(src, null);
}
BufferedImage retBI = null;
switch(getNativeOpIndex(op.getClass())) {
case LOOKUP_OP:
// REMIND: Fix this!
LookupTable table = ((LookupOp) op).getTable();
if (table.getOffset() != 0) {
// Right now the native code doesn't support offsets
return null;
}
if (table instanceof ByteLookupTable) {
ByteLookupTable bt = (ByteLookupTable) table;
if (lookupByteBI(src, dst, bt.getTable()) > 0) {
retBI = dst;
}
}
break;
case AFFINE_OP:
AffineTransformOp bOp = (AffineTransformOp) op;
double[] matrix = new double[6];
AffineTransform xform = bOp.getTransform();
bOp.getTransform().getMatrix(matrix);
if (transformBI(src, dst, matrix, bOp.getInterpolationType()) > 0) {
retBI = dst;
}
break;
case CONVOLVE_OP:
ConvolveOp cOp = (ConvolveOp) op;
if (convolveBI(src, dst, cOp.getKernel(), cOp.getEdgeCondition()) > 0) {
retBI = dst;
}
break;
default:
break;
}
if (retBI != null) {
SunWritableRaster.markDirty(retBI);
}
return retBI;
}
Aggregations