[vtkusers] How to read and display a JPEG image

Miguel Angel Rodriguez Florido marf at itccanarias.org
Fri Oct 3 06:15:25 EDT 2008


	Please, look at:

http://www.vtk.org/doc/nightly/html/classvtkActor2D.html

Elvis Dowson wrote:
> Sorry,
>              I made it work using vtkImageActor but it doesn't work with 
> vtkActor2D.
> 
> Here is the code that works using vtkImageActor (This displays the image 
> in 3D, but I want to use vtkActor2D but that doesnt seem to work)
> 
> *Working code*
> 
> // Declare object instance variables
> vtkJPEGReader* imageReader;
> vtkImageMapper* imageMapper;
> vtkImageActor* mapActor;
> 
> 
> // Initialize objects
> imageReader = NULL;
> imageMapper = NULL;
> mapActor = NULL;
> 
> 
> // Read 2D image file
> imageReader = vtkJPEGReader::New();
> imageReader->SetFileName("/Users/elvis/Image/sample.jpg");
> imageReader->Update();
> 
> 
> // Map 2D image file
> imageMapper = vtkImageMapper::New();
> imageMapper->SetInput(imageReader->GetOutput());
> 
> 
> // Actor in scene
> mapActor = vtkImageActor::New();
> mapActor->SetInput(imageMapper->GetInput());
> 
> 
> // Add Actor to renderer
> ren->AddActor(mapActor);
> 
> *Code that doesn't display the image*
> 
> Here is the attempt at using vtkActor2D but it doesnt work. Could some 
> one please tell me how I can get this to work?
> 
> 
> // Declare object instance variables
> vtkJPEGReader* imageReader;
> vtkImageMapper* imageMapper;
> vtkActor2D* mapActor;
> 
> 
> // Initialize objects
> imageReader = NULL;
> imageMapper = NULL;
> mapActor = NULL;
> 
> // Read 2D image file
> imageReader = vtkJPEGReader::New();
> imageReader->SetFileName("/Users/elvis/Image/sample.jpg");
> imageReader->Update();
> 
> // Map 2D image file
> imageMapper = vtkImageMapper::New();
> imageMapper->SetInput(imageReader->GetOutput());
> 
> // Actor in scene
> mapActor = vtkActor2D::New();
> mapActor->SetMapper(imageMapper);
> 
> // Add Actor to renderer
> ren->AddActor(mapActor);
> 
> 
> Best regards,
> 
> Elvis Dowson
> 
> On Oct 3, 2008, at 1:43 PM, Elvis Dowson wrote:
> 
>> Hi,
>>        I found out the reason why, I had to explicitly specify the 
>> full path to the image file name and it worked.
>>
>> imageReader->SetFileName("/Users/elvis/Image/sample.jpg");
>> imageReader->Update();
>>
>> Best regards,
>>
>> Elvis Dowson
>>
>>
> 



-- 
Miguel Angel Rodríguez Florido
Departamento de Ingeniería del Software
División de Investigación y Desarrollo Tecnológico
INSTITUTO TECNOLOGICO DE CANARIAS, S.A. - GOBIERNO DE CANARIAS
URL: www.itccanarias.org Tlfno: +34 928 727548, Fax: +34 928 727517

--------------------------------------------------------------------------
AVISO LEGAL:
Este mensaje y los ficheros adjuntos si los hubiere, se dirigen 
exclusivamente a su destinatario y puede contener información 
privilegiada o confidencial. La transmisión errónea del presente mensaje 
en ningún momento supone renuncia a su confidencialidad. Si no es vd. el 
destinatario indicado, queda notificado de que la utilización, 
divulgación y/o copia sin autorización está prohibida en virtud de la 
legislación vigente. Si ha recibido este mensaje por error, le rogamos 
que nos lo comunique inmediatamente por esta misma vía y proceda a su 
destrucción.

LEGAL WARNING:
This message and the files attached if there were any, are intended 
exclusively for its addressee and may contain information that is 
CONFIDENTIAL and protected by professional privilege. A wrong 
transmission to this message don't suppose we relinquished to It's 
confidential. If you are not the intended recipient you are hereby 
notified that any dissemination, copy or disclosure of this 
communication is strictly prohibited by law. If this message has been 
received in error, please immediately notify us via e-mail and delete it.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3262 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081003/28f501b5/attachment.bin>


More information about the vtkusers mailing list