CImg is a lightweight, header-only image processing library. The
makefile automatically makes a git clone of this library when building.
This example shows how to capture a screenshot using the bitmap device,
convert it to a CImg bitmap, scale it, add (in a higher resolution than
the original screenshot) annotations and write out a PNG file.
This is a reduced version of a bigger program, so it might be a bit more
complicated that needed just for the example.
This example uses the Bitmap device to draw to an in-memory buffer
and writes the result to a TGA file. This can for example be used to
make screenshots of an application normally running on an Arduino.
This allows creating bitmaps with sizes that are not multiples of 8x8
pixels. It seems the rest of u8g2 already supports this, as long as the
u8g2 and u8x8 buffers are rounded up to a multiple of 8x8 tiles.
A single malloc allocates space for both buffers. Previously,
u8x8_SetupBitmap would figure out where the u8g2 buffer lives based on
the u8x8 buffer, but this seems a bit fragile. Now, directly after
allocating, the pointer for both buffers are figured out and stored
separately.
When compiling outside of the Arduino environmen, U8X8_USE_PINS is not
defined. However, some parts of the C++ code outside of the
U8X8_USE_PINS guards depended on code inside the guards, breaking
compilation. By adding some extra guards, compilation of the C++ code
now also works outside of the Arduino environment.