load bitmap from resource file, bmp or BMP

490 views
Skip to first unread message

asmwarrior

unread,
May 25, 2012, 9:04:51 AM5/25/12
to wx-u...@googlegroups.com
I have found that when I have use such code in the rc file:

content BITMAP "b.bmp"
tv BITMAP "a.bmp"

Next, in the code, I have two wxBitmap objects will be constructed from these two files. But the second wxBitmap failed:
wxWidgets give a alert message saying the "tv" can't be loaded from resource file.
The strange thing is: the first wxBitmap can be constructed correctly.

I have struggled several hours, and finally I found that if I change the file extension to capital letters.
(I also change the file extension in the folder), like below:

content BITMAP "b.BMP"
tv BITMAP "a.BMP"

This works OK, both two wxBitmap objects can be correctly initialized by those two bitmaps in the resource file.

My question is: Does the extension "BMP" or "bmp" cause this issue? Why?

Thanks.

asmwarrior(ollydbg)

Vadim Zeitlin

unread,
May 25, 2012, 1:30:25 PM5/25/12
to wx-u...@googlegroups.com
On Fri, 25 May 2012 21:04:51 +0800 asmwarrior wrote:

a> I have found that when I have use such code in the rc file:
a>
a> content BITMAP "b.bmp"
a> tv BITMAP "a.bmp"
a>
a> Next, in the code, I have two wxBitmap objects will be constructed from these two files. But the second wxBitmap failed:
a> wxWidgets give a alert message saying the "tv" can't be loaded from resource file.
a> The strange thing is: the first wxBitmap can be constructed correctly.
a>
a> I have struggled several hours, and finally I found that if I change the file extension to capital letters.
a> (I also change the file extension in the folder), like below:
a>
a> content BITMAP "b.BMP"
a> tv BITMAP "a.BMP"
a>
a> This works OK, both two wxBitmap objects can be correctly initialized by
a> those two bitmaps in the resource file.
a>
a> My question is: Does the extension "BMP" or "bmp" cause this issue? Why?

It definitely shouldn't, file names are case-insensitive under Windows,
even in the resources. Can you reproduce the problem in a sample?

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

asmwarrior

unread,
May 26, 2012, 12:37:01 AM5/26/12
to wx-u...@googlegroups.com
Hi, VZ, thanks. I test the ownerdrw sample, and the ownerdrw.exe works OK.
I'm using MinGW 4.6.x and wx2.8.12.

I just compared what the ownerdrw build log and what myApp build log.

myApp:(the command line under Codeblocks)
windres.exe -IE:\code\cb\wx\wxWidgets-2.8.12\include -IE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll\mswu -J rc -O coff -i resource.rc -o obj\Debug\resource.res


wx sample: (command under Windows Shell)
windres --use-temp-file -iownerdrw.rc -ogcc_mswudll\ownerdrw_ownerdrw_rc.o --define __WXMSW__ --define NDEBUG --define _UNICODE --define wxUSE_GRAPHICS_CONTEXT=1 --include-dir .\..\..\lib\gcc_dll\mswu --include-dir ./../../include --include-dir . --define WXUSINGDLL --include-dir ./../../samples --define NOPCH

First, I believe that wrong options causes this issue. But after I changed some command line options and file extensions (either "BMP" or "bmp"), I found that I can't reproduce my issue any longer.

So, sorry about my noise, I will report this if the issue happens again.

asmwarrior
Reply all
Reply to author
Forward
0 new messages