Mercurial > hg > dmlib
diff tools/lib64gfx.h @ 1775:4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 12 Jun 2018 17:12:48 +0300 |
parents | 88354355b8e1 |
children | 5ea4713e9e0f |
line wrap: on
line diff
--- a/tools/lib64gfx.h Tue Jun 12 15:36:00 2018 +0300 +++ b/tools/lib64gfx.h Tue Jun 12 17:12:48 2018 +0300 @@ -186,9 +186,23 @@ typedef DMC64EncDecOp DMC64EncDecOpList[D64_MAX_ENCDEC_OPS]; +typedef struct +{ + int type; // Type flags, see D64_FMT_* + int width, height; // Width and height in pixels + int chWidth, chHeight; // Width and height in charblocks + + int (*convertFrom)(DMImage *, const DMC64Image *, const DMC64ImageFormat *fmt); + int (*convertTo)(DMC64Image *, const DMImage *, const DMC64ImageFormat *fmt); + + DMC64GetPixelFunc getPixel; + + DMC64EncDecOpList encdecOps; +} DMC64ImageCommonFormat; + + typedef struct _DMC64ImageFormat { - int type; // Type flags, see D64_FMT_* char *fext; // Filename extension char *name; // Format description/name @@ -197,20 +211,12 @@ int flags; // DM_FMT_* flags, see libgfx.h - int width, height; // Width and height in pixels - int chWidth, chHeight; // Width and height in charblocks - - int (*probe)(const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt); + int (*probe)(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt); - int (*decode)(DMC64Image *img, const DMGrowBuf *buf, const struct _DMC64ImageFormat *fmt); - int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const struct _DMC64ImageFormat *fmt); + int (*decode)(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt); + int (*encode)(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); - int (*convertFrom)(DMImage *, const DMC64Image *, const struct _DMC64ImageFormat *fmt); - int (*convertTo)(DMC64Image *, const DMImage *, const struct _DMC64ImageFormat *fmt); - - DMC64GetPixelFunc getPixel; - - const DMC64EncDecOpList encdecOps, *encdecOpsRef; + DMC64ImageCommonFormat formatDef, *format; } DMC64ImageFormat; @@ -273,13 +279,14 @@ // Global variables // extern DMColor dmDefaultC64Palette[C64_NCOLORS]; -extern const DMC64ImageFormat dmC64ImageFormats[]; +extern DMC64ImageFormat dmC64ImageFormats[]; extern const int ndmC64ImageFormats; // // Miscellaneous functions // +void dmC64InitializeFormats(void); int dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt); char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng); @@ -323,6 +330,7 @@ void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg); void dmFinishRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg); + int dmGenericRLEOutputRun(DMGrowBuf *dst, const DMCompParams *cfg, const Uint8 data, const unsigned int count); int dmEncodeGenericRLESequence(DMGrowBuf *dst, const Uint8 data, const unsigned int count, const DMCompParams *cfg); @@ -384,8 +392,7 @@ static inline const DMC64EncDecOp * fmtGetEncDecOp(const DMC64ImageFormat *fmt, const int index) { - // Ooh .. look at that beaauuuutiful deref .. - return fmt->encdecOpsRef != NULL ? &(* (fmt->encdecOpsRef))[index] : &fmt->encdecOps[index]; + return &fmt->format->encdecOps[index]; }