Sign in to follow this  
MatsK

FreeImage converting to 32bit...

Recommended Posts

MatsK    394
I'm using [url="http://freeimage.sourceforge.net/"]FreeImage[/url] to convert images from 8-bit to 32-bit RGBA. Here's my code:

[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
}[/code]

It works without crashing and all, but... when I view the images in Windows Explorer, they're supposedly only 24-bits! And [url="http://www.sfml-dev.org"]SFML[/url] refuses to display them, because it only likes 32-bit images! :(

Any idea?

Share this post


Link to post
Share on other sites
Matias Goldberg    9580
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
MChiz    161
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
MatsK    394
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.'[/size][/font]

Share this post


Link to post
Share on other sites
MatsK    394
[quote name='MChiz' timestamp='1306094368' post='4814323']
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
[/quote]


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
ryan20fun    2635
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
ryan20fun    2635
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this