[vtkusers] create bitmap
cspl
affable at hd2.dot.net.in
Mon Oct 21 10:03:26 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.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;
}
LPLOGPALETTE lpLogPal;
lpLogPal = (LPLOGPALETTE) new BYTE[sizeof(LOGPALETTE) + ((255) * sizeof(PALETTEENTRY))];
lpLogPal->palVersion = 0x0300;
lpLogPal->palNumEntries =256;
for (int i = 0; i < 256; i++)
{
lpLogPal->palPalEntry[i].peRed = lpbi->bmiColors[i].rgbRed;
lpLogPal->palPalEntry[i].peGreen = lpbi->bmiColors[i].rgbGreen;
lpLogPal->palPalEntry[i].peBlue = lpbi->bmiColors[i].rgbBlue;
lpLogPal->palPalEntry[i].peFlags = 0;
}
HDC hMemDC;
hMemDC = CreateCompatibleDC(dc.m_hDC);
CPalette m_Palette;
VERIFY( m_Palette.CreatePalette( lpLogPal ) );
HPALETTE m_hPalette=CreateHalftonePalette(hMemDC);
::SelectPalette(dc.m_hDC,m_hPalette,FALSE );
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/20021021/9899586c/attachment.htm>
More information about the vtkusers
mailing list