mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-17 19:05:07 +00:00
Graphics & rendering - Implement `binfont-module` to generate bitmap fonts on the device itself - Remove lodepng support from LVGL library and create `Modules/lodepng-module` to make the feature re-usable in non-LVGL apps too. Add binding functions for LVGL support. - Implement large icons for boot screen (Tactility and USB logos) - Remove unused asset files in `Data/` Boot - Split up `Tactility.cpp` and its `run()` function into various `Init*.cpp` files. - Re-implement `Boot.cpp` app as non-LVGL app - Boot app now has a `BootSequence.cpp` for the init code. - LVGL is now started when the Boot app finishes - Move more init logic into Boot app BLE - Don't allocate scan result buffers unless BLE is on - Allocate scan results in external memory if possible UX & UI - USB Settings app: remove border from the button container
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
#include "doctest.h"
|
|
|
|
#include <lodepng/lodepng.h>
|
|
|
|
#include <cstring>
|
|
|
|
TEST_CASE("lodepng decodes a PNG file") {
|
|
unsigned char* image = nullptr;
|
|
unsigned width = 0;
|
|
unsigned height = 0;
|
|
REQUIRE_EQ(lodepng_decode32_file(&image, &width, &height, LODEPNG_TEST_LOGO), 0);
|
|
CHECK_EQ(width, 80);
|
|
CHECK_EQ(height, 103);
|
|
lodepng_free(image);
|
|
}
|
|
|
|
TEST_CASE("lodepng returns an error for a missing file") {
|
|
unsigned char* image = nullptr;
|
|
unsigned width = 0;
|
|
unsigned height = 0;
|
|
CHECK_NE(lodepng_decode32_file(&image, &width, &height, "missing.png"), 0);
|
|
lodepng_free(image);
|
|
}
|
|
|
|
TEST_CASE("lodepng encodes and decodes an image without changes") {
|
|
constexpr unsigned width = 3;
|
|
constexpr unsigned height = 2;
|
|
const unsigned char pixels[width * height * 4] = {
|
|
255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255,
|
|
0, 0, 0, 0, 255, 255, 255, 128, 10, 20, 30, 40,
|
|
};
|
|
|
|
unsigned char* png = nullptr;
|
|
size_t png_size = 0;
|
|
REQUIRE_EQ(lodepng_encode32(&png, &png_size, pixels, width, height), 0);
|
|
|
|
unsigned char* decoded = nullptr;
|
|
unsigned decoded_width = 0;
|
|
unsigned decoded_height = 0;
|
|
REQUIRE_EQ(lodepng_decode32(&decoded, &decoded_width, &decoded_height, png, png_size), 0);
|
|
CHECK_EQ(decoded_width, width);
|
|
CHECK_EQ(decoded_height, height);
|
|
CHECK_EQ(memcmp(decoded, pixels, sizeof(pixels)), 0);
|
|
|
|
lodepng_free(png);
|
|
lodepng_free(decoded);
|
|
}
|