[vtkusers] Re: stretch an image to fit in a window

Renaud Isabelle renauisa at yahoo.fr
Wed May 25 18:37:02 EDT 2005



Goodwin Lawlor <goodwin.lawlor at ucd.ie> a écrit :Hi Isabelle,
 
A couple of things...
 
- you should use vtkImageViewer2... it uses vtkImageActor; or use the exact classes in the code below
What do you mean by that: do I have to choose between using vtkImageViewer2 and implementing code like I did below?
 
- you have to set the renWin to the same size as your image dimensions
Actually, I would like to do the contrary: that is to say, to set the image dimensions to the same size as my renWin. Indeed, the image that I have to display is about 1552*128 (because of different pixel size according to directions), and I would like to display it in a frame of my MFC interface.
 
- you have to set the camera's parallel scale to numRows*0.5
Ok. I forgot to multipky by numRows the scale factor. This could explain my black image. Thanks
 
Goodwin
----- Original Message ----- 
From: Renaud Isabelle 
To: Goodwin Lawlor ; vtkusers at public.kitware.com 
Sent: Wednesday, May 25, 2005 4:29 PM
Subject: Re: [vtkusers] Re: stretch an image to fit in a window


 Hi,
 
Sorry to bother you again. 
 
I tried what you indicated me to scale my image into a window I passed.
 
I have no error at compilation. However, my image is not scaled at execution. 
 
Is there any fault in this code:
 
viewer->SetInput(reader->GetOutput());
 
 vtkRenderer* ren1 = viewer->GetRenderer();
 ren1->GetActiveCamera()->ParallelProjectionOn(); 
ren1->GetActiveCamera()->SetParallelScale(0.5);
 
 //display the image in the frame
 viewer->SetParentId(this->m_hWnd);
 
 //execute
 viewer->Render(); 
 
thanks in advance, 
 
Isabelle


Goodwin Lawlor <goodwin.lawlor at ucd.ie> a écrit:
Hi Isabelle,

Have a look at this example:

http://www.bioengineering-research.com/vtk/vhpreader.tcl

or

http://www.bioengineering-research.com/vtk/BackgroundImage.tcl


here's the bit you need: (app is an image; numCol and numRow are the image
dims)

vtkImageActor ia
ia SetInput [app GetOutput]
ia InterpolateOff
vtkRenderer ren1
ren1 AddActor ia
ren1 SetBackground 1 1 1
vtkRenderWindow renWin
renWin AddRenderer ren1
renWin SetSize [expr $numCol / 4] [expr $numRow / 4]
vtkInteractorStyleImage istyle
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
iren SetInteractorStyle istyle
[ren1 GetActiveCamera] ParallelProjectionOn
#fit the image to the render window
[ren1 GetActiveCamera] SetParallelScale [expr $numRow / 2]
renWin Render


hth

Goodwin


"Renaud ! Isabelle" wrote in message
news:20050525115733.8984.qmail at web26108.mail.ukl.yahoo.com...
Hi everyone,

I made a 2D image displayed in a window by using
vtkImageViewer->SetParentId(this->m_hWnd). It works well, but my image is
still displayed with its own dimensions. What I would like to do is find a
way to display it in order to fit the dimensions of my window, something
which could stretch my image.

Could someone suggest me something? I am not sure if it is a VTK or ITK
problem.

By the way, what is the difference between vtkImageViewer and
vtkImageViewer2?

Thanks in advance,

Isabelle


Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails,
photos et vidéos !
Créez votre Yahoo! Mail



_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



---------------------------------
Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails, photos et vidéos !
Créez votre Yahoo! Mail 

		
---------------------------------
 Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos mails, photos et vidéos !
Créez votre Yahoo! Mail  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050526/86c1da1a/attachment.htm>


More information about the vtkusers mailing list