<meta http-equiv="content-type" content="text/html; charset=utf-8"><div class="gmail_quote">On Fri, Sep 16, 2011 at 10:21 PM, Julien Finet <span dir="ltr"><<a href="mailto:julien.finet@kitware.com">julien.finet@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi David, <br><br><div><div>The following snippet should do what you need:</div><div><br><div><div> vtkImageData* cachedImage = ...;</div>
<div> int width = cachedImage->GetDimensions()[0];</div><div> int height = cachedImage->GetDimensions()[1];</div>
<div> QImage qImage(width, height, QImage::Format_RGB32);</div><div> QRgb* rgbPtr = reinterpret_cast<QRgb*>(qImage.bits());</div><div> unsigned char* colorsPtr = reinterpret_cast<unsigned char*>(cachedImage->GetScalarPointer());</div>
<div> for(int i = 0; i < width * height; ++i)</div><div> {</div><div> *(rgbPtr++) = QColor(colorsPtr[0], colorsPtr[1], colorsPtr[2]).rgb();</div><div> colorsPtr += 3;</div><div> }</div><div><br>
</div><div>Regards,</div><div>Julien.</div></div></div></div></blockquote><div><br></div><div>Thanks Julien. Here is a complete example for future readers:</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/ImageDataToQImage">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/ImageDataToQImage</a><br clear="all">
<br><div>David </div></div>