var
i: Integer;
bmpinfo: PBitmapInfo;
bmp: TBitmap;
Bits: Pointer;
begin
bmp := TBitmap.Create;
getmem(bmpinfo, sizeof(TBitmapInfoHeader) + //BitmapInfoHeader大小
sizeof(TRGBQuad)*256 + //颜色表大小
length(你的裸数据)
);
with bmpinfo^ do
begin
with bmiHeader do
begin
biSize := sizeof(TBitmapInfoHeader);
biWidth := 256;
biHeight := 256;
biPlanes := 1;
biBitCount := 8;
biCompression := BI_RLE8;
biSizeImage := length(你的裸数据);
biXPelsPerMeter := 97 * 254;
biYPelsPerMeter := 97 * 254;
biClrUsed := 0;
biClrImportant := 0;
end;
for i := 0 to 255 do // 设置256灰度的颜色表
begin
bmiColors.rgbBlue := xxxx;
bmiColors.rgbGreen := ...;
bmiColors.rgbRed := ...;
bmiColors.rgbReserved := 0;
end;
end;
bmp.handle := createdibsection(bmp.canvas.handle, bmpinfo, DIB_PAL_COLORS, bits, nil, 0);
move(你的裸数据的起始位置, bits^, length(你的裸数据)); // 将你的数据转入Tbitmap中.
end;
没试过.