[vtkusers] Create bitmap
cspl
affable at hd2.dot.net.in
Wed Oct 23 09:16:22 EDT 2002
dear friends,
I am working on vtkWin32ImageMapper class to create hbitmap.But in that createBitmapObject function getting abort.Please give me suggestion where I am going wrong.What i need is HBITMAP for displaying on window.
I have written code as follows.
{
LPBITMAPINFO lpbi;
// Fill in the BITMAPINFOHEADER
lpbi = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER) + (256 * sizeof(RGBQUAD))];
lpbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
lpbi->bmiHeader.biWidth = 512;//size.cx;
lpbi->bmiHeader.biHeight = 512;//size.cy;
lpbi->bmiHeader.biPlanes = 1;
lpbi->bmiHeader.biBitCount = 8;
lpbi->bmiHeader.biCompression = BI_RGB;
lpbi->bmiHeader.biSizeImage = 512*512*8;//WIDTHBYTES((DWORD)size.cx * 8) * size.cy;
lpbi->bmiHeader.biXPelsPerMeter = 0;
lpbi->bmiHeader.biYPelsPerMeter = 0;
lpbi->bmiHeader.biClrUsed = 0;
lpbi->bmiHeader.biClrImportant = 0;
for(int col=0;col<256;col++)
{
//int color=rand()%255;
lpbi->bmiColors[col].rgbBlue=(BYTE)(col);
lpbi->bmiColors[col].rgbGreen=(BYTE)(col);
lpbi->bmiColors[col].rgbRed =(BYTE)(col);
lpbi->bmiColors[col].rgbReserved=0;
}
HDC hMemDC;
hMemDC = CreateCompatibleDC(dc.m_hDC);
BYTE *pBits;
HBITMAP oldbmp=NULL;
unsigned char *data;
vtkImageReader *Reader = vtkImageReader::New();
Reader->SetDataByteOrderToLittleEndian();
Reader->SetDataExtent(0,511,0,511,1,1);
Reader->SetFileName(filepath);//"g:\\1.2.840.113713.10001.1.20076558.428.1013450393.36");
Reader->SetDataSpacing(1.0, 1.0, 1.0);
Reader->SetDataMask(0x7fff);
Reader->SetDataScalarTypeToUnsignedShort();
vtkWin32ImageMapper *bb=vtkWin32ImageMapper::New();
HBITMAP hBitmap1=bb->CreateBitmapObject(oldbmp,*lpbi,dc.m_hDC,data,Reader->GetOutput(),512,512);
}
Thanking you,
regards,
Satyanarayana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021023/2074095e/attachment.htm>
More information about the vtkusers
mailing list