use mode structs in Draw.c

This commit is contained in:
Yay295 2024-04-21 19:20:58 -05:00
parent da808ce436
commit 2beb5fa67c

View File

@ -68,7 +68,7 @@ typedef void (*hline_handler)(Imaging, int, int, int, int);
static inline void
point8(Imaging im, int x, int y, int ink) {
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
im->image8[y][x * 2] = (UINT8)(ink >> 8);
im->image8[y][x * 2 + 1] = (UINT8)ink;
@ -118,7 +118,7 @@ hline8(Imaging im, int x0, int y0, int x1, int ink) {
x1 = im->xsize - 1;
}
if (x0 <= x1) {
pixelwidth = strncmp(im->mode, "I;16", 4) == 0 ? 2 : 1;
pixelwidth = strncmp(im->mode->name, "I;16", 4) == 0 ? 2 : 1;
memset(
im->image8[y0] + x0 * pixelwidth, (UINT8)ink, (x1 - x0 + 1) * pixelwidth
);
@ -659,17 +659,17 @@ DRAW draw32rgba = {point32rgba, hline32rgba, line32rgba, polygon32rgba};
/* Interface */
/* -------------------------------------------------------------------- */
#define DRAWINIT() \
if (im->image8) { \
draw = &draw8; \
if (strncmp(im->mode, "I;16", 4) == 0) { \
ink = INK16(ink_); \
} else { \
ink = INK8(ink_); \
} \
} else { \
draw = (op) ? &draw32rgba : &draw32; \
memcpy(&ink, ink_, sizeof(ink)); \
#define DRAWINIT() \
if (im->image8) { \
draw = &draw8; \
if (strncmp(im->mode->name, "I;16", 4) == 0) { \
ink = INK16(ink_); \
} else { \
ink = INK8(ink_); \
} \
} else { \
draw = (op) ? &draw32rgba : &draw32; \
memcpy(&ink, ink_, sizeof(ink)); \
}
int