[vtkusers] Need to resize a QImage....

David Gobbi david.gobbi at gmail.com
Fri Jun 15 17:28:51 EDT 2012


Hi Sebastien,

I noticed one mistake: before you call SetMagnificationFactors(), you
should call this:

image_resize->SetResizeMethodToMagnificationFactors();

As for the scalar type problem, I don't know why that would be
happening.  I use vtkImageResize with various input data types and
haven't seen that problem before.

To be on the safe side, you should use the new way of connecting an
input to the ImageActor:

actor->GetMapper()->SetInputConnection(image_resize->GetOutputPort());

 - David


On Fri, Jun 15, 2012 at 3:09 PM, Sebastien Calvi
<sebastien.calvi at yahoo.com> wrote:
> Hello All,
>
> I have to display an image that create myself, it's a QImage.
> I use vtkQImageToImageSource to convert it into a vtkImageData and it works
> fine.
>
> Here is a chunk of my code:
>
>
> void updateActor( vtkImageActor * actor, double magnifyFactor[3] )
> {
>     vtkImageResize * image_resize = vtkImageResize::New();
>     image_resize->SetMagnificationFactors( magnifyFactor );
>
>     actor->SetOrigin( const_cast<double*>( VTK_ORIGIN ) );
>     actor->SetOrientation( _orientation );
>     actor->SetPosition( _position );
>
>     vtkQImageToImageSource * qimage_to_image_source =
> vtkQImageToImageSource::New();
>     qimage_to_image_source->SetQImage( _image );
>
>     image_resize->SetInputConnection(
> qimage_to_image_source->GetOutputPort() );
>
>     actor->SetInput( image_resize->GetOutput() );
>
>     qimage_to_image_source->Delete();
>     image_resize->Delete();
> }
>
> My problem is that when I run my app I get the following error message:
> ERROR: In /opt/VTK/Imaging/vtkImageResize.cxx, line 910
> vtkImageResize (0x28cb430): ThreadedRequestData: output scalar type does not
> match input scalar type
>
> and effectively when I debug I found out at the corresponding line of code
> that my input scalar type is unsigned char and the output scalar type is
> double...
>
> The unsigned char is handled/created by the vtkQImageToImageSource, no way
> to change that!
>
> Is there a different way to handle this issue? I'm assuming that yes, I jsut
> would like to know how, please?
>
> Thank you by advance,
> Sebastien.



More information about the vtkusers mailing list