<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4417.0">
<TITLE>vtkImageData from pixel data</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Hello vtkUsers,</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">We are trying to obtain the vtkImageData from the byte* (24bit pixel data).&nbsp; When we create a bmp file we get crash in writing a BMPFile in the method&nbsp; &quot;</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">void</FONT><FONT SIZE=2 FACE="Courier New"> vtkBMPWriter::WriteFile(ofstream *file, vtkImageData *data,</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">int</FONT><FONT SIZE=2 FACE="Courier New"> extent[6]) &quot;</FONT> </P>
<BR>

<P><FONT SIZE=2 FACE="Arial">kindly tell us what is wrong with this code,&nbsp; And we want to know what are the header parameters to be set for the vtkImageData.</FONT></P>
<BR>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">void</FONT><FONT SIZE=2 FACE="Courier New"> CMainFrame::ImageData(byte* src)</FONT>

<BR><FONT SIZE=2 FACE="Courier New">{</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">vtkImageData *outData = vtkImageData::New();</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">byte arry[320*240*3];</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">memcpy(arry,src,320*240*3);</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">vtkImageImport *import = vtkImageImport::New();</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">import-&gt;SetDataExtent(0,319,0,239,0,0);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">import-&gt;SetWholeExtent(0,319,0,239,0,0);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">import-&gt;SetDataScalarType(VTK_UNSIGNED_CHAR);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">import-&gt;SetImportVoidPointer((</FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">void</FONT><FONT SIZE=2 FACE="Courier New">*)src);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">import-&gt;UpdateWholeExtent();</FONT>
</P>
<BR>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">outData = import-&gt;GetOutput();</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">outData-&gt;SetNumberOfScalarComponents( 1 );</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">int</FONT><FONT SIZE=2 FACE="Courier New"> iNo = outData-&gt;GetNumberOfScalarComponents();</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">WriteBMP(outData);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">return</FONT><FONT SIZE=2 FACE="Courier New">;</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">}</FONT>
</P>
<BR>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">void</FONT><FONT SIZE=2 FACE="Courier New"> Definitions::WriteBMP(vtkImageData *source)</FONT>

<BR><FONT SIZE=2 FACE="Courier New">{</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">vtkBMPWriter write =vtkBMPWriter::New();</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=2 FACE="Courier New"> write-&gt;SetFilePrefix(&quot;C:/tested/tested&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; write-&gt;SetFilePattern(&quot;%s%d.bmp&quot;);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=2 FACE="Courier New"> write-&gt;SetInput(source);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=2 FACE="Courier New"> write-&gt;Write();</FONT>

<BR><FONT SIZE=2 FACE="Courier New">}</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">regards</FONT>

<BR><FONT SIZE=2 FACE="Courier New">SoftUsers</FONT>
</P>

<DIV>
<HR>  , <B></B> - .
<BR> <B></B>  <A HREF="http://www.burrotech.com/officemail"></A>.
</DIV></BODY>
</HTML>