private BufferedImage createIndexImage(int bpp) {
// calculate palette size
int psize = (1 << bpp);
// prepare palette;
byte[] r = new byte[psize];
byte[] g = new byte[psize];
byte[] b = new byte[psize];
for (int i = 0; i < colors.length; i++) {
r[i] = (byte)(0xff & colors[i].getRed());
g[i] = (byte)(0xff & colors[i].getGreen());
b[i] = (byte)(0xff & colors[i].getBlue());
}
// now prepare appropriate index clor model
IndexColorModel icm = new IndexColorModel(bpp, psize, r, g, b);
return new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
}
BMPSubsamplingTest.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:jdk8u-jdk
作者:
评论列表
文章目录