From d4a0ff9ac8e6293de9f33dde393eaa46e1b78396 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 11 Jun 2017 22:01:11 -0400 Subject: [PATCH] draw_image can now draw images with x<0, fixes #433 this isn't used at all in the source --- src/graphics/RasterDrawMethods.inl | 42 +++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl index 31c3c60ef..f19ef898b 100644 --- a/src/graphics/RasterDrawMethods.inl +++ b/src/graphics/RasterDrawMethods.inl @@ -445,26 +445,48 @@ void PIXELMETHODS_CLASS::clearrect(int x, int y, int w, int h) void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int a) { - int i, j, r, g, b; - if (!img) return; - if(y + h > VIDYRES) h = ((VIDYRES)-y)-1; //Adjust height to prevent drawing off the bottom + int startX = 0; + if (!img) + return; + // Adjust height to prevent drawing off the bottom + if (y + h > VIDYRES) + h = ((VIDYRES)-y)-1; + // Too big + if (x + w > VIDXRES) + return; + + // Starts off the top of the screen, adjust if (y < 0 && -y < h) { img += -y*w; h += y; y = 0; } - if(!h || y < 0) return; - if(a >= 255) - for (j=0; j= 255) + for (int j = 0; j < h; j++) + { + img += startX; + for (int i = startX; i < w; i++) { vid[(y+j)*(VIDXRES)+(x+i)] = *img; img++; } + } else - for (j=0; j