Jump to content
  • Advertisement
Sign in to follow this  
MatsK

FreeImage converting to 32bit...

This topic is 2585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using FreeImage to convert images from 8-bit to 32-bit RGBA. Here's my code:

FARExtractItemFromFileByName(m_ArchivePath.c_str(), StrFilename.c_str(),
(unsigned char**)&Buffer, 1);

FREE_IMAGE_FORMAT Fif = FreeImage_GetFIFFromFilename(StrFilename.c_str());

if(Fif != FIF_UNKNOWN)
{
FIBITMAP *Img = FreeImage_Load(Fif, StrFilename.c_str());

FIBITMAP *Tmp = Img;
Img = FreeImage_ConvertTo32Bits(Tmp);
FreeImage_Unload(Tmp);

if(StrFilename.find(".tga") == string::npos)
FreeImage_Save(FREE_IMAGE_FORMAT::FIF_PNG, Img, Replace(StrFilename, ".bmp", ".png").c_str());
else
FreeImage_Save(FREE_IMAGE_FORMAT::FIF_PNG, Img, Replace(StrFilename, ".tga", ".png").c_str());

remove(StrFilename.c_str());
//delete Img; //This causes an assertion... o_O
}


It works without crashing and all, but... when I view the images in Windows Explorer, they're supposedly only 24-bits! And SFML refuses to display them, because it only likes 32-bit images! :(

Any idea?

Share this post


Link to post
Share on other sites
Advertisement
Don't know about SFML requirements, but Windows Explorer is very unreliable for giving image data. I suggest you use a more advanced program to double check your image has alpha (GIMP is able to do so)

BTW, "delete Img" causes an assertion because you should call FreeImage_Unload( Img )

Share this post


Link to post
Share on other sites
Hi:

I'm guessing that you are saving the image to disk just for debug purposes. I haven't used FreeImage to save images, so I can't help you there.

However, if you are converting the image to 32bpp just to upload it to the graphics card, you could use 'FreeImage_GetBPP' to make sure that the image is 32 bpp ( it works for me ).

About your comment on the assertion when deleting the image, I think you should call 'FreeImage_Unload' to free it.

Hope it helps.
Carlos

Share this post


Link to post
Share on other sites
Thanks!
I don't have GIMP installed currently, but I opened the image in Photoshop, and it says 'RGB/8'. I Googled and found:

'[font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=2]8 bits per channel give 256 colours per channel, and an RGB image of 24 bit.'[/font]

Share this post


Link to post
Share on other sites

Hi:

I'm guessing that you are saving the image to disk just for debug purposes. I haven't used FreeImage to save images, so I can't help you there.

However, if you are converting the image to 32bpp just to upload it to the graphics card, you could use 'FreeImage_GetBPP' to make sure that the image is 32 bpp ( it works for me ).

About your comment on the assertion when deleting the image, I think you should call 'FreeImage_Unload' to free it.

Hope it helps.
Carlos



Nope, I'm not saving the images for debug purposes. I'm recompressing them after they've been converted. It doesn't change the bit depth though. I'll try outputting the bit-depth using FreeImage_GetBPP and see what happens.

Share this post


Link to post
Share on other sites
i could conveert them to 32Bit for you, but if they are like a good few MB's can you put them in a rar / zip / whatever archive or something so that it is not a big download and upload (i dont have a fast internet connection, 192KB per sec)
you can upload it here but is wont allow archives and such only images and media as far as i know (and i dont think there are bad reprocusions for that or you could upload them to a file server or something)

Share this post


Link to post
Share on other sites
i just noticed you are using Photoshop i have used the CS3 version and there is an option to change the image editiong mode or something like that.
here is what i think should do the job
[attachment=2407:untitled.jpg]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!