[vtkusers] How to read and display a JPEG image

Miguel Angel Rodriguez Florido marf at itccanarias.org
Fri Oct 3 05:26:14 EDT 2008


	I haven't seen your email in detail, but perhaps, you need to add 
reader Update method to your pipeline.

	Hth.

Elvis Dowson wrote:
> Hi,
>         I'm trying to read a JPEG image and display it using vtkActor2D, 
> but I cant seem to get it to work. What am I missing out here?
> 
> #include "qapplication.h"
> #include <QtGui>
> 
> #include <vtkActor.h>
> #include <vtkActor2D.h>
> #include <vtkTextActor.h>
> #include <vtkJPEGReader.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkImageMapper.h>
> 
> int main(int argc, char** argv)
> {
> 
>   QApplication app(argc, argv);
> 
> 
> #if QT_VERSION >= 0x040000
> Ui::Dialog ui;
> QDialog dialog;
> #endif
> 
> 
> ui.setupUi(&dialog);
> dialog.setAttribute(Qt::WA_QuitOnClose);
> 
> 
> // Qt vtk integration
> vtkRenderer* ren;
> ren = vtkRenderer::New();
> ui.qvtkWidget->GetRenderWindow()->AddRenderer(ren);
> 
> // 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("sample.jpg");
> 
> 
> // Map 2D image file
> imageMapper = vtkImageMapper::New();
> imageMapper->SetInput(imageReader->GetOutput());
> imageMapper->GetInput();
> 
> 
> // Actor in scene
> mapActor = vtkActor2D::New();
> mapActor->SetMapper(imageMapper);
> 
> 
> // Add Actor to renderer
> ren->AddActor2D(mapActor);
> 
> // Reset camera
> ren->ResetCamera();
> 
> 
> // Render the scene
> ren->GetRenderWindow()->Render();
> 
> 
> // Display the dialog window
> dialog.show();
> 
>   return app.exec();
> }
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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


-- 
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/bea7a8a8/attachment.bin>


More information about the vtkusers mailing list