From ea96b298b36480787a1ff16d1098b258fd9068f6 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 4 Dec 2021 16:30:55 -0500 Subject: [PATCH] less wankly --- src/image.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/src/image.c b/src/image.c index c748088..683e922 100644 --- a/src/image.c +++ b/src/image.c @@ -499,26 +499,19 @@ static void tile_copy(cammy_image *dest, size_t x, y; - for (y=0; y < from->height; y++) { - if (to->y + y > dest->height) { + for (y=from->y; yy + from->height; y++) { + if (y > dest->height) { break; } - for (x=0; x < from->width; x++) { - uint8_t value = tile_read((cammy_tile *)src->buf, - from->x + x, - from->y + y, - src->width); + for (x=from->x; xx + from->width; x++) { + uint8_t value = tile_read((cammy_tile *)src->buf, x, y, src->width); if (to->x + x > dest->width) { break; } - tile_write((cammy_tile *)dest->buf, - to->x + x, - to->y + y, - dest->width, - value); + tile_write((cammy_tile *)dest->buf, x, y, dest->width, value); } } } @@ -532,15 +525,15 @@ static void bitmap_copy(cammy_image *dest, int channels_dest = depth_channels(dest->depth), channels_src = depth_channels(src->depth); - for (y=0; y < from->height; y++) { - if (to->y + y > dest->height) { + for (y=from->y; yy + from->height; y++) { + if (y > dest->height) { break; } - for (x=0; x < from->width; x++) { + for (x=from->x; xx + from->width; x++) { uint8_t r, g, b; - if (to->x + x > from->width) { + if (x > from->width) { break; } @@ -567,15 +560,15 @@ static void bitmap_copy_to_tile(cammy_image *dest, int channels = depth_channels(src->depth); - for (y=0; y < from->height; y++) { - if (to->y + y > dest->height) { + for (y=from->y; yy + from->height; y++) { + if (y > dest->height) { break; } - for (x=0; x < from->width; x++) { + for (x=from->x; xx + from->width; x++) { uint8_t r, g, b; - if (to->x + x > from->width) { + if (x > from->width) { break; } @@ -603,26 +596,23 @@ static void tile_copy_to_bitmap(cammy_image *dest, int channels = depth_channels(dest->depth); - for (y=0; y < from->height; y++) { - if (to->y + y > dest->height) { + for (y=from->y; yy + from->height; y++) { + if (y > dest->height) { break; } - for (x=0; x < from->width; x++) { + for (x=from->x; xx + from->width; x++) { uint8_t c; - if (to->x + x > from->width) { + if (x > from->width) { break; } - c = tile_read((cammy_tile *)src->buf, - from->x + x, - from->y + y, - from->width); + c = tile_read((cammy_tile *)src->buf, x, y, from->width); bitmap_write(dest->buf, - from->x + x, - from->y + y, + x, + y, from->width, src->palette[c].r, src->palette[c].g,