文章目录
真彩色转256 色源程序
提示:这里可以添加技术概要
核心源码
procedure TForm1.Button2Click(Sender: TObject);
var Bmp: TBitMap;
begin
Bmp := TBitMap.Create;
//Bmp.Assign(Image1.Picture.Bitmap);
Trueto256(Image1.Picture.Bitmap, bmp);
Image2.Picture.Bitmap := bmp;
Bmp.Free;
end;
unit Unit2;
interface
uses
Windows, Graphics;
type
PRGBColor = ^TRGBColor;
TRGBColor = record
B, G, R: Byte;
end;
PByte = ^Byte;
LColor = record
Color, Times: Integer;
end;
procedure Trueto256(SBitmap: TBitMap; var DBitMap: TBitMap);
implementation
var
ColorCount: array[0…4096] of LColor; //为记录颜色使用频率的数组
ColorTable: array[0…4096] of Byte; // 为记录颜色索引