From 97f6a62bba70bdaee554e523e27568a7a587d72b Mon Sep 17 00:00:00 2001 From: rob Date: Thu, 4 Oct 2007 12:31:27 +0000 Subject: [PATCH] scale bitmaps one line at a time. this uses significantly less memory while being almost as fast git-svn-id: https://svn.aros.org:8080/svn/aros/trunk/AROS@26981 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/hidds/graphics/BM_Class.c | 53 ++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/workbench/hidds/graphics/BM_Class.c b/workbench/hidds/graphics/BM_Class.c index 05d22fc9a..b95dc7272 100644 --- a/workbench/hidds/graphics/BM_Class.c +++ b/workbench/hidds/graphics/BM_Class.c @@ -3443,6 +3443,7 @@ VOID BM__Hidd_BitMap__BitMapScale(OOP_Class * cl, OOP_Object *o, { struct BitScaleArgs *bsa = msg->bsa; ULONG *srcbuf, *dstbuf; + LONG srcline = -1; UWORD *linepattern; ULONG count; UWORD ys = bsa->bsa_SrcY; @@ -3455,44 +3456,58 @@ VOID BM__Hidd_BitMap__BitMapScale(OOP_Class * cl, OOP_Object *o, ULONG dys = bsa->bsa_SrcHeight; LONG accuyd = - (dys >> 1); LONG accuxd = - (dxs >> 1); - ULONG y; + ULONG x; - srcbuf = AllocVec(bsa->bsa_SrcWidth * sizeof(ULONG) * bsa->bsa_SrcHeight, 0); - dstbuf = AllocVec(bsa->bsa_DestWidth * sizeof(ULONG) * bsa->bsa_DestHeight, 0); + if ((srcbuf = AllocVec(bsa->bsa_SrcWidth * sizeof(ULONG), 0)) == NULL) + return; - HIDD_BM_GetImage(msg->src, (UBYTE *) srcbuf, bsa->bsa_SrcWidth * sizeof(ULONG), bsa->bsa_SrcX, bsa->bsa_SrcY, bsa->bsa_SrcWidth, bsa->bsa_SrcHeight, vHidd_StdPixFmt_Native32); + if ((dstbuf = AllocVec(bsa->bsa_DestWidth * sizeof(ULONG), 0)) == NULL) { + FreeVec(srcbuf); + return; + } - linepattern = (UWORD *) AllocVec(bsa->bsa_DestHeight * sizeof(UWORD), 0); + if ((linepattern = (UWORD *) AllocVec(bsa->bsa_DestWidth * sizeof(UWORD), 0)) == NULL) { + FreeVec(dstbuf); + FreeVec(srcbuf); + return; + } count = 0; - while (count < bsa->bsa_DestHeight) { + while (count < bsa->bsa_DestWidth) { + accuxd += dxs; + while (accuxd > accuxs) { + xs++; + accuxs += dxd; + } + + linepattern[count] = xs; + + count++; + } + + count = bsa->bsa_DestY; + while (count < bsa->bsa_DestHeight + bsa->bsa_DestY) { accuyd += dys; while (accuyd > accuys) { ys++; accuys += dyd; } - linepattern[count] = ys; - count++; - } - count = bsa->bsa_DestX; - while (count < bsa->bsa_DestWidth + bsa->bsa_DestX) { - accuxd += dxs; - while (accuxd > accuxs) { - xs++; - accuxs += dxd; + if (srcline != ys) { + HIDD_BM_GetImage(msg->src, (UBYTE *) srcbuf, bsa->bsa_SrcWidth * sizeof(ULONG), bsa->bsa_SrcX, bsa->bsa_SrcY + ys, bsa->bsa_SrcWidth, 1, vHidd_StdPixFmt_Native32); + srcline = ys; + + for (x = 0; x < bsa->bsa_DestWidth; x++) + dstbuf[x] = srcbuf[linepattern[x]]; } - for (y = 0; y < bsa->bsa_DestHeight; y++) - dstbuf[(bsa->bsa_DestWidth * y) + count] = srcbuf[(bsa->bsa_SrcWidth * linepattern[y]) + xs]; + HIDD_BM_PutImage(msg->dst, msg->gc, (UBYTE *) dstbuf, bsa->bsa_DestWidth * sizeof(ULONG), bsa->bsa_DestX, bsa->bsa_DestY + count, bsa->bsa_DestWidth, 1, vHidd_StdPixFmt_Native32); count++; } FreeVec(linepattern); - HIDD_BM_PutImage(msg->dst, msg->gc, (UBYTE *) dstbuf, bsa->bsa_DestWidth * sizeof(ULONG), bsa->bsa_DestX, bsa->bsa_DestY, bsa->bsa_DestWidth, bsa->bsa_DestHeight, vHidd_StdPixFmt_Native32); - FreeVec(dstbuf); FreeVec(srcbuf); } -- 2.11.4.GIT