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