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.
Joelito
Earned some good credits
Posts: 128 Joined: Wed Jun 18, 2008 8:35 pm
Location: Tijuana, BC, México
Post
by Joelito » Fri Nov 17, 2017 7:33 pm
I'm trying to convert png to header code with ImageMagick. Does anyone had succesfully use it. Because testing 3 image gives me on my executable startup "This is not a image PNG" message. The code is simple:
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux x86_64 with xfce desktop & wxgtk{2,3}-3.0.5.
Joelito
Earned some good credits
Posts: 128 Joined: Wed Jun 18, 2008 8:35 pm
Location: Tijuana, BC, México
Post
by Joelito » Mon Nov 27, 2017 1:19 am
Sorry for the delay.
1.- This is the test icon
stop.png
2.- My convert version:
outputs:
Version: ImageMagick 6.9.9-23 Q16 x86_64 2017-11-12
http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
3.- imagemagick command from png to C/C++ header file
Contents of stop_png.h, outputs this ->
nopaste.xyz
4.- After editing the header to fit the wxBITMAP_PNG needs, from
static const unsigned char MagickImage[]
to
static const unsigned char stop_png[]
The test code example:
Code: Select all
#include "stop_png.h"
// ...
wxImage::AddHandler(new wxPNGHandler);
// ...
wxButton *stop_button = new wxButton(panel, wxID_STOPBUTTON, _("&Find"));
stop_button->SetBitmap(wxBITMAP_PNG(stop));
Get the warning:
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux x86_64 with xfce desktop & wxgtk{2,3}-3.0.5.
doublemax
Moderator
Posts: 19116 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Mon Nov 27, 2017 6:52 am
Try wxBITMAP_PNG_FROM_DATA instead of wxBITMAP_PNG
Use the source, Luke!
Joelito
Earned some good credits
Posts: 128 Joined: Wed Jun 18, 2008 8:35 pm
Location: Tijuana, BC, México
Post
by Joelito » Mon Nov 27, 2017 2:52 pm
Code: Select all
file_button->SetBitmap(wxBITMAP_PNG_FROM_DATA(stop));
Same warning
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux x86_64 with xfce desktop & wxgtk{2,3}-3.0.5.
doublemax
Moderator
Posts: 19116 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Mon Nov 27, 2017 6:27 pm
The header file stop_png.h and the PNG you posted are definitely not the same. In the PNG, the first four bytes are 0x89, 0x50, 0x4e, 0x47 which is the PNG marker.
So i'd say the error message is correct, the header file does not contain a valid PNG file. It seems the tool converted it into PNM.
Use the source, Luke!
Joelito
Earned some good credits
Posts: 128 Joined: Wed Jun 18, 2008 8:35 pm
Location: Tijuana, BC, México
Post
by Joelito » Mon Nov 27, 2017 7:40 pm
yeah, right now I'm using wxInclude and bin2c and both produce correct header files.
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux x86_64 with xfce desktop & wxgtk{2,3}-3.0.5.