use of java.awt.image.LookupOp in project jdk8u_jdk by JetBrains.
the class MlibOpsTest method getLookupOp.
private static BufferedImageOp getLookupOp() {
byte[] inv = new byte[256];
for (int i = 0; i < 256; i++) {
inv[i] = (byte) (255 - i);
}
ByteLookupTable table = new ByteLookupTable(0, inv);
return new LookupOp(table, null);
}
use of java.awt.image.LookupOp in project ChatGameFontificator by GlitchCog.
the class Sprite method setupSwap.
private void setupSwap() {
short[][] lookupArray = new short[4][256];
for (int i = 0; i < lookupArray.length; i++) {
for (short c = 0; c < lookupArray[i].length; c++) {
lookupArray[i][c] = c;
}
}
swapTable = new ShortLookupTable(0, lookupArray);
swapOp = new LookupOp(swapTable, null);
}
use of java.awt.image.LookupOp 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.LookupOp 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.LookupOp 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;
}
Aggregations