Developed today a tool for Redkite to generate resources files for PNG files. It converts PNG images to C files with an C array as ARGB32 encoding for images. Called the tool rkpng2c. When building and installing the Redkite toolkit rkpng2c is built and installed too, so, is a part of Redkite GUI toolkit, released under GPLv3.
Developers may use other tools to convert PNG images to array, but I thought there must be a mandatory tool from Redkite that will be part of a more polished resources “module” of Redkite.
For example, now Geonkick has a directory resources with PNG files. When building with CMake, the build system is using rkpng2c to convert all files to C files that are then built. The code from Geonkick that uses a PNG file to display the logo image by a label look like this:
extern const unsigned char rk_logo_png; .... auto logo = new RkLabel(this); RkImage image(rk_logo_png, 120, 20); logo->setSize(image.width(), image.height()); logo->setBackgroundColor(68, 68, 70); logo->setImage(image); logo->setX(10); logo->setY((height() - logo->height()) / 2); logo->show();
rk_logo_png array will be defined in the file logo_png.c generated automatically by CMake with rkpng2c.