← Back to team overview

kicad-developers team mailing list archive

Re: KiCad new look - new icons and new buttons


On 08/23/2011 07:32 AM, Wayne Stambaugh wrote:
>> Then we have to decide on how to load the PNG files into the programs, and there
>> seem to be at least two ways to do this:
>> A) read the *.PNG files into memory from disk at program start time.
>> B) convert the *.PNG files into a BYTE array which is compiled into the
>> respective program.  But the byte array is definitely a PNG format, meaning we
>> get the advantage of the alpha channel support, which we do not currently have.
> C) Zip all the *.PNG files into an archive and use wxInputStream to access the
> archive like a file system.
> My preference is B but I'm not sure exactly how you would access the byte
> arrays directly with wxBitmap or wxImage.


tells how.   The C program they are using to convert the *.png file to a byte
array is nothing, and can be done in Cmake scripting lingo as I said.

I also prefer B), which lets the linker do the determination ahead of time as to
which bitmaps are needed by which program.

There is difficulty using the C program to do this, when cross compiling,
assuming you want that C program to be built with CMake.   Therefore I suggested
using a *.cmake script to do it.

The CMake script should at least:

1) convert each *.png file to a *.cpp file.

2) remember each *.png file that it converted, and output a single header file.

the header file needs to have "per bitmap" entries in it.

case 1) either this:

extern unsigned char GBM_rotate_neg_X[];
#define GBM_rotate_neg_X_SIZE;

extern unsigned char GBM_rotate_pos_Y[];
#define GBM_rotate_pos_Y_SIZE;


or this:

case 2) this:

extern wxBitmap* GPM_rotate_neg_X;        // @todo look into no pointer, but
extern wxBitmap* GPM_rotate_pos_Y;

In case 2) the *.cmake script can simply write code for each *.png file to
construct the bitmap in the bitmap specific *.cpp file, which goes into the
bitmap library:


#include "bitmaps.h"
#include <wxBitmap.h>

static unsigned char bytes[] = { 0xab, 0xcd, ...};

wxBitmap* GPM_rotate_neg_X = MakeBitmap( bytes, sizeof(bytes) );


Then you put those into the bitmap library.

For the new common function:

static bool usingPNG;

wxBitmap* MakeBitmap( unsigned char* bytes, int byteCount )

    if( !usingPNG )
        usingPNG = true;
        wxImage.AddHandler( New wxPNGHandler )

        // other oneshot stuff.


    return wxBitmap( as per the wiki entry );



So, can Windows wxWidgets be taught to support PNG?

Follow ups