Introduction

GBImg is a command-line tool that allow you to convert BMP and PNG images into the Gamebuino flash memory format.

It can also handle animated images and spritesheets

It currently support only uint8_t[] flash images in the indexed mode


Usage:
  GBImg [OPTION...]

  -o, --output-path arg         File name of the export (default: code.hpp)   -i, --image-input arg         Image path to convert   -c, --code-name arg           identifier in the exported code (default:                                 image)       --transparency [=N(=0)]   Choosen color index used for transparency.                                 Value greater than 15 (0x0F) will make the                                 program not handle transparency (default: 255)       --palette default / edge16                                 Choosen color palette used for finding                                 correct indexes (default: default)       --palette-file arg        File from which the color palette will be                                 used (override palette option)   -h, --help                    Print the help

 Spritesheet options:   -s, --spritesheet  Activate the spritesheets mode       --tile-x N     Number of tiles on X axis Sub width will be deduced                      with image-width / tile-x (default: 0)       --tile-y N     Number of tiles on Y axis | Sub height will be deduced                      with image-height / tile-y (default: 0)       --framerate N  Framerate of the animation | number of frame per                      animation (default: 0)


The download link provide a compiled version for Windows 7 and some test / example in bat files


Todo

  • Loading custom color palette from file
  • Support for uint16_t[] images
  • Convert RGB888 to RGB565
  • Multiples images at once
  • Other export methods

Last comments

avatar
gamebuino-admin
1 year ago
Author :  Sorunome

It would appear to be an authorized optimization

Yeah, compiler optimizes it, except if you turn off optimizations

So indeed, for clarity && to avoid surprise, it's better to do a direct initialization

Yep!


Also, direct initialization is shorter to type xP

avatar
gamebuino-admin
1 year ago
Author :  AceyT

Theoretically, I would said the same as you, but after some tests on my computers and gamebuino, I got other results.

I don't know if this is a compiler optimization or the standard way of interpreting it in C++, but the syntax `Image img = Image(data);` still call the appropriate constructor, and not a constructor + copy constructor;

EDIT : It would appear to be an authorized optimization. It's kind of like Return Value Optimization but named in this case " Copy Elision (cpp reference) ".
So indeed, for clarity && to avoid surprise, it's better to do a direct initialization. There's so many things that you can think about in C++

avatar
gamebuino-admin
1 year ago
Author :  Sorunome

Let's break `Image img = Image(blah);` down.

So, what happens here first is that a temporary Image is created, with the `Image(blah);` call. Afterwards a new Image called `img` is created. Next, the temporary Image is been copied over to img, calling the copyconstructor.

When you use `Image img(blah);` it just creates a new image img and initializes it with blah