use mode structs in Draw.c

This commit is contained in:
eyedav 2025-07-19 15:37:03 +02:00
parent 9bf3495898
commit bcfe5f2172

View File

@ -68,7 +68,7 @@ typedef void (*hline_handler)(Imaging, int, int, int, int, Imaging);
static inline void static inline void
point8(Imaging im, int x, int y, int ink) { point8(Imaging im, int x, int y, int ink) {
if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) { if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) {
if (strncmp(im->mode, "I;16", 4) == 0) { if (strncmp(im->mode->name, "I;16", 4) == 0) {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
im->image8[y][x * 2] = (UINT8)(ink >> 8); im->image8[y][x * 2] = (UINT8)(ink >> 8);
im->image8[y][x * 2 + 1] = (UINT8)ink; im->image8[y][x * 2 + 1] = (UINT8)ink;
@ -117,13 +117,13 @@ hline8(Imaging im, int x0, int y0, int x1, int ink, Imaging mask) {
} }
if (x0 <= x1) { if (x0 <= x1) {
int bigendian = -1; int bigendian = -1;
if (strncmp(im->mode, "I;16", 4) == 0) { if (isModeI16(im->mode)) {
bigendian = bigendian =
( (
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
strcmp(im->mode, "I;16") == 0 || strcmp(im->mode, "I;16L") == 0 im->mode == IMAGING_MODE_I_16 || im->mode == IMAGING_MODE_I_16L
#else #else
strcmp(im->mode, "I;16B") == 0 im->mode == IMAGING_MODE_I_16B
#endif #endif
) )
? 1 ? 1
@ -672,17 +672,17 @@ DRAW draw32rgba = {point32rgba, hline32rgba, line32rgba};
/* Interface */ /* Interface */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
#define DRAWINIT() \ #define DRAWINIT() \
if (im->image8) { \ if (im->image8) { \
draw = &draw8; \ draw = &draw8; \
if (strncmp(im->mode, "I;16", 4) == 0) { \ if (strncmp(im->mode->name, "I;16", 4) == 0) { \
ink = INK16(ink_); \ ink = INK16(ink_); \
} else { \ } else { \
ink = INK8(ink_); \ ink = INK8(ink_); \
} \ } \
} else { \ } else { \
draw = (op) ? &draw32rgba : &draw32; \ draw = (op) ? &draw32rgba : &draw32; \
memcpy(&ink, ink_, sizeof(ink)); \ memcpy(&ink, ink_, sizeof(ink)); \
} }
int int