Right way to generate a .xpm icon from gimp Topic is solved

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
jos
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Dec 31, 2020 10:14 am

Right way to generate a .xpm icon from gimp

Post by jos »

Hi Im trying to generate my own .xpm files from .png in gimp:


Once that the image is to 32x32 pix 300ppp I generate on this way:

image->Colour->Indexed->Colour map->Generate optimum palette->Maximum 8 Colors
export->xpm ->Alpha threshold 127

But when I try to integrate it in the app, I get the next error:

An assertion Failed!
../src/generic/imaglist.cpp(66): assert "(bitmap.GetWidth() >= m_width && bitmap.GetHeight() == m_height) || (m_width == 0 && m_height == 0)" failed in Add(): invalid bitmap size in wxImageList: this might work on this platform but definitely won't under Windows.

Could somebody show me the right way to geneate a xpm (right app, options... etc)?

Thanks in advance.

Here is my own .xpm file:

Code: Select all

/* XPM */
static char * toolchar2_xpm[] = {
"32 32 9 1",
" 	c None",
".	c #211E1C",
"+	c #5A4A23",
"@	c #544A40",
"#	c #92754C",
"$	c #C38340",
"%	c #A59330",
"&	c #979B27",
"*	c #CA9F70",
"&&&&%&&%%$%#%#+####%%&&&%%%&%&%&",
"%&&&&&&%++............+%&&%%&&%&",
"%%%&&&+........+.........%&&&&&%",
"$%%%&%....++###@##%#++...+&&&&&%",
"$%&%%%+.+#@@$####@%+++++.+&%%%&%",
"$%&&&&+++.@@@##++##@+...+%&%&&&%",
"%%&&&&%@.@+##++++.$%#+...&%%&&%%",
"%%&&&&%++#.....@@..@@@++&&%&%$$$",
"$&&&&&&&#@@@#####@@@@@+.&&&$$$$$",
"%%$%&&&%.************#*#&&&$$%%$",
"%&%$$&&&#***********#**#%&&$$%%$",
"&&%%$&&&#**$##****$****#+&&$$$%$",
"&&&%$&&&#**$$#**$#$##***#&&&$$$$",
"&%%%%&&%#***#****$$#*$**%%&&&%$%",
"*$*%&&&$$****$***$**$$**+$&&&&&&",
"*$%**&&##********$*$$$$##+&&&&&$",
"*$**#%%#@**$$$$****$$$$#++&&&&%%",
"%**#*&&#@#**$$$#$$$$$$$@+#&&&&%%",
"&&$%%&&#@#*$$$%%#%%$$$#+++&&&&%%",
"%&%&&&##@+#%%%%#$$*%##@+@+&&&%&%",
"&&&&&%#++@%%*%#$$$$%##+@@+&&%&%%",
"%&&&&##@######**$$#####++++%&%&%",
"%%&&&%#@#$###@**++#+@+#++++%&%%%",
"&%&&&#####@#@##*+@##+##++@@#&%%&",
"%&&&&###@@@#*#%#@.@####@++@+%%%%",
"&&&&##*@@@@#**#@+.@++###+++@%%&%",
"&&&&+#@@@@@####@++@@+@@#+++@+&%%",
"&&%&##@@@#####%+.@@@+.@..++++&&%",
"%&&&#+##+@.#@@+...@..+@.@@@+++&%",
"*%&%++.@@@+@+++....@+++@@+++++&&",
"*$&@@#+@@.+@@@#+..@@.+@.@@@+++.&",
"%#.@@+@@@.++@.#+++.@+.+.....++.."};

[b]And here a right .xpm icon:[/b]
/* XPM */
static const char *const toolchar_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 4 1",
". c Black",
"X c #FFFF00",
"  c None",
"o c #C00000",
/* pixels */
"                                ",
"             .....              ",
"          ...XXXXX...           ",
"        ..XXXXXXXXXXX..         ",
"       .XXXXXXXXXXXXXXX.        ",
"     ..XXXXXXXXXXXXXXXXX..      ",
"     .XXXXXXXXXXXXXXXXXXXX.     ",
"    .XXXXXX.XXXXXXX.XXXXXX.     ",
"   .XXXXXX.X.XXXXX.X.XXXXXX.    ",
"   .XXXXX.XXX.XXX.XXX.XXXXXX.   ",
"  .XXXXX.XXXXXXXXXXXXX.XXXXX.   ",
"  .XXXXXXXX.XXXXXXX.XXXXXXXX.   ",
"  .XXXXXXXX.XXXXXXX.XXXXXXXX.   ",
" .XXXXXXXXXXXXXXXXXXXXXXXXXXX.  ",
" .XXXXXXXXXXXXXXXXXXXXXXXXXXX.  ",
" .XXXXXXXXXXXXXXXXXXXXXXXXXXX.  ",
" .XXXXXXXXXXXXXXXXXXXXXXXXXXX.  ",
" .XXXXXXX.XXXXXXXXXXX.XXXXXXX.  ",
"  .XXXXXX...XXXXXXX...XXXXXX.   ",
"  .XXXXXX.oo..XXX..oo.XXXXXX.   ",
"  .XXXXXXX.ooo...ooo.XXXXXXX.   ",
"   .XXXXXXX.ooooooo.XXXXXXXX.   ",
"   .XXXXXXXX..ooo..XXXXXXXX.    ",
"    .XXXXXXXXX...XXXXXXXXX.     ",
"     .XXXXXXXXXXXXXXXXXXXX.     ",
"     ..XXXXXXXXXXXXXXXXX..      ",
"       .XXXXXXXXXXXXXXX.        ",
"        ..XXXXXXXXXXX..         ",
"          ...XXXXX...           ",
"             .....              ",
"                                ",
"                                "
};
Last edited by DavidHart on Mon Feb 15, 2021 11:24 am, edited 1 time in total.
Reason: Added code-tags
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Right way to generate a .xpm icon from gimp

Post by doublemax »

Could somebody show me the right way to geneate a xpm (right app, options... etc)?
I don't think it's a problem with the XPM. The assert just complains that the size of the bitmap does not match the size the image list expects (an wxImageList can only contain bitmaps that all have the same size).
Use the source, Luke!
jos
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Dec 31, 2020 10:14 am

Re: Right way to generate a .xpm icon from gimp

Post by jos »

Thank you very much for the tip, but when I only use my own .xpm on all the list elements I get the same error :-(
I don't think it's a problem with the XPM. The assert just complains that the size of the bitmap does not match the size the image list expects (an wxImageList can only contain bitmaps that all have the same size).
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Right way to generate a .xpm icon from gimp

Post by doublemax »

Please show the code that triggers the assert, especially where you create the wxImageList and how you load the bitmaps.
Use the source, Luke!
jos
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Dec 31, 2020 10:14 am

Re: Right way to generate a .xpm icon from gimp

Post by jos »

Hi doublemax, thank you very much,

I found the fail!

I was trying to load a 32x32 pixels icon on this form:

Code: Select all

m_imageListNormal = new wxImageList(16, 16, true);
when should be:

Code: Select all

m_imageListNormal = new wxImageList(32, 32, true);
Regards!
Post Reply