Hi Jonathan,

On Thu, 2005-03-24 at 16:56 -0500, Jonathan Bard wrote:
> Hello everybody,
> 
> I opened another thread because the other one was getting a little big ;)

True. ;)

> Here's the problem : it's still related to what I explained in my old posts : 
> I
> set the data of an image by hand, using getData to get the memory pointer of
> the data, and then setting this pointer to another location 
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!!

Hmm, sorry, you can't do that. Your code below is buggy, but even if you
tried to, that just doesn't work with OpenSG (or STL, for that matter).

> // loop over the kBar slices of the data
> for(int i=0;i<kBar;i++)
> {
>         // Getting the pointer of the image I want to write
>       UChar8 *dataImgSave = saveImg->getData();
>         // setting this pointer to the memory location where the data of the
> slice is stored (i*iBar*jBar*3 is equal to the position of the first pixel of
> the [i] slice : the "3" is here because the array is an array of UInt8, which
> go 3 by 3, for stocking RGB)
>       dataImgSave = &(pDataArray[i*iBar*jBar*3]);

This only changes your local pointer, but doesn't affect the image at
all. That's why the data that the image points to is still black.

> That's it. The "cout << ..." shows me that my array is filled with non-zero
> values. But the images written to the disk are black!
> Is there something wrong in this test, or in the way I set the data to the
> image?

You can initialize the 3D image by using

saveImg->set( Image::OSG_RGB_PF, iBar, jBar, kBar, 1, 1, 0, pDataArray);

If you want to change the data you will have to change the data in the
image, or copy the changed data into the image. You can't redirect the
image to use your data, that would be pretty tricky to get thread-safe,
therefore we don't support it right now.

Yours

        Dirk


-- 
-- Dirk Reiners               OpenSG Forum             [EMAIL PROTECTED] 
-- The OpenSG Open Source Scenegraph:            http://www.opensg.org
-- Announcements:   http://lists.sf.net/lists/listinfo/opensg-announce



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to