From 23c0cda24324198b30906ab059641b67fa9d0397 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 16 Jan 2000 03:56:14 +0000 Subject: [PATCH] Fixed bugs in raster.c code. Fixes bad icon image with some images. --- wrlib/raster.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/wrlib/raster.c b/wrlib/raster.c index 47038739..87b761ef 100644 --- a/wrlib/raster.c +++ b/wrlib/raster.c @@ -289,17 +289,19 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width, assert(sy + height <= src->height); assert(sx + width <= src->width); - + if (width > image->width - dx) + width = image->width - dx; + if (height > image->height - dy) height = image->height - dy; if (!HAS_ALPHA(src)) { if (!HAS_ALPHA(image)) { - swi = (src->width - width) * 3; - dwi = (image->width - width) * 3; + swi = src->width * 3; + dwi = image->width * 3; - d = image->data + dy*(int)image->width*3 + dx; - s = src->data + sy*(int)src->width*3 + sx; + s = src->data + (sy*(int)src->width + sx) * 3; + d = image->data + (dy*(int)image->width + dx) * 3; for (y=0; y < height; y++) { memcpy(d, s, width*3); @@ -310,8 +312,8 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width, swi = (src->width - width) * 3; dwi = (image->width - width) * 4; - d = image->data + dy*(int)image->width*4 + dx; - s = src->data + sy*(int)src->width*3 + sx; + s = src->data + (sy*(int)src->width + sx) * 3; + d = image->data + (dy*(int)image->width + dx) * 4; for (y=0; y < height; y++) { for (x=0; x < width; x++) { @@ -328,13 +330,13 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width, int dalpha = HAS_ALPHA(image); swi = (src->width - width) * 4; - s = src->data + sy*(int)src->width*4 + sx; + s = src->data + (sy*(int)src->width + sx) * 4; if (!HAS_ALPHA(image)) { dwi = (image->width - width) * 3; - d = image->data + (dy*(int)image->width+dx)*3; + d = image->data + (dy*(int)image->width + dx) * 3; } else { dwi = (image->width - width) * 4; - d = image->data + (dy*(int)image->width+dx)*4; + d = image->data + (dy*(int)image->width + dx) * 4; } for (y=0; y < height; y++) { -- 2.11.4.GIT