Search in sources :

Example 6 with IndexColorModel

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

the class RLECompressionTest method getTestImage.

private BufferedImage getTestImage(int type) {
    BufferedImage src = null;
    IndexColorModel icm = getTestColorModel(type);
    src = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
    Graphics2D g = src.createGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, w, h);
    g.dispose();
    return src;
}
Also used : BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel) Graphics2D(java.awt.Graphics2D)

Example 7 with IndexColorModel

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

the class RLECompressionTest method getTestColorModel.

private IndexColorModel getTestColorModel(int type) {
    IndexColorModel icm = null;
    int bpp = 8;
    int size = 256;
    switch(type) {
        case TEST_RLE8:
            bpp = 8;
            size = 256;
            break;
        case TEST_RLE4:
            bpp = 4;
            size = 16;
            break;
        default:
            throw new IllegalArgumentException("Wrong test type: " + type);
    }
    byte[] palette = new byte[size * 3];
    for (int i = 0; i < usedColors.length; i++) {
        palette[3 * i] = (byte) (0xff & usedColors[i].getRed());
        palette[3 * i + 1] = (byte) (0xff & usedColors[i].getGreen());
        palette[3 * i + 2] = (byte) (0xff & usedColors[i].getBlue());
    }
    // rest of palette is black
    icm = new IndexColorModel(bpp, size, palette, 0, false);
    return icm;
}
Also used : IndexColorModel(java.awt.image.IndexColorModel)

Example 8 with IndexColorModel

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

the class OddPaletteTest method createTestImage.

private static BufferedImage createTestImage(int paletteSize) {
    byte[] r = new byte[paletteSize];
    byte[] g = new byte[paletteSize];
    byte[] b = new byte[paletteSize];
    int shift = 256 / paletteSize;
    for (int i = 0; i < paletteSize; i++) {
        r[i] = g[i] = b[i] = (byte) (shift * i);
    }
    int numBits = getNumBits(paletteSize);
    System.out.println("num of bits " + numBits);
    IndexColorModel icm = new IndexColorModel(numBits, paletteSize, r, g, b);
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(Color.white);
    g2d.fillRect(0, 0, w, h);
    g2d.setColor(Color.black);
    g2d.drawLine(0, 0, w, h);
    g2d.drawLine(0, h, w, 0);
    return img;
}
Also used : BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel) Graphics2D(java.awt.Graphics2D)

Example 9 with IndexColorModel

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

the class TransparencyTest method main.

public static void main(String[] args) {
    System.out.println("Test indexed image...");
    IndexColorModel icm = createIndexedBitmaskColorModel();
    BufferedImage img = createIndexedImage(200, 200, icm);
    TransparencyTest t = new TransparencyTest(img);
    try {
        t.doTest();
    } catch (Exception e) {
        throw new RuntimeException("Test failed!", e);
    }
    System.out.println("Test passed.");
}
Also used : BufferedImage(java.awt.image.BufferedImage) IOException(java.io.IOException) IndexColorModel(java.awt.image.IndexColorModel)

Example 10 with IndexColorModel

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

the class DrawBitmaskToSurfaceTest method createTestImage.

private static Image createTestImage() {
    byte[] r = new byte[] { (byte) 0x00, (byte) 0x80, (byte) 0xff, (byte) 0xff };
    byte[] g = new byte[] { (byte) 0x00, (byte) 0x80, (byte) 0xff, (byte) 0x00 };
    byte[] b = new byte[] { (byte) 0x00, (byte) 0x80, (byte) 0xff, (byte) 0x00 };
    IndexColorModel icm = new IndexColorModel(2, 4, r, g, b, 3);
    BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_INDEXED, icm);
    return img;
}
Also used : BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel)

Aggregations

IndexColorModel (java.awt.image.IndexColorModel)57 ColorModel (java.awt.image.ColorModel)24 BufferedImage (java.awt.image.BufferedImage)19 DirectColorModel (java.awt.image.DirectColorModel)11 SampleModel (java.awt.image.SampleModel)10 Point (java.awt.Point)8 WritableRaster (java.awt.image.WritableRaster)8 Rectangle (java.awt.Rectangle)7 MultiPixelPackedSampleModel (java.awt.image.MultiPixelPackedSampleModel)7 Raster (java.awt.image.Raster)7 ComponentSampleModel (java.awt.image.ComponentSampleModel)6 ColorSpace (java.awt.color.ColorSpace)5 ComponentColorModel (java.awt.image.ComponentColorModel)5 SinglePixelPackedSampleModel (java.awt.image.SinglePixelPackedSampleModel)5 Graphics (java.awt.Graphics)4 Graphics2D (java.awt.Graphics2D)4 ICC_ColorSpace (java.awt.color.ICC_ColorSpace)4 RenderedImage (java.awt.image.RenderedImage)4 ByteComponentRaster (sun.awt.image.ByteComponentRaster)4 DataBufferByte (java.awt.image.DataBufferByte)3