arrays - 德尔福。将位图图像转换为二维数组

标签 arrays delphi bitmap 2d palette

我有一张 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/

相关文章:

delphi - 德尔福 Sprite (旋钮)

Ice Cream Sandwich 中的 java.lang.OutOfMemoryError

javascript - 消除 。并且,在 Angular 6 中数组列表中每个元素的开头/结尾

java - 更新: Reading text file into a byte array

c - 在 C 结构中初始化值

delphi - const、var、out 参数的顺序重要吗?

delphi - 无法修改EnumWindows回调中的参数

java - 在从独立相机捕获的图像上绘制文本(时间戳)

Android - 为什么使用 onSaveInsanceState() 来保存未调用的位图对象?

javascript - 根据第一个单词对对象数组进行排序