summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-01-15 14:35:23 +1100
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-01-15 14:35:23 +1100
commita48603e468359e347e5478047feed3fe35bcc396 (patch)
treec78ebe3bb227dec574809d3ba3a0197702d37582 /include
parentf2ec68946937ac2ca27508ffd34d4530c8af6254 (diff)
feat(png): Add image data fields to PNG context struct
Diffstat (limited to 'include')
-rw-r--r--include/tinyff/image/png.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h
index a77092a..c9f3378 100644
--- a/include/tinyff/image/png.h
+++ b/include/tinyff/image/png.h
@@ -15,9 +15,13 @@ static const unsigned char PNG_SIGNATURE[8] = {
0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A
};
+typedef enum {
+ FF_PNG_MODE_NONE = 0,
+ FF_PNG_MODE_DIRECT_COLOR, // pixels
+ FF_PNG_MODE_PALETTE // palette
+} ff_png_mode;
typedef struct {
-
// Raw file handle
FILE *raw;
@@ -30,17 +34,21 @@ typedef struct {
uint8_t color_type;
// Image data
- //
- // It's weird because theres actually multiple ways to store it
- // we need to be able to have the same fields to hold the data
- // or have two seperate fields and a flag pointing to which one is actually
- // being used sorta because of palette vs direct color
- // so until i find a better way than holding this crappy project together with duct tape
- // im just gonna use two fields and a flag
- // but again with bit depths and color types this can get really messy really fast
- // and i have NO idea what what type direct color data should be stored as.
- // god... i hate png
+
+ ff_png_mode image_mode;
+
+ union {
+ uint8_t* pixels;
+ uint8_t* imap; // Map of all the indices defines in PLTE
+ } data;
+
+ // Palette (if needed; can be left NULL if it's direct color)
+ uint8_t* palette;
+ uint32_t palette_size;
+
bool valid;
+ ff_result last_error;
+
} ff_png_ctx;