<!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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>{</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>&nbsp;LPBITMAPINFO lpbi;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;// Fill in the BITMAPINFOHEADER<BR>&nbsp;lpbi = (LPBITMAPINFO) 
new BYTE[sizeof(BITMAPINFOHEADER) + (256 * 
sizeof(RGBQUAD))];<BR>&nbsp;lpbi-&gt;bmiHeader.biSize = 
sizeof(BITMAPINFOHEADER);<BR>&nbsp;lpbi-&gt;bmiHeader.biWidth = 
512;//size.cx;<BR>&nbsp;lpbi-&gt;bmiHeader.biHeight = 
512;//size.cy;<BR>&nbsp;lpbi-&gt;bmiHeader.biPlanes = 
1;<BR>&nbsp;lpbi-&gt;bmiHeader.biBitCount = 
8;<BR>&nbsp;lpbi-&gt;bmiHeader.biCompression = 
BI_RGB;<BR>&nbsp;lpbi-&gt;bmiHeader.biSizeImage = 
512*512*8;//WIDTHBYTES((DWORD)size.cx * 8) * 
size.cy;<BR>&nbsp;lpbi-&gt;bmiHeader.biXPelsPerMeter = 
0;<BR>&nbsp;lpbi-&gt;bmiHeader.biYPelsPerMeter = 
0;<BR>&nbsp;lpbi-&gt;bmiHeader.biClrUsed = 
0;<BR>&nbsp;lpbi-&gt;bmiHeader.biClrImportant = 0;<BR>&nbsp;for(int 
col=0;col&lt;256;col++)<BR>&nbsp;{<BR>&nbsp;&nbsp;//int 
color=rand()%255;<BR>&nbsp;&nbsp;lpbi-&gt;bmiColors[col].rgbBlue=(BYTE)(col);<BR>&nbsp;&nbsp;lpbi-&gt;bmiColors[col].rgbGreen=(BYTE)(col);<BR>&nbsp;&nbsp;lpbi-&gt;bmiColors[col].rgbRed 
=(BYTE)(col);<BR>&nbsp;&nbsp;lpbi-&gt;bmiColors[col].rgbReserved=0;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;LPLOGPALETTE lpLogPal;<BR>&nbsp;lpLogPal = (LPLOGPALETTE) new 
BYTE[sizeof(LOGPALETTE) + ((255) * 
sizeof(PALETTEENTRY))];<BR>&nbsp;lpLogPal-&gt;palVersion = 
0x0300;<BR>&nbsp;lpLogPal-&gt;palNumEntries =256;<BR>&nbsp;<BR>&nbsp;for (int i 
= 0; i &lt; 256; 
i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;lpLogPal-&gt;palPalEntry[i].peRed = 
lpbi-&gt;bmiColors[i].rgbRed;<BR>&nbsp;&nbsp;lpLogPal-&gt;palPalEntry[i].peGreen 

lpbi-&gt;bmiColors[i].rgbGreen;<BR>&nbsp;&nbsp;lpLogPal-&gt;palPalEntry[i].peBlue 

lpbi-&gt;bmiColors[i].rgbBlue;<BR>&nbsp;&nbsp;lpLogPal-&gt;palPalEntry[i].peFlags 
= 0;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;HDC hMemDC;<BR>&nbsp;hMemDC = 
CreateCompatibleDC(dc.m_hDC);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;CPalette m_Palette;<BR>&nbsp;VERIFY( m_Palette.CreatePalette( 
lpLogPal ) );</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;<BR>&nbsp;HPALETTE m_hPalette=CreateHalftonePalette(hMemDC); 
<BR>&nbsp;::SelectPalette(dc.m_hDC,m_hPalette,FALSE 
);&nbsp;<BR>&nbsp;<BR>&nbsp;BYTE *pBits;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;HBITMAP oldbmp=NULL;<BR>&nbsp;unsigned char *data;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;vtkImageReader *Reader = 
vtkImageReader::New();<BR>&nbsp;Reader-&gt;SetDataByteOrderToLittleEndian();<BR>&nbsp;Reader-&gt;SetDataExtent(0,511,0,511,1,1);<BR>&nbsp;Reader-&gt;SetFileName(filepath);//"g:\\1.2.840.113713.10001.1.20076558.428.1013450393.36");<BR>&nbsp;Reader-&gt;SetDataSpacing(1.0, 
1.0, 
1.0);<BR>&nbsp;Reader-&gt;SetDataMask(0x7fff);<BR>&nbsp;Reader-&gt;SetDataScalarTypeToUnsignedShort(); 
</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;vtkWin32ImageMapper 
*bb=vtkWin32ImageMapper::New();<BR>&nbsp;HBITMAP 
&nbsp;hBitmap1=bb-&gt;CreateBitmapObject(oldbmp,*lpbi,dc.m_hDC,data,Reader-&gt;GetOutput(),512,512);<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Thanking 
you,<BR>regards,<BR>Satyanarayana<BR></FONT></DIV></BODY></HTML>