procedure GetImgData(pBuf:PByte);pBuf 为位图返回的数据,大小为:宽度*高度*颜色位数 div 8当 dwColor 为 16 时返回的是 555位图 ,设置为 16 或 24 以下方式显示正常。如果设置为 4 或 8 显示就不正常了。当取位4色时缓冲长度为64字节,当取8位色时缓冲长度为1024字节。请问 BtimapInfo 还需要设置哪些参数?或是用其它方法? 谢谢。
var
BitmapInfo:TBitmapInfo;
dwColor:=24; with BitmapInfo.bmiHeader do
begin
biSize := SizeOf(TBitmapInfoHeader);
biWidth := xxxxWidth;
biHeight := xxxHeight;
biPlanes := 1;
biBitCount := dwColor;
biCompression := BI_RGB;
end; SetDIBitsToDevice(Form1.Canvas.Handle,
xxxRect.Left,
xxxRect.Top,
xxxWidth,
xxxHeight,
0,
0,
0,
xxxHeight,
pBuf,
BitmapInfo,
DIB_RGB_COLORS);
var
BitmapInfo:TBitmapInfo;
dwColor:=24; with BitmapInfo.bmiHeader do
begin
biSize := SizeOf(TBitmapInfoHeader);
biWidth := xxxxWidth;
biHeight := xxxHeight;
biPlanes := 1;
biBitCount := dwColor;
biCompression := BI_RGB;
end; SetDIBitsToDevice(Form1.Canvas.Handle,
xxxRect.Left,
xxxRect.Top,
xxxWidth,
xxxHeight,
0,
0,
0,
xxxHeight,
pBuf,
BitmapInfo,
DIB_RGB_COLORS);
bmiHeader: TBitmapInfoHeader; //位图信息头,该结构用于说明位图的格式;
bmiColors: array[0..0] of TRGBQuad; //颜色表,给出调色板数据。
end;
由于 不会设置 bmiColors当 4 位 或是 8位时,可以用这个过程来获取系统调色板
procedure GetColorTable(pTable:Pointer);bmiColors 是不是可以利用 返回的 pTable ?
BitmapInfo: PBitmapInfo;
// 分配位图信息头和调色板长度,获取位图数据时,调色板会自动填充,8位为256,4位为16 GetMem(BitmapInfo, Sizeof(TBitmapInfoHeader) + Sizeof(TRGBQuad) * 256);
with BitmapInfo^.bmiHeader do
begin
biSize := SizeOf(TBitmapInfoHeader);
biWidth := xxxxWidth;
biHeight := xxxHeight;
biPlanes := 1;
biBitCount := dwColor;
biCompression := BI_RGB;
end;