Mercurial > hg > dmlib
diff tools/libgfx.h @ 2094:4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
for future work on supporting non-indexed/paletted images. It is still messy.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Mar 2019 09:56:47 +0200 |
parents | d17512dbb4ef |
children | 80786a28caf0 |
line wrap: on
line diff
--- a/tools/libgfx.h Thu Feb 28 12:32:07 2019 +0200 +++ b/tools/libgfx.h Tue Mar 05 09:56:47 2019 +0200 @@ -70,6 +70,14 @@ }; +typedef struct +{ + int ncolors; // number of colors in palette, if any + int ctransp; // transparency color index, -1 if none + DMColor *colors;// colors +} DMPalette; + + // Bitmapped image struct typedef struct { @@ -80,10 +88,8 @@ float aspect; // aspect ratio (vert / horiz), <= 0 if not set - int ncolors; // number of colors in palette, if any - int ctransp; // transparency color index BOOL constpal; // is the palette a const? - DMColor *pal; // pointer to palette struct, NULL if no palette + DMPalette *pal; // pointer to palette struct, NULL if no palette size_t size; Uint8 *data; @@ -124,9 +130,11 @@ int dmImageGetBitsPerPixel(const int format); int dmImageProbeGeneric(const Uint8 *buf, const size_t len, const DMImageFormat **fmt, int *index); -BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); -BOOL dmPaletteAlloc(DMColor **ppal, int ncolors, int ctransp); -BOOL dmImagePaletteAlloc(DMImage *img, int ncolors, int ctransp); +BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha); +int dmPaletteAlloc(DMPalette **ppal, const int ncolors, const int ctransp); +int dmPaletteResize(DMPalette **ppal, const int ncolors); +void dmPaletteFree(DMPalette *pal); +int dmPaletteCopy(DMPalette **pdst, const DMPalette *src); int dmWriteImageData(const DMImage *img, void *cbdata,