<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Please keep questions/replies on the list in case somebody else has
time to respond sooner. (Next time, keep cc'ing <a class="moz-txt-link-abbreviated" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>...)<br>
<br>
Here's a small example that builds a vtkImageData from raw r,g,b values
and shows it in a render window. It's an adaptation and reduction of
VTK/Examples/Tutorial/Step6/Cxx/Cone6.cxx. I've eliminated the cone
source/mapper/actor and added a vtkImageData and vtkImageActor.<br>
<br>
The important pieces of the puzzle are SetScalarTypeToUnsignedChar and
SetNumberOfScalarComponents(3). Then you can fill in the r,g,b values
to your liking in a loop after allocating the scalars. If you already
have a bitmap allocated and filled in, there's probably a way for you
to set that data in as the scalar data here as long as it is laid out
properly: r, g, b sequentially for each pixel as shown here. I'll let
somebody else who's done that before chime in if you need more help. :-)<br>
<br>
//====================<SampleCode>====================<br>
#include "vtkImageActor.h"<br>
#include "vtkImageData.h"<br>
#include "vtkInteractorStyleTrackballCamera.h"<br>
#include "vtkRenderer.h"<br>
#include "vtkRenderWindow.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
<br>
int main()<br>
{<br>
vtkImageData *imageData = vtkImageData::New();<br>
imageData->SetScalarTypeToUnsignedChar();<br>
imageData->SetNumberOfScalarComponents(3);<br>
imageData->SetDimensions(16, 16, 1);<br>
imageData->AllocateScalars();<br>
<br>
int i = 0;<br>
int j = 0;<br>
unsigned char r = 0;<br>
unsigned char g = 0;<br>
unsigned char b = 0;<br>
unsigned char *data = (unsigned char *)
imageData->GetScalarPointer();<br>
for (i= 0; i<16; ++i)<br>
for (j= 0; j<16; ++j)<br>
{<br>
// Checkerboard test pattern with red, green, blue and black
quadrants:<br>
if ((j+i) % 2)<br>
{<br>
r= g= b= 0;<br>
<br>
if (i>7 && j>7)<br>
{<br>
r= 255;<br>
}<br>
else if (i>7)<br>
{<br>
b= 255;<br>
}<br>
else if (j>7)<br>
{<br>
g= 255;<br>
}<br>
}<br>
else<br>
{<br>
// White on the "other" part of the checkerboard:<br>
r= g= b= 255;<br>
<br>
// Grayscale ramp:<br>
//r= g= b= 16*i + j;<br>
}<br>
<br>
*data++ = r;<br>
*data++ = g;<br>
*data++ = b;<br>
}<br>
<br>
vtkImageActor *imageActor = vtkImageActor::New();<br>
imageActor->SetInput(imageData);<br>
imageActor->InterpolateOff();<br>
<br>
vtkRenderer *ren1= vtkRenderer::New();<br>
ren1->AddActor( imageActor );<br>
ren1->SetBackground( 0.1, 0.2, 0.4 );<br>
<br>
vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
renWin->AddRenderer( ren1 );<br>
renWin->SetSize( 300, 300 );<br>
<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br>
<br>
vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();<br>
iren->SetInteractorStyle(style);<br>
<br>
iren->Initialize();<br>
iren->Start();<br>
<br>
imageActor->Delete();<br>
imageData->Delete();<br>
ren1->Delete();<br>
renWin->Delete();<br>
iren->Delete();<br>
style->Delete();<br>
<br>
return 0;<br>
}<br>
//====================</SampleCode>====================<br>
<br>
<br>
Hope this helps you get a little further,<br>
David<br>
<br>
<br>
<br>
med ali wrote:
<blockquote
cite="mid20050607153402.74432.qmail@web26407.mail.ukl.yahoo.com"
type="cite">
<div>Hi,</div>
<div> </div>
<div>thanks you,</div>
<div>but i 'am begginer in vtk </div>
<div>can you give me a short example that i can begin with .</div>
<div> </div>
<div>thanks,</div>
<div> </div>
<div>dali<br>
<br>
<b><i>David Cole <a class="moz-txt-link-rfc2396E" href="mailto:david.cole@kitware.com"><david.cole@kitware.com></a></i></b> a écrit :</div>
<blockquote class="replbq"
style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">The
output of vtkBMPReader (which is derived from vtkImageAlgorithm) is a
vtkImageData. Just construct a vtkImageData directly from your data
with the correct dimensions, scalar type and underlying data rather
than using vtkBMPReader.<br>
<br>
med ali wrote:
<blockquote
cite="mid20050607144554.60708.qmail@web26407.mail.ukl.yahoo.com"
type="cite">
<div>
<p>Hi all,</p>
<p> </p>
<p>i want use vtkBMPReader but not directly on the files </p>
<p> instead of passing the prefix of slices can i pass the array
data of pixels to vtkBMPReader</p>
<font size="2"><font size="2">
<p>/* </p>
<p>bmp= vtkBMPReader::New();</p>
</font></font>
<p><font size="2">bmp->SetFilePrefix (prefix);</font></p>
<p><font size="2">bmp->SetFileNameSliceOffset(1);</font></p>
<p><font size="2">bmp->SetFilePattern("%s%d.bmp");</font></p>
<p><font size="2">*/</font></p>
</div>
<hr size="1">
Découvrez le nouveau Yahoo! Mail : <font color="red">1 Go d'espace</font>
de stockage pour vos mails, photos et vidéos !<br>
<a
href="http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html"
target="_blank">Créez votre Yahoo! Mail</a>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a
class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext"
href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
</blockquote>
<p> </p>
<hr size="1"> Découvrez le nouveau Yahoo! Mail : <font color="red">1
Go d'espace</font> de stockage pour vos mails, photos et vidéos !<br>
<a
href="http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html"
target="_blank">Créez votre Yahoo! Mail</a> </blockquote>
</body>
</html>