use of java.awt.image.LookupOp in project AozoraEpub3 by hmdev.
the class Epub3Writer method setImageParam.
/** 画像のリサイズ用パラメータを設定 */
public void setImageParam(int dispW, int dispH, int coverW, int coverH, int resizeW, int resizeH, int singlePageSizeW, int singlePageSizeH, int singlePageWidth, int imageSizeType, boolean fitImage, boolean isSvgImage, int rotateAngle, float imageScale, int imageFloatType, int imageFloatW, int imageFloatH, float jpegQuality, float gamma, int autoMarginLimitH, int autoMarginLimitV, int autoMarginWhiteLevel, float autoMarginPadding, int autoMarginNombre, float nombreSize) {
this.dispW = dispW;
this.dispH = dispH;
this.maxImageW = resizeW;
this.maxImageH = resizeH;
this.singlePageSizeW = singlePageSizeW;
this.singlePageSizeH = singlePageSizeH;
this.singlePageWidth = singlePageWidth;
//0なら無効
this.imageScale = imageScale;
this.imageFloatType = imageFloatType;
this.imageFloatW = imageFloatW;
this.imageFloatH = imageFloatH;
this.imageSizeType = imageSizeType;
this.fitImage = fitImage;
this.isSvgImage = isSvgImage;
this.rotateAngle = rotateAngle;
this.coverW = coverW;
this.coverH = coverH;
this.jpegQuality = jpegQuality;
/*
if (gamma < 1 && gamma > 0) gammaOp = new RescaleOp(1/gamma, -256*1/gamma+256, null);
else if (gamma > 1) gammaOp = new RescaleOp(gamma, 0, null);*/
if (gamma != 1) {
byte[] table = new byte[256];
for (int i = 0; i < 256; i++) {
table[i] = (byte) Math.min(255, Math.round(255 * Math.pow((i / 255.0), 1 / gamma)));
}
gammaOp = new LookupOp(new ByteLookupTable(0, table), null);
} else
gammaOp = null;
this.autoMarginLimitH = autoMarginLimitH;
this.autoMarginLimitV = autoMarginLimitV;
this.autoMarginWhiteLevel = autoMarginWhiteLevel;
this.autoMarginPadding = autoMarginPadding;
this.autoMarginNombre = autoMarginNombre;
this.autoMarginNombreSize = nombreSize;
}
use of java.awt.image.LookupOp 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;
}
use of java.awt.image.LookupOp in project jdk8u_jdk by JetBrains.
the class IntImageReverseTest method main.
public static void main(String[] args) {
LookupTable tbl = createReverseTable();
LookupOp op = new LookupOp(tbl, null);
for (ImageType t : ImageType.values()) {
System.out.print(t);
BufferedImage src = createSourceImage(t);
BufferedImage dst = op.filter(src, null);
int rgb = dst.getRGB(0, 0);
System.out.printf(" Result: 0x%X ", rgb);
if (rgb != argbReverse) {
throw new RuntimeException("Test failed.");
}
System.out.println("Passed.");
}
}
Aggregations