[vtkusers] Loosing first Compontent after SafeDownCast

Martn Ulken martinulken at googlemail.com
Tue Sep 21 13:52:55 EDT 2010


Ah that explains my Problem J

 

First: Right I meant test2[0].

 

Second: Today I realized that the missing component is in test2[-1]. 

So the Offset explains why the pointer is set to a wrong place ;)

 

Thanks J

 

 

Von: Karthik Krishnan [mailto:karthik.krishnan at kitware.com] 
Gesendet: Dienstag, 21. September 2010 11:22
An: Martin Ulken
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] Loosing first Compontent after SafeDownCast

 

 

On Tue, Sep 21, 2010 at 1:43 PM, Martin Ulken <martinulken at googlemail.com>
wrote:

Hello

 

I am going to import an bmp image by using the vtkBMPReader which works
fine.

 

When I am going to access the pixels of the image using "
image2->GetScalarComponentAsFloat(x,y,0,0) " everything works fine.

When I display the first greyvalues in row y=0  I get the following:
21,36,58,63,. which is correct.

 

Now I want to have a faster access. so I create a pointer with the following
commands:

 

vtkUnsignedCharArray* test=
vtkUnsignedCharArray::SafeDownCast(image2->GetPointData()->GetScalars());

test2= test->GetPointer(VTK_UNSIGNED_CHAR);


What do you mean by test->GetPointer(VTK_UNSIGNED_CHAR) ? The value to be
passed in is simply the offset. Perhaps you meant to write
test->GetPointer(0);
 

 

Now the value of test[0] is 36. So I cannot access the first column of the
image.


You mean test2[0] ?






 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100921/ad26f6c2/attachment.htm>


More information about the vtkusers mailing list