[vtkusers] Is there any one know how to generate a JPEG file manually?

Mathieu Malaterre mathieu.malaterre at kitware.com
Tue Mar 9 10:35:07 EST 2004


Qi,

Have a look at
	vtkImageShiftScale ::SetOutputScalarTypeToUnsignedChar ()
or
	vtkImageCast::SetOutputScalarTypeToUnsignedChar ()

HTH
Mathieu

Q Ma wrote:
> Hi, there,
> 
> Is there any one know how to generate a JPEG file manually?
> I have an arrary of data, grey value for each pixel,and want to output into a
> JPEG file.
> I use vtkJPEGWriter, with following code:
> 
> vtkJPEGWriter *imagewriter=vtkJPEGWriter::New();
>   imagewriter->SetFileName(imagefilename);
> vtkStructuredPoints *im = vtkStructuredPoints::New();
>   im->SetDimensions(1024,768,1);
> vtkFloatArray *scalartemp = vtkFloatArray::New();	
> im->GetPointData()->SetScalars(scalartemp);
> for(int x=0;x<1024;x++)
> 	for(int y=0;y<768;y++)
> 		scalartemp->InsertValue(y*1024+x,(char)(xy[x][y][2]/5));
> imagewriter->SetInput(im);
> imagewriter->Write();
> 
> It does not work. And an error reported like this:
> warning: In /var/tmp/BUILD-cedward1/VTK/IO/vtkJPEGWriter.cxx, line 186
> vtkJPEGWriter only supports unsigned char input
> 
> Can anyone with some help on how to output JPEG file manually?
> Thank you very much.
> 
> Regards,
> Qi
> 
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 






More information about the vtkusers mailing list