From b7d101f636a45bd2935ed6ba8f4e95936ca41828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 12 Feb 2011 18:59:14 +0000 Subject: [PATCH] [GB.IMAGE] * NEW: Image.DrawAlpha() can work with images having different formats. git-svn-id: svn://localhost/gambas/trunk@3562 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/lib/image/image.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/lib/image/image.c b/main/lib/image/image.c index 6e811398b..dc5d56509 100644 --- a/main/lib/image/image.c +++ b/main/lib/image/image.c @@ -890,11 +890,11 @@ void IMAGE_bitblt(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int void IMAGE_draw_alpha(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int sw, int sh) { - if (dst->format != src->format) + /*if (dst->format != src->format) { GB.Error("The source image and the destination image must have the same format"); return; - } + }*/ if (!GB_IMAGE_FMT_IS_32_BITS(dst->format)) { @@ -925,17 +925,18 @@ void IMAGE_draw_alpha(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, const int dd = dst->width - sw; const int ds = src->width - sw; uint cs, cd; - int format = src->format; + int sformat = src->format; + int dformat = dst->format; int t; while (sh--) { for (t = sw; t--; d++,s++) { - cs = BGRA_from_format(*s, format); - cd = BGRA_from_format(*d, format); + cs = BGRA_from_format(*s, sformat); + cd = BGRA_from_format(*d, dformat); if (ALPHA(cs) < ALPHA(cd)) - *d = BGRA_to_format(RGBA(RED(cd), GREEN(cd), BLUE(cd), ALPHA(cs)), format); + *d = BGRA_to_format(RGBA(RED(cd), GREEN(cd), BLUE(cd), ALPHA(cs)), dformat); } d += dd;