我有一张 80x40 像素的 gif 图像。该图像的调色板由几种相似的颜色组成,但调色板中的数字不同。如何构建一个二维数组,其中 x,y
处的单元格将是调色板中的颜色数字?
最佳答案
TGifImage内置了这样一个数组,所以只需使用它:
var
Gif:TGifImage;
PaletteIndex : byte;
begin
Gif := TGifImage.Create;
// ... load your stuff here ...
// TGifImage has an Images property, which is probably only interesting if you're dealing with animations, so just take the first image.
PaletteIndex := Gif.Images[0].Pixels[0,0]; // palette index for top-left pixel
// Now, to get the actual TColor for that pixel, you could do this:
Self.color := Gif.Images[0].ColorMap.Colors[PaletteIndex];
end;
关于arrays - 德尔福。将位图图像转换为二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17508319/