XRC issue for some PNG graphics.

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

XRC issue for some PNG graphics.

Post by Widgets »

In my current project, I am trying to display a wxBitmapButton, using a 16x16 PNG as the base image.
The GUI is built using wxCrafter 2.9 - latest version
I am building under Win 10, 64-bits using MSVC 2029 community edit and wxWidgets 3.1.4
The problem is that the specific button with the given PNG does not display. Other PNGs, built using the same process and GUI builder do display properly in the same app.
The log reports:

Code: Select all

18:08:05: Error: XRC error: XRC resource "Modify_16x16" (class "wxBitmap") not found
I have asked on the wxCrafter forum, but have not had any answers as yet.

As an alternative in tracking this down and to move my project along, because I am convinced it is a wxWidgets issue - wxCrafter is based on wxWidgets and, presumably uses the wxWidgets library for all of the relevant code - I have modified the wxWidgets minimal project and have attached a basic example which shows the same issue.
It reports:

Code: Select all

18:06:08: XRC error: XRC resource "D:/MSVC2019/wxWidgets-3.1.4/samples/minimalPng/modifywxCrafter.xml" (class "wxBitmap") not found
18:06:08: XRC error: XRC resource "modifywxCrafter.xml" (class "wxBitmap") not found
If I use the plain PNG or an XMP version, it loads and display the image without error.
Since this is the first time I had to dig into XRC functionality and hence I am not familiar at all, I have copied the data generated by wxCrafter for the give n PNG and the example shows the same error message when I try to display the image using the same code as used by the wxCrafter generated class
Attachments
minimalXrcTest.zip
(13.41 KiB) Downloaded 66 times
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: XRC issue for some PNG graphics.

Post by doublemax »

I usually don't use XRC, so i don't know too much about it, but i know that the .xml file you posted is not an XML resource file.

Check one of the .xrc files in <wxdir>/samples/xrc/rc/ to see how the look like.

What you have is a binary converted to C source file. You include them and create a bitmap from the static data:

Code: Select all

#include "modifywxCrafter.xml"
...

wxBitmap bmp = wxBitmap::NewFromPNGData( xml_res_file_1, xml_res_size_1 );
Maybe wxCrafter has an option to include the static data in the resource file somehow? I don't know, but i think there is a step missing somewhere.
Use the source, Luke!
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: XRC issue for some PNG graphics.

Post by DavidHart »

Hi,
I have asked on the wxCrafter forum, but have not had any answers as yet.
Are you sure? I noticed this bug-report but I can't see anything on the CodeLite forum.

IIUC you're using wxCrafter for the gui, but MSVC for building. wxCrafter can produce two sorts of output: by default, C++ for use in the CodeLite IDE, but you can also export as XRC. Which are you using? And how does this relate to the bitmapbutton with the problematical PNG? Is it added by wxCrafter, or separately?

Regards,

David
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: XRC issue for some PNG graphics.

Post by Widgets »

@Doublemax: wxCrafter does produce both an *.xrc file (which I ignore) and a *,cpp file where I copied the data array from as well as the loader code

Code: Select all

 wxXmlResource::Get()->LoadBitmap( wxT("modifywxCrafter.xml")) );
my apologies for not identifying that.
The XRC file is included in the wxCrafter code, but I can rename that file and there is no reaction from the compiler/linker if I do so. Hence my conclusion that it was not used. As well, if I even comment out the code which seems to include it, the project compiles, links and the rest of the PNG images in similar buttons, still display as expected.

@DavidHart: the bug report you were looking at was the one I was referring to.
Yes, I am using the stand alone version and have been ever since it was first published. And, yes, I generate the GUI with it and then compile with MSVC.
As a test, I have also created the GUI with the latest Codelite wxCrafter plugin, just in case there might be a difference/update, but I got the same results - the one image does not display.
In the mean time, I have tried to display a second image in the test app, which in my app is also included the same way and one which displays without error, but evidently, there is something else I am missing, because this second image produces the same error as the one I was complaining about.

FWIW, all images start as PNGs. Some display OK, at least one fails. And I have not been able to identify what, if any difference there might be between the two.
Back to the drawing board and more tracking down of the real problem.
If I come to any better resolution other than some temporary work around, I will repost here
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: XRC issue for some PNG graphics.

Post by Widgets »

My current work-around is to let wxCrafter use wxArtProvider images
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: XRC issue for some PNG graphics.

Post by Widgets »

Just posted a new chapter in this story at: https://github.com/eranif/codelite/issues/2830
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply