<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>dear friends,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>{</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR> LPBITMAPINFO lpbi;</DIV>
<DIV> </DIV>
<DIV><BR> // Fill in the BITMAPINFOHEADER<BR> lpbi = (LPBITMAPINFO)
new BYTE[sizeof(BITMAPINFOHEADER) + (256 *
sizeof(RGBQUAD))];<BR> lpbi->bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);<BR> lpbi->bmiHeader.biWidth =
512;//size.cx;<BR> lpbi->bmiHeader.biHeight =
512;//size.cy;<BR> lpbi->bmiHeader.biPlanes =
1;<BR> lpbi->bmiHeader.biBitCount =
8;<BR> lpbi->bmiHeader.biCompression =
BI_RGB;<BR> lpbi->bmiHeader.biSizeImage =
512*512*8;//WIDTHBYTES((DWORD)size.cx * 8) *
size.cy;<BR> lpbi->bmiHeader.biXPelsPerMeter =
0;<BR> lpbi->bmiHeader.biYPelsPerMeter =
0;<BR> lpbi->bmiHeader.biClrUsed =
0;<BR> lpbi->bmiHeader.biClrImportant = 0;<BR> for(int
col=0;col<256;col++)<BR> {<BR> //int
color=rand()%255;<BR> lpbi->bmiColors[col].rgbBlue=(BYTE)(col);<BR> lpbi->bmiColors[col].rgbGreen=(BYTE)(col);<BR> lpbi->bmiColors[col].rgbRed
=(BYTE)(col);<BR> lpbi->bmiColors[col].rgbReserved=0;</DIV>
<DIV> </DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV> LPLOGPALETTE lpLogPal;<BR> lpLogPal = (LPLOGPALETTE) new
BYTE[sizeof(LOGPALETTE) + ((255) *
sizeof(PALETTEENTRY))];<BR> lpLogPal->palVersion =
0x0300;<BR> lpLogPal->palNumEntries =256;<BR> <BR> for (int i
= 0; i < 256;
i++)<BR> {<BR> lpLogPal->palPalEntry[i].peRed =
lpbi->bmiColors[i].rgbRed;<BR> lpLogPal->palPalEntry[i].peGreen
=
lpbi->bmiColors[i].rgbGreen;<BR> lpLogPal->palPalEntry[i].peBlue
=
lpbi->bmiColors[i].rgbBlue;<BR> lpLogPal->palPalEntry[i].peFlags
= 0;<BR> }<BR> <BR> HDC hMemDC;<BR> hMemDC =
CreateCompatibleDC(dc.m_hDC);</DIV>
<DIV> </DIV>
<DIV> CPalette m_Palette;<BR> VERIFY( m_Palette.CreatePalette(
lpLogPal ) );</DIV>
<DIV> </DIV>
<DIV> <BR> HPALETTE m_hPalette=CreateHalftonePalette(hMemDC);
<BR> ::SelectPalette(dc.m_hDC,m_hPalette,FALSE
); <BR> <BR> BYTE *pBits;</DIV>
<DIV> </DIV>
<DIV> HBITMAP oldbmp=NULL;<BR> unsigned char *data;</DIV>
<DIV> </DIV>
<DIV> vtkImageReader *Reader =
vtkImageReader::New();<BR> Reader->SetDataByteOrderToLittleEndian();<BR> Reader->SetDataExtent(0,511,0,511,1,1);<BR> Reader->SetFileName(filepath);//"g:\\1.2.840.113713.10001.1.20076558.428.1013450393.36");<BR> Reader->SetDataSpacing(1.0,
1.0,
1.0);<BR> Reader->SetDataMask(0x7fff);<BR> Reader->SetDataScalarTypeToUnsignedShort();
</DIV>
<DIV> </DIV>
<DIV><BR> vtkWin32ImageMapper
*bb=vtkWin32ImageMapper::New();<BR> HBITMAP
hBitmap1=bb->CreateBitmapObject(oldbmp,*lpbi,dc.m_hDC,data,Reader->GetOutput(),512,512);<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>Thanking
you,<BR>regards,<BR>Satyanarayana<BR></FONT></DIV></BODY></HTML>