Search in sources :

Example 1 with ByteLookupTable

use of java.awt.image.ByteLookupTable 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);
}
Also used : LookupOp(java.awt.image.LookupOp) ByteLookupTable(java.awt.image.ByteLookupTable) RadialGradientPaint(java.awt.RadialGradientPaint)

Example 2 with ByteLookupTable

use of java.awt.image.ByteLookupTable 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;
}
Also used : WritableRaster(java.awt.image.WritableRaster) ByteLookupTable(java.awt.image.ByteLookupTable) LookupTable(java.awt.image.LookupTable) ConvolveOp(java.awt.image.ConvolveOp) LookupOp(java.awt.image.LookupOp) ByteLookupTable(java.awt.image.ByteLookupTable) AffineTransformOp(java.awt.image.AffineTransformOp)

Example 3 with ByteLookupTable

use of java.awt.image.ByteLookupTable 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;
}
Also used : LookupOp(java.awt.image.LookupOp) ByteLookupTable(java.awt.image.ByteLookupTable)

Example 4 with ByteLookupTable

use of java.awt.image.ByteLookupTable 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;
}
Also used : ByteLookupTable(java.awt.image.ByteLookupTable) LookupTable(java.awt.image.LookupTable) AffineTransform(java.awt.geom.AffineTransform) ConvolveOp(java.awt.image.ConvolveOp) LookupOp(java.awt.image.LookupOp) ByteLookupTable(java.awt.image.ByteLookupTable) BufferedImage(java.awt.image.BufferedImage) AffineTransformOp(java.awt.image.AffineTransformOp)

Example 5 with ByteLookupTable

use of java.awt.image.ByteLookupTable in project jdk8u_jdk by JetBrains.

the class BufferedBufImgOps method isLookupOpValid.

/**************************** LookupOp support ******************************/
public static boolean isLookupOpValid(LookupOp lop, BufferedImage srcImg) {
    LookupTable table = lop.getTable();
    int numComps = table.getNumComponents();
    ColorModel srcCM = srcImg.getColorModel();
    if (srcCM instanceof IndexColorModel) {
        throw new IllegalArgumentException("LookupOp cannot be " + "performed on an indexed image");
    }
    if (numComps != 1 && numComps != srcCM.getNumComponents() && numComps != srcCM.getNumColorComponents()) {
        throw new IllegalArgumentException("Number of arrays in the " + " lookup table (" + numComps + ") is not compatible with" + " the src image: " + srcImg);
    }
    int csType = srcCM.getColorSpace().getType();
    if (csType != ColorSpace.TYPE_RGB && csType != ColorSpace.TYPE_GRAY) {
        // Not prepared to deal with other color spaces
        return false;
    }
    if (numComps == 2 || numComps > 4) {
        // Not really prepared to handle this at the native level, so...
        return false;
    }
    // these restrictions here.
    if (table instanceof ByteLookupTable) {
        byte[][] data = ((ByteLookupTable) table).getTable();
        for (int i = 1; i < data.length; i++) {
            if (data[i].length > 256 || data[i].length != data[i - 1].length) {
                return false;
            }
        }
    } else if (table instanceof ShortLookupTable) {
        short[][] data = ((ShortLookupTable) table).getTable();
        for (int i = 1; i < data.length; i++) {
            if (data[i].length > 256 || data[i].length != data[i - 1].length) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
Also used : ShortLookupTable(java.awt.image.ShortLookupTable) ColorModel(java.awt.image.ColorModel) IndexColorModel(java.awt.image.IndexColorModel) ByteLookupTable(java.awt.image.ByteLookupTable) LookupTable(java.awt.image.LookupTable) ShortLookupTable(java.awt.image.ShortLookupTable) ByteLookupTable(java.awt.image.ByteLookupTable) IndexColorModel(java.awt.image.IndexColorModel)

Aggregations

ByteLookupTable (java.awt.image.ByteLookupTable)6 LookupOp (java.awt.image.LookupOp)4 LookupTable (java.awt.image.LookupTable)4 AffineTransformOp (java.awt.image.AffineTransformOp)2 ConvolveOp (java.awt.image.ConvolveOp)2 ShortLookupTable (java.awt.image.ShortLookupTable)2 RadialGradientPaint (java.awt.RadialGradientPaint)1 AffineTransform (java.awt.geom.AffineTransform)1 BufferedImage (java.awt.image.BufferedImage)1 ColorModel (java.awt.image.ColorModel)1 IndexColorModel (java.awt.image.IndexColorModel)1 WritableRaster (java.awt.image.WritableRaster)1