Jump to content

How to save an IMG_File


Recommended Posts

Hi,

 

i'm trying to save an image or rather a PXL_Raster to a file but there will be no genereted file.

IMG_File *tex = IMG_File::open("D:/test.png");
					
UT_PtrArray<PXL_Raster *> images; 
tex->readImages(images);
// First try
if (IMG_File::saveRasterAsFile("D:/new.png", images[0]))
    cout << "Success!" << endl; // is not called
// Second try
if (tex->writeImages(images))
    cout << "Success!" << endl; // is also not called
tex->close();
delete tex;

What i'm doing wrong?

Has someone a tip for me?

 

Thanks!

Link to comment
Share on other sites

Have you checked to see if images has any entries? The [] brackets will create entry zero for you (as NULL), so it's better to use images(0) when you're doing a read access to the array.

 

Also, make sure you have write access to D:/. Finally, if nothing else works, try writing a .pic file to see if it's a png-specific issue.

 

The second attempt will definitely not work because tex is a IMG_File handle opened for read.

Link to comment
Share on other sites

Thanks for the images(0) tip. I will do that.

 

I have figured out that the problem was caused by the non-commercial version of Houdini. The IMG_File::saveRasterAsFile() method accepts only 768x576 px images in the nc-version. My code works well for smaller images.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...