From a5605f2a337066609d564c0b42637f5206136d44 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 26 Jan 2015 00:10:10 +0000 Subject: [PATCH] - Fixed a regression in decoding 8-bit images (introduced in my r46589). - Line buffer was too small for 1-bit and 4-bit images. Fixed (but the 1-bit images I've tried don't work either before or after my changes). - Removed unused field 'linebufbytes' in BmpHandleType. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49940 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/classes/datatypes/bmp/bmpclass.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/workbench/classes/datatypes/bmp/bmpclass.c b/workbench/classes/datatypes/bmp/bmpclass.c index 1f5582abfc..0cc29c8f4d 100644 --- a/workbench/classes/datatypes/bmp/bmpclass.c +++ b/workbench/classes/datatypes/bmp/bmpclass.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -57,7 +57,6 @@ typedef struct { long filebufsize; UBYTE *linebuf; UBYTE *linebufpos; - long linebufbytes; long linebufsize; APTR codecvars; @@ -370,7 +369,10 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) TAG_DONE); /* Now decode the picture data into a chunky buffer; and pass it to Bitmap line-by-line */ - bmphandle->linebufsize = bmphandle->linebufbytes = alignbytes; + if (biBitCount == 24) + bmphandle->linebufsize = alignbytes; + else + bmphandle->linebufsize = alignwidth; if (! (bmphandle->linebuf = bmphandle->linebufpos = AllocMem(bmphandle->linebufsize, MEMF_ANY)) ) { BMP_Exit(bmphandle, ERROR_NO_FREE_STORE); @@ -403,6 +405,7 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) *(bmphandle->linebufpos)++ = g; *(bmphandle->linebufpos)++ = b; } + bmphandle->filebufpos += alignbytes; } else { @@ -416,7 +419,7 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) cont = 0; break; } - byte = *p++; + byte = *(bmphandle->filebufpos)++; switch (biBitCount) { case 1: @@ -457,7 +460,6 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) BMP_Exit(bmphandle, ERROR_OBJECT_WRONG_TYPE); return FALSE; } - bmphandle->filebufpos += alignbytes; } //D(bug("bmp.datatype/LoadBMP() --- bytes of %ld (%ld) bytes\n", (long)bmphandle->filebufbytes, (long)(bmphandle->filebufsize-(bmphandle->filebufpos-bmphandle->filebuf)) )); @@ -586,7 +588,7 @@ static BOOL SaveBMP(struct IClass *cl, Object *o, struct dtWrite *dtw ) /* Now read the picture data from the bitplanes and write it to a chunky buffer */ /* For now, we use a full picture pixel buffer, not a single line */ widthxheight = width*height; - bmphandle->linebufsize = bmphandle->linebufbytes = widthxheight; + bmphandle->linebufsize = widthxheight; if (! (bmphandle->linebuf = bmphandle->linebufpos = AllocMem(bmphandle->linebufsize, MEMF_ANY)) ) { BMP_Exit(bmphandle, ERROR_NO_FREE_STORE); -- 2.11.4.GIT