diff --git a/README.md b/README.md
index 2764770..eebda01 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,8 @@ You can find a simple Arduino example sketch [over here](https://github.com/javl
### Screen types
I wrote the code with my 128x64 pixel monochrome OLED display in mind, but it should work with most similar displays. You might need to change some export settings; those are explained in the tool.
+### Running tests
+A simple test suite lives in the `tests` directory. See [`tests/`](tests/README.md) for instructions.
### Credit
Initial code by [javl](https://github.com/javl) with aditional code by (in alphabetical order):
diff --git a/index.html b/index.html
index 5144e28..c4d0343 100644
--- a/index.html
+++ b/index.html
@@ -252,7 +252,7 @@
diff --git a/js/script.js b/js/script.js
index 18f75be..f61f39a 100644
--- a/js/script.js
+++ b/js/script.js
@@ -582,8 +582,10 @@ function listToImageHorizontal(list, canvas) {
// we want to scale / invert, etc.
ctx.putImageData(imgData, 0, 0);
const img = new Image();
+ img.onload = () => {
+ images.first().img = img;
+ };
img.src = canvas.toDataURL('image/png');
- images.first().img = img;
}
// Quick and effective way to draw single pixels onto the canvas
@@ -644,8 +646,10 @@ function listToImageVertical(list, canvas) {
// Save the canvas contents inside the img object. This way we can
// reuse the img object when we want to scale / invert, etc.
const img = new Image();
+ img.onload = () => {
+ images.first().img = img;
+ };
img.src = canvas.toDataURL('image/png');
- images.first().img = img;
}
// Handle inserting an image by pasting code
@@ -665,7 +669,7 @@ function handleTextInput(drawMode) {
canvasContainer.appendChild(canvas);
const image = new Image();
- images.setByIndex(0, { img: image, canvas });
+ images.setByIndex(0, { img: image, canvas, ctx: canvas.getContext('2d') });
let input = document.getElementById('byte-input').value;
@@ -673,14 +677,15 @@ function handleTextInput(drawMode) {
input = input.replace(/const\s+(unsigned\s+char|uint8_t)\s+[a-zA-Z0-9]+\s*\[\]\s*(PROGMEM\s*)?=\s*/g, '');
input = input.replace(/\};|\{/g, '');
- // Convert newlines to comma (helps to remove comments later)
+ // Remove comments (while newlines are still newlines, so the whole
+ // comment is dropped even if it contains a comma, e.g. "// 'name', 8x8px")
+ input = input.replace(/\/\/.*$/gm, '');
+ // Convert newlines to comma
input = input.replace(/\r\n|\r|\n/g, ',');
// Convert multiple commas in a row into a single one
input = input.replace(/,{2,}/g, ',');
// Remove whitespace
input = input.replace(/\s/g, '');
- // Remove comments
- input = input.replace(/\/\/(.+?),/g, '');
// Remove "0x"
input = input.replace(/0[xX]/g, '');
// Split into list
@@ -775,7 +780,7 @@ function handleImageSelection(evt) {
w.value = img.width;
settings.screenWidth = img.width;
w.oninput = () => {
- canvas.width = this.value;
+ canvas.width = w.value;
updateAllImages();
updateInteger('screenWidth');
};
@@ -789,7 +794,7 @@ function handleImageSelection(evt) {
h.value = img.height;
settings.screenHeight = img.height;
h.oninput = () => {
- canvas.height = this.value;
+ canvas.height = h.value;
updateAllImages();
updateInteger('screenHeight');
};
@@ -885,7 +890,7 @@ function imageToString(image) {
// Get the custom arduino output variable name, if any
function getIdentifier() {
const vn = document.getElementById('identifier');
- return vn && vn.value.length ? vn.value : identifier;
+ return (vn && vn.value.length) ? vn.value : identifier;
}
// Output the image string to the textfield
@@ -910,7 +915,7 @@ function generateOutputString() {
const comment = `// '${image.glyph}', ${image.canvas.width}x${image.canvas.height}px\n`;
bytesUsed += code.split('\n').length * 16; // 16 bytes per line.
- const varname = getIdentifier() + image.glyph.replace(/[^a-zA-Z0-9]/g, '_');
+ const varname = getIdentifier() + (image.glyph ? image.glyph.replace(/[^a-zA-Z0-9]/g, '_') : '');
varQuickArray.push(varname);
code = `${comment}const ${getImageType()} ${varname} [] PROGMEM = {\n${code}};\n`;
outputString += code;
@@ -918,8 +923,8 @@ function generateOutputString() {
varQuickArray.sort();
outputString += `\n// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = ${bytesUsed})\n`;
- outputString += `const int ${getIdentifier()}allArray_LEN = ${varQuickArray.length};\n`;
- outputString += `const ${getImageType()}* ${getIdentifier()}allArray[${varQuickArray.length}] = {\n\t${varQuickArray.join(',\n\t')}\n};\n`;
+ outputString += `const int ${getIdentifier()}_allArray_LEN = ${varQuickArray.length};\n`;
+ outputString += `const ${getImageType()}* ${getIdentifier()}_allArray[${varQuickArray.length}] = {\n\t${varQuickArray.join(',\n\t')}\n};\n`;
break;
}
diff --git a/package-lock.json b/package-lock.json
index 19c9cbe..226f538 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -166,10 +166,11 @@
}
},
"node_modules/ajv": {
- "version": "6.12.6",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
- "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
+ "version": "6.15.0",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
+ "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -298,10 +299,11 @@
"dev": true
},
"node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "version": "1.1.18",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
+ "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -376,10 +378,11 @@
"dev": true
},
"node_modules/cross-spawn": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
- "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
@@ -1421,10 +1424,20 @@
}
},
"node_modules/js-yaml": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
- "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
+ "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
"dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/puzrin"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/nodeca"
+ }
+ ],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -1837,10 +1850,11 @@
}
},
"node_modules/semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
+ "version": "6.3.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
+ "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
+ "license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 0000000..3a6e398
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,37 @@
+# image2cpp test suite
+
+Test uses the real `index.html` file and scripts in a headless browser
+using `Playwright`. Output is compared against known valid (`golden`) files.
+This way we are testing the output of the actual tool, not a reimplementation.
+
+## Setup and running
+
+```
+python3 -m venv .venv
+source .venv/bin/activate
+pip install -r tests/requirements.txt
+playwright install chromium
+```
+
+To run:
+```
+python3 tests/test_conversions.py
+```
+
+Prints `ok`/`FAIL` per scenario and exits non-zero if anything doesn't
+match.
+
+## Updating golden files and test image
+
+To generate the test image again (only needed if we changed the image):
+```
+python3 tests/generate_test_image.py
+```
+
+After an intentional change to the conversion logic, regenerate the
+golden output and optionally review the diff before committing:
+
+```
+python3 tests/test_conversions.py --update
+git diff tests/golden
+```
diff --git a/tests/fixtures/test_pattern.png b/tests/fixtures/test_pattern.png
new file mode 100644
index 0000000..87f9b74
Binary files /dev/null and b/tests/fixtures/test_pattern.png differ
diff --git a/tests/generate_test_image.py b/tests/generate_test_image.py
new file mode 100644
index 0000000..2d8227a
--- /dev/null
+++ b/tests/generate_test_image.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+""" Generate a simple test-pattern image for use with the test suite.
+ This 32x24 image is used to test all the different conversion paths in
+ js/script.js and js/dithering.js. Different quadrants of the image test
+ different aspects of the conversion process:
+
+ - top-left: checkerboard -> stresses the threshold/dithering modes
+ - top-right: horizontal grayscale gradient -> stresses dithering algorithms
+ - bottom-left: RGB color bars -> stresses 565/888 color output
+ - bottom-right: diagonal line on white -> asymmetric element to test flip/rotate/mirror
+
+A 1px red marker in the extreme top-left corner and a 1px blue marker in the
+extreme bottom-right corner give an unambiguous orientation reference.
+"""
+from pathlib import Path
+
+from PIL import Image
+
+WIDTH, HEIGHT = 32, 24
+OUT_PATH = Path(__file__).parent / "fixtures" / "test_pattern.png"
+
+
+def build_image():
+ img = Image.new("RGB", (WIDTH, HEIGHT), "white")
+ px = img.load()
+ if px is None:
+ raise RuntimeError("Failed to create image object")
+
+ half_w, half_h = WIDTH // 2, HEIGHT // 2
+
+ # Top-left: checkerboard
+ for y in range(half_h):
+ for x in range(half_w):
+ color = (0, 0, 0) if (x // 2 + y // 2) % 2 == 0 else (255, 255, 255)
+ px[x, y] = color
+
+ # Top-right: horizontal grayscale gradient
+ for y in range(half_h):
+ for x in range(half_w):
+ v = int((x / max(half_w - 1, 1)) * 255)
+ px[half_w + x, y] = (v, v, v)
+
+ # Bottom-left: RGB color bars (red, green, blue, white)
+ bars = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)]
+ bar_w = max(half_w // len(bars), 1)
+ for y in range(half_h):
+ for x in range(half_w):
+ bar = min(x // bar_w, len(bars) - 1)
+ px[x, half_h + y] = bars[bar]
+
+ # Bottom-right: diagonal line on white background (asymmetric marker)
+ for y in range(half_h):
+ for x in range(half_w):
+ px[half_w + x, half_h + y] = (255, 255, 255)
+ for i in range(min(half_w, half_h)):
+ px[half_w + i, half_h + i] = (0, 0, 0)
+
+ # Orientation markers
+ px[0, 0] = (255, 0, 0) # top-left corner: red
+ px[WIDTH - 1, HEIGHT - 1] = (0, 0, 255) # bottom-right corner: blue
+
+ return img
+
+
+def main():
+ OUT_PATH.parent.mkdir(parents=True, exist_ok=True)
+ build_image().save(OUT_PATH)
+ print(f"wrote {OUT_PATH}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/golden/background_black.txt b/tests/golden/background_black.txt
new file mode 100644
index 0000000..928ffe2
--- /dev/null
+++ b/tests/golden/background_black.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0x33, 0x33, 0x00, 0xff, 0x00, 0x00, 0x33, 0x33, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff,
+0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff, 0x00, 0x00, 0x33, 0x33, 0x00, 0xff, 0x00, 0x00, 0x33, 0x33,
+0x00, 0xff, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff, 0x00, 0x00,
+0x33, 0x33, 0x00, 0xff, 0x00, 0x00, 0x33, 0x33, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff,
+0x00, 0x00, 0xcc, 0xcc, 0x00, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0x7f, 0xff, 0x00, 0x00, 0x0f, 0x0f,
+0xbf, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xdf, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xef, 0xff, 0x00, 0x00,
+0x0f, 0x0f, 0xf7, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xfb, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xfd, 0xff,
+0x00, 0x00, 0x0f, 0x0f, 0xfe, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0xff, 0x7f, 0x00, 0x00, 0x0f, 0x0f,
+0xff, 0xbf, 0x00, 0x00, 0x0f, 0x0f, 0xff, 0xdf, 0x00, 0x00, 0x0f, 0x0f, 0xff, 0xee, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
\ No newline at end of file
diff --git a/tests/golden/background_transparent.txt b/tests/golden/background_transparent.txt
new file mode 100644
index 0000000..c73451d
--- /dev/null
+++ b/tests/golden/background_transparent.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
\ No newline at end of file
diff --git a/tests/golden/background_white_larger_canvas.txt b/tests/golden/background_white_larger_canvas.txt
new file mode 100644
index 0000000..703e81b
--- /dev/null
+++ b/tests/golden/background_white_larger_canvas.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33,
+0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff,
+0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0x0f,
+0xbf, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xef, 0xff, 0xff, 0xff,
+0x0f, 0x0f, 0xf7, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xfd, 0xff,
+0xff, 0xff, 0x0f, 0x0f, 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0x7f, 0xff, 0xff, 0x0f, 0x0f,
+0xff, 0xbf, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xdf, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xee, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
\ No newline at end of file
diff --git a/tests/golden/bitswap.txt b/tests/golden/bitswap.txt
new file mode 100644
index 0000000..3aeab3e
--- /dev/null
+++ b/tests/golden/bitswap.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0xf0, 0xf0, 0xfe, 0xff, 0xf0, 0xf0, 0xfd, 0xff, 0xf0, 0xf0, 0xfb, 0xff, 0xf0, 0xf0, 0xf7, 0xff,
+0xf0, 0xf0, 0xef, 0xff, 0xf0, 0xf0, 0xdf, 0xff, 0xf0, 0xf0, 0xbf, 0xff, 0xf0, 0xf0, 0x7f, 0xff,
+0xf0, 0xf0, 0xff, 0xfe, 0xf0, 0xf0, 0xff, 0xfd, 0xf0, 0xf0, 0xff, 0xfb, 0xf0, 0xf0, 0xff, 0x77
\ No newline at end of file
diff --git a/tests/golden/center_both_larger_canvas.txt b/tests/golden/center_both_larger_canvas.txt
new file mode 100644
index 0000000..db176b4
--- /dev/null
+++ b/tests/golden/center_both_larger_canvas.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00,
+0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33,
+0x33, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff,
+0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0x33, 0x33, 0x00, 0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00,
+0xff, 0xff, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0x0f,
+0x0f, 0xbf, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xef, 0xff, 0xff,
+0xff, 0x0f, 0x0f, 0xf7, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xfd,
+0xff, 0xff, 0xff, 0x0f, 0x0f, 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0x7f, 0xff, 0xff, 0x0f,
+0x0f, 0xff, 0xbf, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xdf, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xee, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
\ No newline at end of file
diff --git a/tests/golden/default.txt b/tests/golden/default.txt
new file mode 100644
index 0000000..d2b1a12
--- /dev/null
+++ b/tests/golden/default.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0x0f, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xef, 0xff,
+0x0f, 0x0f, 0xf7, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfe, 0xff,
+0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/dithering_atkinson.txt b/tests/golden/dithering_atkinson.txt
new file mode 100644
index 0000000..bd8018f
--- /dev/null
+++ b/tests/golden/dithering_atkinson.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x33, 0x33, 0x01, 0xbf, 0x33, 0x33, 0x04, 0xff, 0xcc, 0xcc, 0x04, 0x9f, 0xcc, 0xcc, 0x03, 0x77,
+0x33, 0x33, 0x09, 0x7f, 0x33, 0x33, 0x01, 0x9f, 0xcc, 0xcc, 0x06, 0x7f, 0xcc, 0xcc, 0x01, 0xb7,
+0x33, 0x33, 0x09, 0xbf, 0x33, 0x33, 0x04, 0x6f, 0xcc, 0xcc, 0x05, 0xbf, 0xcc, 0xcc, 0x01, 0xb7,
+0x0d, 0x0f, 0x7f, 0xff, 0x0d, 0x0f, 0xbf, 0xff, 0x4b, 0x0f, 0xdf, 0xff, 0x1a, 0x0f, 0xef, 0xff,
+0x26, 0x0f, 0xf7, 0xff, 0x0d, 0x0f, 0xfb, 0xff, 0x49, 0x0f, 0xfd, 0xff, 0x1b, 0x0f, 0xfe, 0xff,
+0x0e, 0x0f, 0xff, 0x7f, 0x65, 0x0f, 0xff, 0xbf, 0x0d, 0x0f, 0xff, 0xdf, 0x0b, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/dithering_bayer.txt b/tests/golden/dithering_bayer.txt
new file mode 100644
index 0000000..8987b8a
--- /dev/null
+++ b/tests/golden/dithering_bayer.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x33, 0x33, 0x15, 0x57, 0x33, 0x33, 0x02, 0xbf, 0xcc, 0xcc, 0x15, 0x57, 0xcc, 0xcc, 0x00, 0xff,
+0x33, 0x33, 0x15, 0x57, 0x33, 0x33, 0x02, 0xbf, 0xcc, 0xcc, 0x15, 0x57, 0xcc, 0xcc, 0x00, 0xff,
+0x33, 0x33, 0x15, 0x57, 0x33, 0x33, 0x02, 0xbf, 0xcc, 0xcc, 0x15, 0x57, 0xcc, 0xcc, 0x00, 0xff,
+0x55, 0x1f, 0x7f, 0xff, 0x2b, 0x0f, 0xbf, 0xff, 0x55, 0x0f, 0xdf, 0xff, 0x0a, 0x0f, 0xef, 0xff,
+0x55, 0x1f, 0xf7, 0xff, 0x2b, 0x0f, 0xfb, 0xff, 0x55, 0x0f, 0xfd, 0xff, 0x0a, 0x0f, 0xfe, 0xff,
+0x55, 0x1f, 0xff, 0x7f, 0x2b, 0x0f, 0xff, 0xbf, 0x55, 0x0f, 0xff, 0xdf, 0x0a, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/dithering_floyd_steinberg.txt b/tests/golden/dithering_floyd_steinberg.txt
new file mode 100644
index 0000000..c86c4ad
--- /dev/null
+++ b/tests/golden/dithering_floyd_steinberg.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x33, 0x33, 0x02, 0xbf, 0x33, 0x33, 0x09, 0x57, 0xcc, 0xcc, 0x05, 0x7f, 0xcc, 0xcc, 0x11, 0x57,
+0x33, 0x33, 0x05, 0x5f, 0x33, 0x33, 0x02, 0xb7, 0xcc, 0xcc, 0x14, 0xbf, 0xcc, 0xcc, 0x02, 0xd7,
+0x33, 0x33, 0x09, 0x5d, 0x33, 0x33, 0x04, 0xb7, 0xcc, 0xcc, 0x12, 0xbf, 0xcc, 0xcc, 0x02, 0xaf,
+0x0a, 0x0f, 0x7f, 0xff, 0x55, 0x0f, 0xbf, 0xff, 0x0b, 0x0f, 0xdf, 0xff, 0x2d, 0x0f, 0xef, 0xff,
+0x45, 0x0f, 0xf7, 0xff, 0x15, 0x0f, 0xfb, 0xff, 0x4d, 0x0f, 0xfd, 0xff, 0x15, 0x0f, 0xfe, 0xff,
+0x4a, 0x0f, 0xff, 0x7f, 0x0b, 0x0f, 0xff, 0xbf, 0x55, 0x0f, 0xff, 0xdf, 0x0a, 0x2f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/dithering_threshold_high.txt b/tests/golden/dithering_threshold_high.txt
new file mode 100644
index 0000000..cabebd6
--- /dev/null
+++ b/tests/golden/dithering_threshold_high.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x33, 0x33, 0x00, 0x0f, 0x33, 0x33, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f,
+0x33, 0x33, 0x00, 0x0f, 0x33, 0x33, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f,
+0x33, 0x33, 0x00, 0x0f, 0x33, 0x33, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f, 0xcc, 0xcc, 0x00, 0x0f,
+0x00, 0x0f, 0x7f, 0xff, 0x00, 0x0f, 0xbf, 0xff, 0x00, 0x0f, 0xdf, 0xff, 0x00, 0x0f, 0xef, 0xff,
+0x00, 0x0f, 0xf7, 0xff, 0x00, 0x0f, 0xfb, 0xff, 0x00, 0x0f, 0xfd, 0xff, 0x00, 0x0f, 0xfe, 0xff,
+0x00, 0x0f, 0xff, 0x7f, 0x00, 0x0f, 0xff, 0xbf, 0x00, 0x0f, 0xff, 0xdf, 0x00, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/dithering_threshold_low.txt b/tests/golden/dithering_threshold_low.txt
new file mode 100644
index 0000000..d046e7c
--- /dev/null
+++ b/tests/golden/dithering_threshold_low.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xb3, 0x33, 0x0f, 0xff, 0x33, 0x33, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff,
+0x33, 0x33, 0x0f, 0xff, 0x33, 0x33, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff,
+0x33, 0x33, 0x0f, 0xff, 0x33, 0x33, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff, 0xcc, 0xcc, 0x0f, 0xff,
+0xff, 0x0f, 0x7f, 0xff, 0xff, 0x0f, 0xbf, 0xff, 0xff, 0x0f, 0xdf, 0xff, 0xff, 0x0f, 0xef, 0xff,
+0xff, 0x0f, 0xf7, 0xff, 0xff, 0x0f, 0xfb, 0xff, 0xff, 0x0f, 0xfd, 0xff, 0xff, 0x0f, 0xfe, 0xff,
+0xff, 0x0f, 0xff, 0x7f, 0xff, 0x0f, 0xff, 0xbf, 0xff, 0x0f, 0xff, 0xdf, 0xff, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/golden/draw_mode_horizontal565.txt b/tests/golden/draw_mode_horizontal565.txt
new file mode 100644
index 0000000..56b0757
--- /dev/null
+++ b/tests/golden/draw_mode_horizontal565.txt
@@ -0,0 +1,49 @@
+// 'test_pattern', 32x24px
+0xf800, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000,
+0x0000, 0x1082, 0x2104, 0x3186, 0x4228, 0x52aa, 0x632c, 0x73ae, 0x8c51, 0x9cd3, 0xad55, 0xbdd7, 0xce79, 0xdefb, 0xef7d, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
+0xf800, 0xf800, 0xf800, 0xf800, 0x07e0, 0x07e0, 0x07e0, 0x07e0, 0x001f, 0x001f, 0x001f, 0x001f, 0xffff, 0xffff, 0xffff, 0xffff,
+0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0x001f
\ No newline at end of file
diff --git a/tests/golden/draw_mode_horizontal888.txt b/tests/golden/draw_mode_horizontal888.txt
new file mode 100644
index 0000000..e731596
--- /dev/null
+++ b/tests/golden/draw_mode_horizontal888.txt
@@ -0,0 +1,25 @@
+// 'test_pattern', 32x24px
+0x00ff0000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000, 0x00000000, 0x00111111, 0x00222222, 0x00333333, 0x00444444, 0x00555555, 0x00666666, 0x00777777, 0x00888888, 0x00999999, 0x00aaaaaa, 0x00bbbbbb, 0x00cccccc, 0x00dddddd, 0x00eeeeee, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff,
+0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x000000ff
\ No newline at end of file
diff --git a/tests/golden/draw_mode_horizontal_alpha.txt b/tests/golden/draw_mode_horizontal_alpha.txt
new file mode 100644
index 0000000..fe08dcf
--- /dev/null
+++ b/tests/golden/draw_mode_horizontal_alpha.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
\ No newline at end of file
diff --git a/tests/golden/draw_mode_vertical1bit.txt b/tests/golden/draw_mode_vertical1bit.txt
new file mode 100644
index 0000000..790404b
--- /dev/null
+++ b/tests/golden/draw_mode_vertical1bit.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0x0c, 0x0c, 0x03, 0x03, 0xfc, 0xfc, 0xf3, 0xf3, 0x0c, 0x0c, 0x03, 0x03, 0xfc, 0xfc, 0xf3, 0xf3,
+0xe0, 0xd0, 0xb0, 0x70, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, 0xff, 0xff, 0xff, 0x7f
\ No newline at end of file
diff --git a/tests/golden/flip_both.txt b/tests/golden/flip_both.txt
new file mode 100644
index 0000000..c70700f
--- /dev/null
+++ b/tests/golden/flip_both.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x77, 0xff, 0xf0, 0xf0, 0xfb, 0xff, 0xf0, 0xf0, 0xfd, 0xff, 0xf0, 0xf0, 0xfe, 0xff, 0xf0, 0xf0,
+0xff, 0x7f, 0xf0, 0xf0, 0xff, 0xbf, 0xf0, 0xf0, 0xff, 0xdf, 0xf0, 0xf0, 0xff, 0xef, 0xf0, 0xf0,
+0xff, 0xf7, 0xf0, 0xf0, 0xff, 0xfb, 0xf0, 0xf0, 0xff, 0xfd, 0xf0, 0xf0, 0xff, 0xfe, 0xf0, 0xf0,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc
\ No newline at end of file
diff --git a/tests/golden/flip_horizontal.txt b/tests/golden/flip_horizontal.txt
new file mode 100644
index 0000000..d6b33af
--- /dev/null
+++ b/tests/golden/flip_horizontal.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33,
+0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33,
+0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33,
+0xff, 0xfe, 0xf0, 0xf0, 0xff, 0xfd, 0xf0, 0xf0, 0xff, 0xfb, 0xf0, 0xf0, 0xff, 0xf7, 0xf0, 0xf0,
+0xff, 0xef, 0xf0, 0xf0, 0xff, 0xdf, 0xf0, 0xf0, 0xff, 0xbf, 0xf0, 0xf0, 0xff, 0x7f, 0xf0, 0xf0,
+0xfe, 0xff, 0xf0, 0xf0, 0xfd, 0xff, 0xf0, 0xf0, 0xfb, 0xff, 0xf0, 0xf0, 0x77, 0xff, 0xf0, 0xf0
\ No newline at end of file
diff --git a/tests/golden/flip_vertical.txt b/tests/golden/flip_vertical.txt
new file mode 100644
index 0000000..3c0eaf2
--- /dev/null
+++ b/tests/golden/flip_vertical.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x0f, 0x0f, 0xff, 0xee, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0x7f,
+0x0f, 0x0f, 0xfe, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xf7, 0xff,
+0x0f, 0x0f, 0xef, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0x7f, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff
\ No newline at end of file
diff --git a/tests/golden/invert_colors.txt b/tests/golden/invert_colors.txt
new file mode 100644
index 0000000..ba88886
--- /dev/null
+++ b/tests/golden/invert_colors.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00,
+0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00,
+0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00,
+0xf0, 0xf0, 0x80, 0x00, 0xf0, 0xf0, 0x40, 0x00, 0xf0, 0xf0, 0x20, 0x00, 0xf0, 0xf0, 0x10, 0x00,
+0xf0, 0xf0, 0x08, 0x00, 0xf0, 0xf0, 0x04, 0x00, 0xf0, 0xf0, 0x02, 0x00, 0xf0, 0xf0, 0x01, 0x00,
+0xf0, 0xf0, 0x00, 0x80, 0xf0, 0xf0, 0x00, 0x40, 0xf0, 0xf0, 0x00, 0x20, 0xf0, 0xf0, 0x00, 0x11
\ No newline at end of file
diff --git a/tests/golden/kitchen_sink.txt b/tests/golden/kitchen_sink.txt
new file mode 100644
index 0000000..7695d1d
--- /dev/null
+++ b/tests/golden/kitchen_sink.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+80000000804020100804020100000000
+00000000ff7fffff904fb04bb5ffaaff
+0001000208010e010e030d0e8b4f2f1f
+0c0c0303fcfcf3f31cac5323dc7cd3f3
+000000aa009a611ee15eabfdb7ffffff
+cccc3333cccc3333cccc3333cccc3333
diff --git a/tests/golden/output_adafruit_gfx.txt b/tests/golden/output_adafruit_gfx.txt
new file mode 100644
index 0000000..f8c637a
--- /dev/null
+++ b/tests/golden/output_adafruit_gfx.txt
@@ -0,0 +1,19 @@
+const unsigned char epd_bitmapBitmap [] PROGMEM = {
+ // 'test_pattern', 32x24px
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x0f, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xef, 0xff,
+ 0x0f, 0x0f, 0xf7, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfe, 0xff,
+ 0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xee
+};
+
+const GFXbitmapGlyph epd_bitmapGlyphs [] PROGMEM = {
+ { 0, 32, 24, 0, '0' }// 'test_pattern'
+};
+
+const GFXbitmapFont epd_bitmapFont PROGMEM = {
+ (uint8_t *)epd_bitmapBitmap,
+ (GFXbitmapGlyph *)epd_bitmapGlyphs,
+ 1
+};
diff --git a/tests/golden/output_arduino.txt b/tests/golden/output_arduino.txt
new file mode 100644
index 0000000..ef93a3a
--- /dev/null
+++ b/tests/golden/output_arduino.txt
@@ -0,0 +1,15 @@
+// 'test_pattern', 32x24px
+const unsigned char epd_bitmaptest_pattern [] PROGMEM = {
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x0f, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xef, 0xff,
+ 0x0f, 0x0f, 0xf7, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfe, 0xff,
+ 0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xee
+};
+
+// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 112)
+const int epd_bitmap_allArray_LEN = 1;
+const unsigned char* epd_bitmap_allArray[1] = {
+ epd_bitmaptest_pattern
+};
diff --git a/tests/golden/output_arduino_single.txt b/tests/golden/output_arduino_single.txt
new file mode 100644
index 0000000..ebcc9f0
--- /dev/null
+++ b/tests/golden/output_arduino_single.txt
@@ -0,0 +1,9 @@
+const unsigned char epd_bitmap [] PROGMEM = {
+ // 'test_pattern, 32x24px
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+ 0x0f, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xef, 0xff,
+ 0x0f, 0x0f, 0xf7, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfe, 0xff,
+ 0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xee
+};
\ No newline at end of file
diff --git a/tests/golden/remove_zeroes_commas.txt b/tests/golden/remove_zeroes_commas.txt
new file mode 100644
index 0000000..3da87fe
--- /dev/null
+++ b/tests/golden/remove_zeroes_commas.txt
@@ -0,0 +1,2 @@
+// 'test_pattern', 32x24px
+333300ff333300ffcccc00ffcccc00ff333300ff333300ffcccc00ffcccc00ff333300ff333300ffcccc00ffcccc00ff0f0f7fff0f0fbfff0f0fdfff0f0fefff0f0ff7ff0f0ffbff0f0ffdff0f0ffeff0f0fff7f0f0fffbf0f0fffdf0f0fffee
\ No newline at end of file
diff --git a/tests/golden/rotate_180.txt b/tests/golden/rotate_180.txt
new file mode 100644
index 0000000..c70700f
--- /dev/null
+++ b/tests/golden/rotate_180.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 32x24px
+0x77, 0xff, 0xf0, 0xf0, 0xfb, 0xff, 0xf0, 0xf0, 0xfd, 0xff, 0xf0, 0xf0, 0xfe, 0xff, 0xf0, 0xf0,
+0xff, 0x7f, 0xf0, 0xf0, 0xff, 0xbf, 0xf0, 0xf0, 0xff, 0xdf, 0xf0, 0xf0, 0xff, 0xef, 0xf0, 0xf0,
+0xff, 0xf7, 0xf0, 0xf0, 0xff, 0xfb, 0xf0, 0xf0, 0xff, 0xfd, 0xf0, 0xf0, 0xff, 0xfe, 0xf0, 0xf0,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc,
+0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0x33, 0x33, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0x00, 0xcc, 0xcc
\ No newline at end of file
diff --git a/tests/golden/rotate_270.txt b/tests/golden/rotate_270.txt
new file mode 100644
index 0000000..784e6cc
--- /dev/null
+++ b/tests/golden/rotate_270.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 24x32px
+0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
+0xff, 0xfd, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xf7, 0x00, 0x0f, 0xef, 0x00, 0x0f, 0xdf, 0x00, 0x0f,
+0xbf, 0x00, 0x0f, 0x7f, 0x00, 0x0e, 0xff, 0x00, 0x0d, 0xff, 0x00, 0x0b, 0xff, 0x00, 0x07, 0xff,
+0xcc, 0xcf, 0xff, 0xcc, 0xcf, 0xff, 0x33, 0x3f, 0xff, 0x33, 0x3f, 0xff, 0xcc, 0xc0, 0x00, 0xcc,
+0xc0, 0x00, 0x33, 0x30, 0x00, 0x33, 0x30, 0x00, 0xcc, 0xcf, 0xff, 0xcc, 0xcf, 0xff, 0x33, 0x3f,
+0xff, 0x33, 0x3f, 0xff, 0xcc, 0xc0, 0x00, 0xcc, 0xc0, 0x00, 0x33, 0x30, 0x00, 0x33, 0x30, 0x00
\ No newline at end of file
diff --git a/tests/golden/rotate_90.txt b/tests/golden/rotate_90.txt
new file mode 100644
index 0000000..648e5b0
--- /dev/null
+++ b/tests/golden/rotate_90.txt
@@ -0,0 +1,7 @@
+// 'test_pattern', 24x32px
+0x00, 0x0c, 0xcc, 0x00, 0x0c, 0xcc, 0x00, 0x03, 0x33, 0x00, 0x03, 0x33, 0xff, 0xfc, 0xcc, 0xff,
+0xfc, 0xcc, 0xff, 0xf3, 0x33, 0xff, 0xf3, 0x33, 0x00, 0x0c, 0xcc, 0x00, 0x0c, 0xcc, 0x00, 0x03,
+0x33, 0x00, 0x03, 0x33, 0xff, 0xfc, 0xcc, 0xff, 0xfc, 0xcc, 0xff, 0xf3, 0x33, 0xff, 0xf3, 0x33,
+0xff, 0xe0, 0x00, 0xff, 0xd0, 0x00, 0xff, 0xb0, 0x00, 0xff, 0x70, 0x00, 0xfe, 0xf0, 0x00, 0xfd,
+0xf0, 0x00, 0xfb, 0xf0, 0x00, 0xf7, 0xf0, 0x00, 0xef, 0xff, 0xff, 0xdf, 0xff, 0xff, 0xbf, 0xff,
+0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff
\ No newline at end of file
diff --git a/tests/golden/scale_fit_larger_canvas.txt b/tests/golden/scale_fit_larger_canvas.txt
new file mode 100644
index 0000000..c5af95e
--- /dev/null
+++ b/tests/golden/scale_fit_larger_canvas.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e,
+0x38, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff,
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71,
+0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff,
+0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x1f, 0xff, 0x03, 0xc0, 0x3f, 0x3f,
+0xff, 0xff, 0x03, 0xf0, 0x3f, 0xbf, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xdf, 0xff, 0xff, 0x03, 0xf0,
+0x3f, 0xef, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xf7, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfb, 0xff, 0xff,
+0x03, 0xf0, 0x3f, 0xfd, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfe, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xff,
+0x7f, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xbf, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xdf, 0xff, 0x03, 0xf0,
+0x3f, 0xff, 0xef, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xf7, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xfb, 0xff,
+0x03, 0xf0, 0x3f, 0xff, 0xfd, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xfe, 0xff, 0x03, 0xf0, 0x3f, 0xff,
+0xff, 0x7f, 0x03, 0xf0, 0x3f, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
\ No newline at end of file
diff --git a/tests/golden/scale_stretch_h_larger_canvas.txt b/tests/golden/scale_stretch_h_larger_canvas.txt
new file mode 100644
index 0000000..ee57f8f
--- /dev/null
+++ b/tests/golden/scale_stretch_h_larger_canvas.txt
@@ -0,0 +1,10 @@
+// 'test_pattern', 48x24px
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71,
+0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff,
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0x03, 0xf0, 0x3f, 0x3f, 0xff, 0xff, 0x03, 0xf0,
+0x3f, 0x9f, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xe7, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xf3, 0xff, 0xff,
+0x03, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0x03, 0xf0, 0x3f, 0xff,
+0x9f, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xcf, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xf3, 0xff, 0x03, 0xf0,
+0x3f, 0xff, 0xf9, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xfe, 0x7f, 0x03, 0xf0, 0x3f, 0xff, 0xff, 0x3e
\ No newline at end of file
diff --git a/tests/golden/scale_stretch_larger_canvas.txt b/tests/golden/scale_stretch_larger_canvas.txt
new file mode 100644
index 0000000..a85719f
--- /dev/null
+++ b/tests/golden/scale_stretch_larger_canvas.txt
@@ -0,0 +1,16 @@
+// 'test_pattern', 48x40px
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e,
+0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff,
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0x1c, 0x71,
+0xc6, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff,
+0x1c, 0x71, 0xc7, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00,
+0x0f, 0xff, 0xe3, 0x8e, 0x38, 0x00, 0x3f, 0xff, 0x03, 0x80, 0x3f, 0x3f, 0xff, 0xff, 0x03, 0xf0,
+0x3f, 0x3f, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0x9f, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xef, 0xff, 0xff,
+0x03, 0xf0, 0x3f, 0xe7, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xf3, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfb,
+0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0x03, 0xf0, 0x3f, 0xfe, 0xff, 0xff, 0x03, 0xf0,
+0x3f, 0xff, 0x7f, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xbf, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0x9f, 0xff,
+0x03, 0xf0, 0x3f, 0xff, 0xcf, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xf7, 0xff, 0x03, 0xf0, 0x3f, 0xff,
+0xf3, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xf9, 0xff, 0x03, 0xf0, 0x3f, 0xff, 0xfd, 0xff, 0x03, 0xf0,
+0x3f, 0xff, 0xfe, 0x7f, 0x03, 0xf0, 0x3f, 0xff, 0xff, 0x7e, 0x03, 0xf0, 0x3f, 0xff, 0xff, 0x3e
\ No newline at end of file
diff --git a/tests/golden/scale_stretch_v_larger_canvas.txt b/tests/golden/scale_stretch_v_larger_canvas.txt
new file mode 100644
index 0000000..93d9734
--- /dev/null
+++ b/tests/golden/scale_stretch_v_larger_canvas.txt
@@ -0,0 +1,11 @@
+// 'test_pattern', 32x40px
+0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff,
+0xcc, 0xcc, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0xff,
+0x33, 0x33, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0xcc, 0x03, 0xff,
+0x0c, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0x7f, 0xff, 0x0f, 0x0f, 0xbf, 0xff, 0x0f, 0x0f, 0xdf, 0xff,
+0x0f, 0x0f, 0xdf, 0xff, 0x0f, 0x0f, 0xef, 0xff, 0x0f, 0x0f, 0xef, 0xff, 0x0f, 0x0f, 0xf7, 0xff,
+0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfb, 0xff, 0x0f, 0x0f, 0xfd, 0xff, 0x0f, 0x0f, 0xfd, 0xff,
+0x0f, 0x0f, 0xfe, 0xff, 0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0x7f, 0x0f, 0x0f, 0xff, 0xbf,
+0x0f, 0x0f, 0xff, 0xbf, 0x0f, 0x0f, 0xff, 0xdf, 0x0f, 0x0f, 0xff, 0xee, 0x0f, 0x0f, 0xff, 0xee
\ No newline at end of file
diff --git a/tests/requirements.txt b/tests/requirements.txt
new file mode 100644
index 0000000..d662229
--- /dev/null
+++ b/tests/requirements.txt
@@ -0,0 +1,2 @@
+playwright
+pillow
diff --git a/tests/test_conversions.py b/tests/test_conversions.py
new file mode 100644
index 0000000..b050203
--- /dev/null
+++ b/tests/test_conversions.py
@@ -0,0 +1,293 @@
+#!/usr/bin/env python3
+"""Test suite for image2cpp's conversion output.
+
+Controls the real index.html in a headless browser (Playwright), feeds it the
+deterministic test-pattern image, exercises every conversion option through
+the actual UI, and compares the generated code output against saved golden
+files. Because it runs the real app (not a reimplementation of the
+conversion logic), any change to js/script.js or js/dithering.js that
+changes output is caught.
+
+Usage:
+ python tests/test_conversions.py # run tests, compare to golden
+ python tests/test_conversions.py --diff # print diff on failing scenarios
+ python tests/test_conversions.py --update # (re)generate golden files
+"""
+import argparse
+import difflib
+import re
+import sys
+from pathlib import Path
+
+from playwright.sync_api import sync_playwright
+
+ROOT = Path(__file__).parent.parent
+INDEX_HTML = ROOT / "index.html"
+TEST_IMAGE = Path(__file__).parent / "fixtures" / "test_pattern.png"
+GOLDEN_DIR = Path(__file__).parent / "golden"
+
+NATIVE_WIDTH, NATIVE_HEIGHT = 32, 24
+
+# Full set of controllable options and their app defaults.
+BASE_SETTINGS = {
+ "drawMode": "horizontal1bit",
+ "outputFormat": "plain",
+ "backgroundColor": "white",
+ "invertColors": False,
+ "ditheringMode": 0,
+ "ditheringThreshold": 128,
+ "scale": 1,
+ "centerHorizontally": False,
+ "centerVertically": False,
+ "rotation": 0,
+ "flipHorizontally": False,
+ "flipVertically": False,
+ "bitswap": False,
+ "removeZeroesCommas": False,
+}
+
+# (scenario name, overrides on top of BASE_SETTINGS, optional canvas resize)
+SCENARIOS = [
+ ("default", {}, None),
+ ("draw_mode_vertical1bit", {"drawMode": "vertical1bit"}, None),
+ ("draw_mode_horizontal565", {"drawMode": "horizontal565"}, None),
+ ("draw_mode_horizontal888", {"drawMode": "horizontal888"}, None),
+ ("draw_mode_horizontal_alpha", {"drawMode": "horizontalAlpha"}, None),
+ ("output_arduino", {"outputFormat": "arduino"}, None),
+ ("output_arduino_single", {"outputFormat": "arduino_single"}, None),
+ ("output_adafruit_gfx", {"outputFormat": "adafruit_gfx"}, None),
+ ("invert_colors", {"invertColors": True}, None),
+ ("flip_horizontal", {"flipHorizontally": True}, None),
+ ("flip_vertical", {"flipVertically": True}, None),
+ ("flip_both", {"flipHorizontally": True, "flipVertically": True}, None),
+ ("rotate_90", {"rotation": 90}, None),
+ ("rotate_180", {"rotation": 180}, None),
+ ("rotate_270", {"rotation": 270}, None),
+ ("dithering_bayer", {"ditheringMode": 1}, None),
+ ("dithering_floyd_steinberg", {"ditheringMode": 2}, None),
+ ("dithering_atkinson", {"ditheringMode": 3}, None),
+ ("dithering_threshold_low", {"ditheringThreshold": 64}, None),
+ ("dithering_threshold_high", {"ditheringThreshold": 200}, None),
+ ("bitswap", {"bitswap": True}, None),
+ ("remove_zeroes_commas", {"removeZeroesCommas": True}, None),
+ # scale=1 (original) on a canvas larger than the image so the
+ # background actually shows through in the margins.
+ ("background_white_larger_canvas", {"backgroundColor": "white"}, (48, 40)),
+ ("background_black", {"backgroundColor": "black"}, (48, 40)),
+ # RGB channels of a transparent background are zero-initialized, same as
+ # an explicit black background, so the two are indistinguishable under
+ # the 1-bit draw modes (which ignore alpha). Use the alpha draw mode
+ # here so transparency is actually used.
+ (
+ "background_transparent",
+ {"backgroundColor": "transparent", "drawMode": "horizontalAlpha"},
+ (48, 40),
+ ),
+ ("scale_fit_larger_canvas", {"scale": 2}, (48, 40)),
+ ("scale_stretch_larger_canvas", {"scale": 3}, (48, 40)),
+ ("scale_stretch_h_larger_canvas", {"scale": 4}, (48, NATIVE_HEIGHT)),
+ ("scale_stretch_v_larger_canvas", {"scale": 5}, (NATIVE_WIDTH, 40)),
+ (
+ "center_both_larger_canvas",
+ {"centerHorizontally": True, "centerVertically": True},
+ (48, 40),
+ ),
+ (
+ "kitchen_sink",
+ {
+ "drawMode": "vertical1bit",
+ "invertColors": True,
+ "flipHorizontally": True,
+ "flipVertically": True,
+ "bitswap": True,
+ "removeZeroesCommas": True,
+ "ditheringMode": 2,
+ },
+ None,
+ ),
+]
+
+
+def reset_canvas_size(page, width, height):
+ """Set canvas size through the real width/height text inputs."""
+ page.fill("#screenWidth", str(width))
+ page.fill("#screenHeight", str(height))
+
+
+def apply_settings(page, settings):
+ page.select_option("#drawMode", settings["drawMode"])
+ page.select_option("#outputFormat", settings["outputFormat"])
+ page.check(f"#backgroundColor{settings['backgroundColor'].capitalize()}")
+ set_checkbox(page, "#invertColors", settings["invertColors"])
+ page.select_option("#ditheringMode", str(settings["ditheringMode"]))
+ page.fill("#ditheringThreshold", str(settings["ditheringThreshold"]))
+ page.select_option("#scale", str(settings["scale"]))
+ set_checkbox(page, "#centerHorizontally", settings["centerHorizontally"])
+ set_checkbox(page, "#centerVertically", settings["centerVertically"])
+ page.select_option("#rotation", str(settings["rotation"]))
+ set_checkbox(page, "#flipHorizontally", settings["flipHorizontally"])
+ set_checkbox(page, "#flipVertically", settings["flipVertically"])
+ set_checkbox(page, "#bitswap", settings["bitswap"])
+ if settings["outputFormat"] == "plain":
+ set_checkbox(page, "#removeZeroesCommas", settings["removeZeroesCommas"])
+
+
+def set_checkbox(page, selector, checked):
+ if checked:
+ page.check(selector)
+ else:
+ page.uncheck(selector)
+
+
+def run_scenario(page, name, overrides, resize):
+ settings = {**BASE_SETTINGS, **overrides}
+ reset_canvas_size(page, *(resize or (NATIVE_WIDTH, NATIVE_HEIGHT)))
+ apply_settings(page, settings)
+ # Force a redraw with the final settings state regardless of which
+ # controls' change events actually fired (some may be no-ops if the
+ # value didn't change from the previous scenario).
+ page.evaluate("updateAllImages()")
+ page.click("text=Generate code")
+ return page.input_value("#code-output")
+
+
+def roundtrip_eligible(settings):
+ """Only plain-format, non-bitswapped 1-bit output is re-importable via the
+ "Paste byte array" box: other draw modes aren't supported by the parser,
+ and bitswap/removeZeroesCommas mangle the byte stream so it can't be read
+ back (bitswap reorders bits with no importer to undo it; removeZeroesCommas
+ drops the separators the parser splits on)."""
+ return (
+ settings["drawMode"] in ("horizontal1bit", "vertical1bit")
+ and settings["outputFormat"] == "plain"
+ and not settings["bitswap"]
+ and not settings["removeZeroesCommas"]
+ )
+
+
+def run_roundtrip(page, output, draw_mode, width, height):
+ """Paste a generated byte array back in, import it, and re-export it,
+ same steps a user would take to sanity-check their array. Uses a fresh
+ page load, so the reimported canvas is the only pixel source, nothing
+ left over from a previous scenario."""
+ page.goto(INDEX_HTML.as_uri())
+ # window.onload defaults outputFormat to "arduino"; force it back to plain
+ # to match the format the scenario was exported in.
+ page.select_option("#outputFormat", "plain")
+ page.fill("#byte-input", output)
+ page.fill("#text-input-width", str(width))
+ page.fill("#text-input-height", str(height))
+ direction = "horizontal" if draw_mode == "horizontal1bit" else "vertical"
+ page.click(f"text=Read as {direction}")
+ # The imported canvas is only backed by a real
once its data-URL
+ # finishes loading (async); switching draw mode before that swap
+ # completes triggers a redraw from the still-blank placeholder image and
+ # wipes the canvas. Wait for the swap so this matches how a person would
+ # naturally pause between clicking "Read as..." and changing the dropdown.
+ page.wait_for_function("images.first().img.src")
+ if direction == "vertical":
+ page.select_option("#drawMode", "vertical1bit")
+ page.click("text=Generate code")
+ return page.input_value("#code-output")
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--update", action="store_true", help="(re)generate golden files instead of comparing"
+ )
+ parser.add_argument(
+ "--diff", action="store_true", help="print a diff against golden output on failure"
+ )
+ args = parser.parse_args()
+
+ if not TEST_IMAGE.exists():
+ print(f"Test image missing at {TEST_IMAGE}; run generate_test_image.py first")
+ sys.exit(1)
+
+ GOLDEN_DIR.mkdir(parents=True, exist_ok=True)
+
+ failures = []
+ with sync_playwright() as p:
+ browser = p.chromium.launch()
+ page = browser.new_page()
+ page.goto(INDEX_HTML.as_uri())
+ page.set_input_files("#file-input", str(TEST_IMAGE))
+ # Wait for the app to finish loading the image and create its canvas.
+ page.wait_for_selector("#image-size-settings li")
+
+ for name, overrides, resize in SCENARIOS:
+ settings = {**BASE_SETTINGS, **overrides}
+ output = run_scenario(page, name, overrides, resize)
+ golden_path = GOLDEN_DIR / f"{name}.txt"
+
+ if args.update:
+ golden_path.write_text(output)
+ print(f"wrote {name}")
+ continue
+
+ if not golden_path.exists():
+ failures.append(f"{name}: no golden file (run with --update first)")
+ print(f"MISSING {name}")
+ continue
+
+ expected = golden_path.read_text()
+ if output != expected:
+ failures.append(name)
+ print(f"FAIL {name}")
+ if args.diff:
+ diff = difflib.unified_diff(
+ expected.splitlines(keepends=True),
+ output.splitlines(keepends=True),
+ fromfile=f"{name} (golden)",
+ tofile=f"{name} (actual)",
+ )
+ sys.stdout.writelines(diff)
+ continue
+
+ print(f"ok {name}")
+
+ if roundtrip_eligible(settings):
+ width, height = resize or (NATIVE_WIDTH, NATIVE_HEIGHT)
+ roundtripped = run_roundtrip(page, output, settings["drawMode"], width, height)
+ # The re-imported image has no filename to derive a glyph
+ # comment from, so plain output drops its leading "// name,
+ # WxHpx" comment line; strip it before comparing byte data.
+ comparable_output = re.sub(r"^//[^\n]*\n", "", output)
+ if roundtripped != comparable_output:
+ failures.append(f"{name}: round-trip mismatch")
+ print(f"FAIL {name} (round-trip)")
+ if args.diff:
+ diff = difflib.unified_diff(
+ comparable_output.splitlines(keepends=True),
+ roundtripped.splitlines(keepends=True),
+ fromfile=f"{name} (exported)",
+ tofile=f"{name} (re-imported+exported)",
+ )
+ sys.stdout.writelines(diff)
+ else:
+ print(f"ok {name} (round-trip)")
+
+ # The page was reloaded for the round-trip check; reload the
+ # test image so the next scenario has its canvas back.
+ page.goto(INDEX_HTML.as_uri())
+ page.set_input_files("#file-input", str(TEST_IMAGE))
+ page.wait_for_selector("#image-size-settings li")
+
+ browser.close()
+
+ if args.update:
+ print(f"\nWrote {len(SCENARIOS)} golden files to {GOLDEN_DIR}")
+ return
+
+ if failures:
+ print(f"\n{len(failures)} of {len(SCENARIOS)} scenarios failed:")
+ for f in failures:
+ print(f" - {f}")
+ sys.exit(1)
+
+ print(f"\nAll {len(SCENARIOS)} scenarios match golden output.")
+
+
+if __name__ == "__main__":
+ main()