关于颜色表

wealsh 2011-10-20 01:16:55
已获取 颜色表 的数据为 cBuf (cBuf:Tbyte),是8位色,长度为 1024 字节

var
BitmapInfo:TBitmapInfo;


BitmapInfo.bmiHeader.biSize :=sizeof(BITMAPINFOHEADER);
BitmapInfo.bmiHeader.biCompression := BI_RGB;
BitmapInfo.bmiHeader.biClrImportant := 0;
BitmapInfo.bmiHeader.biPlanes := 1;
// BitmapInfo.bmiHeader.biClrUsed := 0;
BitmapInfo.bmiHeader.biSizeImage := nWidth * nHeight * 8 div 8;
BitmapInfo.bmiHeader.biWidth := nWidth;
BitmapInfo.bmiHeader.biHeight := -nHeight;
BitmapInfo.bmiHeader.biBitCount := 8;

BitmapInfo.bmiColors //如何把上面的颜色表数据 cBuf 应用在这里?谢谢。


注:颜色表数据 cBuf 是由一个 dll 调用获取的,现在主要是把图像显示出来。
...全文
125 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
李_军 2011-10-20
  • 打赏
  • 举报
回复
搞定还不结贴
wealsh 2011-10-20
  • 打赏
  • 举报
回复
case dwColor of
1:cNum=1;
4:cNum=15;
8:cNum=255;
end;
for i := 0 tO cNum dO
begin
with BitmapInfo.bmiColors[i] do
begin
rgbRed:= RGBQuad.rgbRed;
rgbGreen:= RGBQuad.rgbGreen;
rgbBlue:= RGBQuad.rgbBlue;
rgbReserved:= 0;
end;
INC(RGBQuad);
end;

已搞定。
李_军 2011-10-20
  • 打赏
  • 举报
回复
关键是颜色表后面的你那些rgb数据
类似于C的
//by lpData, and the destination image is pointed by m_pTransfered.
LPBITMAPINFOHEADER lpBitmapInfoHeader = (LPBITMAPINFOHEADER)(m_pBitmap+14);
LPBITMAPFILEHEADER lpBitmapFileHeader = (LPBITMAPFILEHEADER)m_pBitmap;
unsigned char *lpData = m_pBitmap + lpBitmapFileHeader->bfOffBits;
unsigned long biHeight = lpBitmapInfoHeader->biHeight;
unsigned long biWidth = lpBitmapInfoHeader->biWidth;
unsigned long biAlign = ( biWidth*3+3) /4 *4;
unsigned long bmSize = biHeight * biAlign;
if (m_pTransfered == NULL)
m_pTransfered = (unsigned char*)malloc(bmSize);
if (m_pTransfered == NULL)
return ;

//Add the processing code here, which reverses the color of each pixel.
int x, y, cur;
for (y = 0; y < (int)biHeight; y++)
{
for (x = 0; x < (int)biWidth; x++)
{
cur = y*biAlign+3*x; //current pixel
m_pTransfered[cur] = 255-lpData[cur]; //on B
m_pTransfered[cur+1] = 255-lpData[cur+1]; //on G
m_pTransfered[cur+2] = 255-lpData[cur+2]; //on R
}
}
就是这里面lpData,你要获取到才能显示出来

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧