summaryrefslogtreecommitdiff
path: root/src/px.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/px.c')
-rw-r--r--src/px.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/px.c b/src/px.c
index d7c8650..56c5706 100644
--- a/src/px.c
+++ b/src/px.c
@@ -57,7 +57,7 @@ pxDeinit(void)
}
int
-pxFlip(void)
+pxFlip(PxRawCol (*fs)(PxRawCol c, int x, int y))
{
uint8_t *pixels = NULL;
int pitch = 0;
@@ -72,9 +72,12 @@ pxFlip(void)
PxCol col = pxbuf[x + y * PX_WIDTH];
if (pxpal[col].spal)
col = pxpal[col].spal - 1;
- pixels[ix + y * pitch + 0] = pxpal[col].b;
- pixels[ix + y * pitch + 1] = pxpal[col].g;
- pixels[ix + y * pitch + 2] = pxpal[col].r;
+ PxRawCol raw = pxRawCol(col);
+ if (fs != NULL)
+ raw = fs(raw, x, y);
+ pixels[ix + y * pitch + 0] = raw.a[2];
+ pixels[ix + y * pitch + 1] = raw.a[1];
+ pixels[ix + y * pitch + 2] = raw.a[0];
pixels[ix + y * pitch + 3] = 255;
}
}
@@ -284,9 +287,20 @@ pxCol(uint8_t r, uint8_t g, uint8_t b)
if (pal->r == r && pal->g == g && pal->b == b)
return i;
}
+ assert(0);
return -1;
}
+PxRawCol
+pxRawCol(PxCol c)
+{
+ return (PxRawCol){{
+ pxpal[c].r,
+ pxpal[c].g,
+ pxpal[c].b
+ }};
+}
+
int
pxMin(int a, int b)
{