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;
}
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;
}
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;
}
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.");
}
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;
}
Aggregations