0

我平均几百张图像,四舍五入的错误使它变成灰色的混乱。如果我可以使用每个通道具有 >8 位的 BufferedImages,我敢打赌四舍五入不会对我造成太大伤害。

有没有办法在高位深度图像的基础图像上使用 BufferedImage 代码?我的意思是>16m 颜色,>24bit,我相信这被称为“Deep Color”

4

1 回答 1

1

是的,它确实。:-)

虽然没有BufferedImage.TYPE_*深色,所以你必须以比“通常”更详细的方式创建它。此外,由于生成的类型TYPE_CUSTOM可能会显着降低绘制和显示的速度。但是,如果您仅将其用作临时“工作”图像,则这可能不是主要问题。

一个例子:

private BufferedImage create48BitRGBImage(int width, int height) {
    int precision = 16; // You could in theory use less than the full 16 bits/component (ie. 12 bits/component)
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel colorModel = new ComponentColorModel(colorSpace, new int[] {precision, precision, precision}, false, false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
    return new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(width, height), colorModel.isAlphaPremultiplied(), null);
}

如果您想要 64 位 ARGB,请更改colorModel如下:

new ComponentColorModel(colorSpace, new int[] {precision, precision, precision, precision}, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_USHORT);
于 2018-11-02T15:06:10.850 回答