[vtkusers] How to read and display a JPEG image
Dave Partyka
dave.partyka at kitware.com
Fri Oct 3 10:44:11 EDT 2008
There is a newer class called vtkTexturedActor2D. To use this class you
would take the output from your reader and place it in a vtkTexture. Then
you would set the texture on vtkTexturedActor2D.
http://www.vtk.org/doc/nightly/html/classvtkTexturedActor2D.html
On Fri, Oct 3, 2008 at 6:15 AM, Miguel Angel Rodriguez Florido <
marf at itccanarias.org> wrote:
> 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.
>
>
>
>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081003/297c092c/attachment.htm>
More information about the vtkusers
mailing list