用VC编写dcmtk出的问题
我的程序编译通过了,但是位图显示不出来,后来一步步执行时发现,位图的高和宽都是0,很想不同到底是什么地方的问题?请教大侠们,贴出部分程序,在线等
DicomImage *image = new DicomImage("CT0010002.dcm");
nbits = image->createWindowsDIB(pDicomDibits, 0, 0, 8, 1, 1);
// image->writeBMP("CT0010002.bmp");
CDC *pDC=GetDC();
BITMAPFILEHEADER bmfh;
bmfh.bfType=0x4D42;
bmfh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(1024)+nbits;
bmfh.bfReserved1=0;
bmfh.bfReserved2=0;
bmfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(1024);
BITMAPINFOHEADER bmih;
memset(&bmih,0,sizeof(BITMAPINFOHEADER));
bmih.biBitCount=8;
bmih.biClrImportant=0;
bmih.biClrUsed=0;
bmih.biCompression=BI_RGB;
bmih.biPlanes=1;
bmih.biHeight=image->getHeight();
bmih.biWidth=image->getWidth();
bmih.biXPelsPerMeter=0;
bmih.biYPelsPerMeter=0;
bmih.biSize=sizeof(BITMAPINFOHEADER);
bmih.biSizeImage=nbits;
RGBQUAD pColorTable[256];
for(int i=0;i<256;i++)
{
pColorTable[i].rgbBlue=i;
pColorTable[i].rgbGreen=i;
pColorTable[i].rgbRed=i;
pColorTable[i].rgbReserved=0;
}
char p[sizeof(BITMAPINFOHEADER)+256*4];
memcpy(p,&bmih,sizeof(BITMAPINFOHEADER));
memcpy(p+sizeof(BITMAPINFOHEADER),pColorTable,1024);
int colorTableLng;
colorTableLng=256;
if (colorTableLng!=0)
{
LOGPALETTE *pLogPal;
pLogPal = (LOGPALETTE*)new char[2*sizeof(WORD)+colorTableLng * sizeof(PALETTEENTRY)];
pLogPal->palVersion = 0x300;
pLogPal->palNumEntries =colorTableLng;
for(int i = 0; i < colorTableLng; i++)
{
pLogPal->palPalEntry[i].peRed= pColorTable[i].rgbRed;
pLogPal->palPalEntry[i].peGreen =pColorTable[i].rgbGreen;
pLogPal->palPalEntry[i].peBlue = pColorTable[i].rgbBlue;
pLogPal->palPalEntry[i].peFlags = 0;
}
CPalette Palette;
Palette.CreatePalette(pLogPal);
CPalette *pOldPalette;
pOldPalette=pDC->SelectPalette(&Palette,FALSE);
pDC->RealizePalette();
pDC->SelectPalette(pOldPalette,FALSE);
delete[] pLogPal;
}
::StretchDIBits(pDC->GetSafeHdc(),0,0,bmih.biWidth, bmih.biHeight, //为什么这两项都是0????
0, 0, bmih.biWidth, bmih.biHeight,
pDicomDibits, //位图数据
(BITMAPINFO*)p, //位图信息
DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(pDC);
------解决方案--------------------
位图没有加载成功???