+ -
当前位置:首页 → 问答吧 → 关于颜色表

关于颜色表

时间:2011-10-20

来源:互联网

已获取 颜色表 的数据为 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 调用获取的,现在主要是把图像显示出来。

作者: wealsh   发布时间: 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,你要获取到才能显示出来

作者: ljmanage   发布时间: 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;

已搞定。

作者: wealsh   发布时间: 2011-10-20