Java 调色板高于255

Java 调色板高于255,java,colors,palette,Java,Colors,Palette,对于我的项目,我能够在对象上打印纹理。一旦我使用更好的纹理,使用高于256的调色板,它就会变成黑色或不可见 有人能帮我解决这个问题吗?现在,这是我将.png转换为可用纹理的代码: public static Background getIndexedImage(int id, File file) throws IOException { BufferedImage image = ImageIO.read(file); List<Integer> palette

对于我的项目,我能够在对象上打印纹理。一旦我使用更好的纹理,使用高于256的调色板,它就会变成黑色或不可见

有人能帮我解决这个问题吗?现在,这是我将
.png
转换为可用纹理的代码:

public static Background getIndexedImage(int id, File file) throws IOException {

    BufferedImage image = ImageIO.read(file);

    List<Integer> paletteList = new LinkedList<>();
    paletteList.add(0);
    int width = image.getWidth();
    int height = image.getHeight();
    byte[] pixels = new byte[width * height];
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int rgb = image.getRGB(x, y);
            int red = rgb >> 16 & 0xff;
            int green = rgb >> 8 & 0xff;
            int blue = rgb & 0xff;
            int alpha = rgb & 0xff;
            rgb = red << 16 | green << 8 | blue;
            if (alpha == 255) {
                rgb = 0;
            }
            int index = paletteList.indexOf(rgb);
            if (index == -1) {

                if (paletteList.size() < 256) {
                    index = paletteList.size();
                    paletteList.add(rgb);
                } else {
                    throw new IllegalArgumentException("The target image has more than 255 color in the palette "+id);
                }
            }
            pixels[x + y * width] = (byte) index;
        }
    }
    int[] palette = new int[paletteList.size()];

    final AtomicInteger index = new AtomicInteger(0);


    for (int pallet = 0; pallet < paletteList.size(); pallet++) {
        palette[index.getAndIncrement()] = paletteList.get(pallet);
    }
    return new Background(width, height, palette, pixels);
}
publicstaticbackgroundgetIndexedImage(int-id,File-File)抛出IOException{
BuffereImage image=ImageIO.read(文件);
列表选项板列表=新建链接列表();
选项板列表。添加(0);
int width=image.getWidth();
int height=image.getHeight();
字节[]像素=新字节[宽度*高度];
对于(int x=0;x>16&0xff;
int绿色=rgb>>8&0xff;
蓝色整数=rgb&0xff;
int alpha=rgb&0xff;

rgb=红色“高于256”您正在使用256个“位置”对于32位像素格式,四次或四组8位。为什么要大于255的值?
255255
==全白和
0,0,0255
==全黑。要处理更详细的纹理,我不理解你的问题。你能详细描述一下你想解决的问题吗?你可以在内部使用任何约定。事实上,许多处理照片的程序使用浮动或每通道16位的颜色(作为工作颜色空间)。最后,你必须转换回用户可以看到的颜色(不是很多人的屏幕可以每通道10位[他们有问题:许多程序不懂这种颜色,但专业的照片/图形/等程序。).