Hi Oliver,

On Tue, 2006-03-14 at 12:14 +0100, [EMAIL PROTECTED]
wrote:
> 
> Now, another thing, which does not work with Windows. I use the
> OpenSG 
> MTD Image Format and I create Data Images in a preprocessing, like
> this:
> 
> float* data = new float[width*height*rgba];
> for (int i=0; i<width*height*rgba; i++) {
>   data[i] = 1.5f; // this is just for test
> }
> 
> ImagePtr image = Image::create();
> image->set(Image::OSG_RGBA_PF, width, height, 1, 1, 1, 0, 
> reinterpret_cast<UInt8*>(data), Image::OSG_FLOAT32_IMAGEDATA);
> image->write("image.mtd");
> 
> And when I load these images in the application and I read the values 
> from the image, I don't get the same values.
> 
> ImagePtr image = Image::create();
> image->read("image.mtd");
> 
> float* _fData;
> _fData = reinterpret_cast<float*>(image->getData());
> 
> This works on Linux, but not on Windows. When I create the images on 
> Windows and run the application, I get some hex values like 06F93AB7. 
> When I use the image created on Linux, I get Null values.
> 
> Do you have an idea about this.

Not really, as I can't reproduce it. I just ran the attached example
with VS8. Worked fine, no differences.

Can you try that and see if that fails for you?

        Dirk


#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGImage.h>
#include <OpenSG/OSGImageFileHandler.h>

OSG_USING_NAMESPACE

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    int width=128;
    int height=128;
    int rgba=4;
    
float* data = new float[width*height*rgba];
for (int i=0; i<width*height*rgba; i++) {
  data[i] = osgrand(); // this is just for test
}

ImagePtr image = Image::create();
image->set(Image::OSG_RGBA_PF, width, height, 1, 1, 1, 0, 
reinterpret_cast<UInt8*>(data), Image::OSG_FLOAT32_IMAGEDATA);
image->write("image.mtd");

ImagePtr image2 = Image::create();
image2->read("image.mtd");

float* _fData;
_fData = reinterpret_cast<float*>(image2->getData());

bool ok = true;
for (int i=0; i<width*height*rgba; i++) {
if(data[i] != _fData[i])
{
	std::cout << i << ":" << data[i] << " " << _fData[i] << std::endl;
	ok = false;
}
}
if (ok) std::cout << "No differences" << std::endl;

    return 0;
}

Reply via email to