Hopefully some of you have encountered the following problem and maybe you
have some solutions for me:
I am attempting to use the CImage class in order to load a PNG image. If I
use CImage::Load( <path_to_PNG_filename> ) everything works. However, if I
attempt to use CImage::LoadFromResource I cannot load my PNG that I imported
into my resources (it basically says that it cannot find the image inside
the .exe) I know that the documentation says that I have to have the
resource type as BITMAP in order for this method to work. The only way to
change a PNG resource to a BITMAP one is to manually edit the rc2 file.
However, if I do that, my IDE complains that the PNG file is not a 3.00
bitmap format.
HOWEVER, if I do the same thing for a JPEG or GIF image everything is ok
(i.e., if I import the JPEG/GIF, then manually edit the rc2 file and set
them to BITMAP) I can successfully use the LoadFromResource method.
Therefore, it seems that the only problem shows up with the PNG format.
I really don't understand why the CImage class advertises that it can load
PNG files both internally and externally (via LoadFromResource and Load
respectively) since I don't seem to be able to load a PNG via
LoadFromResource.
Did anyone run into this situation ? Any solutions ? The only one that I can
think of is to leave my PNG files as external files and not include them
into the .exe itself but I don't want to do that. The bitmap files take a
lot of space so that is why I would like to use PNG files.
Thank you.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4242 (20090714) __________
The message was checked by ESET NOD32 Antivirus.
I don't have easy access at the moment to the source where I did this, so I forget exactly
how I got the CImage to load.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Here is how to use it
CImage Image;
CResourceStream str(0, MAKEINTRESOURCE(IDR_PNG), _T("PNG"));
Image.Load(&str);
AliR.
"vvf" <v...@vvf.com> wrote in message
news:e8ftJHJB...@TK2MSFTNGP02.phx.gbl...
"AliR" <Al...@online.nospam> wrote in message
news:m847m.12323$vO4....@flpi145.ffdc.sbc.com...
>I usually use this class to load images other than bitmaps, but I haven't
>been able to get PNG files to load correctly from resource.
> http://www.learnstar.com/AliR/resourcestream.h
>
> Here is how to use it
>
> CImage Image;
> CResourceStream str(0, MAKEINTRESOURCE(IDR_PNG), _T("PNG"));
> Image.Load(&str);
>
Thank you. Indeed, the reason why this example doesn't work is because the
whole load mechanism seems to expect the images to be of type "BITMAP" [in
the rc2 file]. It just won't work if your resource is specified to be some
other type (such as "PNG" in this case). The problem, as I mentioned before,
is that I can only assign to a "BITMAP" type JPEGs and GIFs but not PNGs. I
do that by manually editing the rc2 file.
Thanks for your answer.
vvf
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4243 (20090714) __________
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:pp9p559jplpsbs3b3...@4ax.com...
>I noticed an annoying feature in including images in resources: the
>resource editor feels
> free to redo the image in some random format of its own. I find this
> unacceptable. I
> solved it by saving the file under a resource type of my own devising (in
> my case it was a
> GIF format file). Apparently the resource editor does not understand the
> concept that "My
> resources are to be saved in the type that I specity, not some random type
> of your
> choosing".
Indeed, I also noticed that after I import an image, the IDE asks if I want
to "save the changes" or something like that. I always click no. However,
I've heard reports that you basically import a, let's say, JPEG image that
has a size of say 100k and after it is saved in the resource editor, its
size increases. Therefore, as you said, it seems that the images are
modified.
vvf.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4243 (20090714) __________