Search in sources :

Example 46 with SampleModel

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

the class ImageTypeSpecifierTest method test4430993.

private static void test4430993() {
    ImageTypeSpecifier itspecifier;
    int bits = 32;
    int rmask = 0x00ff0000;
    int gmask = 0x0000ff00;
    int bmask = 0x000000ff;
    ColorModel dcm = new java.awt.image.DirectColorModel(bits, rmask, gmask, bmask);
    int[] bandOffsets = new int[2];
    bandOffsets[1] = 1;
    SampleModel sm = new java.awt.image.ComponentSampleModel(DataBuffer.TYPE_SHORT, 1, 1, 2, 2, bandOffsets);
    try {
        itspecifier = new ImageTypeSpecifier(dcm, sm);
        fail("Failed to get IAE!");
    } catch (IllegalArgumentException e) {
    }
}
Also used : SampleModel(java.awt.image.SampleModel) ColorModel(java.awt.image.ColorModel) ImageTypeSpecifier(javax.imageio.ImageTypeSpecifier)

Example 47 with SampleModel

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

the class ColCvtAlpha method main.

public static void main(String[] args) {
    BufferedImage src = new BufferedImage(1, 10, BufferedImage.TYPE_INT_ARGB);
    // Set src pixel values
    Color pelColor = new Color(100, 100, 100, 128);
    for (int i = 0; i < 10; i++) {
        src.setRGB(0, i, pelColor.getRGB());
    }
    ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] { 8, 8 }, true, src.getColorModel().isAlphaPremultiplied(), Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
    SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, 100, 100, 2, 200, new int[] { 0, 1 });
    WritableRaster wr = Raster.createWritableRaster(sm, new Point(0, 0));
    BufferedImage dst = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
    dst = dst.getSubimage(0, 0, 1, 10);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);
    for (int i = 0; i < 10; i++) {
        if (((dst.getRGB(0, i) >> 24) & 0xff) != 128) {
            throw new RuntimeException("Incorrect destination alpha value.");
        }
    }
}
Also used : PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) SampleModel(java.awt.image.SampleModel) ColorConvertOp(java.awt.image.ColorConvertOp) ComponentColorModel(java.awt.image.ComponentColorModel) ColorModel(java.awt.image.ColorModel) ComponentColorModel(java.awt.image.ComponentColorModel) WritableRaster(java.awt.image.WritableRaster) Color(java.awt.Color) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) Point(java.awt.Point)

Aggregations

SampleModel (java.awt.image.SampleModel)47 SinglePixelPackedSampleModel (java.awt.image.SinglePixelPackedSampleModel)22 ComponentSampleModel (java.awt.image.ComponentSampleModel)21 Point (java.awt.Point)20 ColorModel (java.awt.image.ColorModel)16 Rectangle (java.awt.Rectangle)15 DataBuffer (java.awt.image.DataBuffer)14 MultiPixelPackedSampleModel (java.awt.image.MultiPixelPackedSampleModel)14 IndexColorModel (java.awt.image.IndexColorModel)12 RasterFormatException (java.awt.image.RasterFormatException)9 WritableRaster (java.awt.image.WritableRaster)9 DataBufferByte (java.awt.image.DataBufferByte)8 PixelInterleavedSampleModel (java.awt.image.PixelInterleavedSampleModel)8 BufferedImage (java.awt.image.BufferedImage)7 DataBufferInt (java.awt.image.DataBufferInt)7 BandedSampleModel (java.awt.image.BandedSampleModel)6 DirectColorModel (java.awt.image.DirectColorModel)6 Raster (java.awt.image.Raster)6 ImageTypeSpecifier (javax.imageio.ImageTypeSpecifier)6 DataBufferShort (java.awt.image.DataBufferShort)5