//存图
bool SaveImage(LONG ImageWidth, LONG ImageHeight, CHAR* pImageData, BSTR bstrImageSavePath)
{
CImage pImage;
if(!pImage.IsNull())
pImage.Destroy();
pImage.Create(ImageWidth,ImageHeight,8);
RGBQUAD* ColorTable;
int MaxColors=256;
ColorTable=new RGBQUAD[MaxColors];
pImage.GetColorTable(0, MaxColors, ColorTable);
for(int i=0;i<MaxColors;i++)
{
ColorTable[i].rgbBlue=(BYTE)i;
ColorTable[i].rgbGreen=(BYTE)i;
ColorTable[i].rgbRed=(BYTE)i;
}
pImage.SetColorTable(0,MaxColors,ColorTable);
delete []ColorTable;
UCHAR* pImg=(UCHAR*)pImage.GetBits();
int step=pImage.GetPitch();
for(int i=0;i<ImageHeight;i++)
{
for(int j=0;j<ImageWidth;j++)
{
int iData=*pImageData++;
*(pImg+i*step+j)=iData;
}
}
CString strSavePath((LPCTSTR)bstrImageSavePath);
pImage.Save(strSavePath);
return true;
}
根据char* 图像数据指针存储图像
最新推荐文章于 2022-10-16 15:44:56 发布