From c7998188a4247c06e50a3296b336541eb85baa92 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 28 Jan 2015 20:39:52 +0000 Subject: [PATCH] Added support for standard 16-bit images. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49963 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/classes/datatypes/bmp/bmp.conf | 2 +- workbench/classes/datatypes/bmp/bmpclass.c | 31 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/workbench/classes/datatypes/bmp/bmp.conf b/workbench/classes/datatypes/bmp/bmp.conf index b9bd3cd1a7..acf83ea7da 100644 --- a/workbench/classes/datatypes/bmp/bmp.conf +++ b/workbench/classes/datatypes/bmp/bmp.conf @@ -1,6 +1,6 @@ ##begin config basename BMP -version 41.3 +version 41.4 superclass PICTUREDTCLASS ##end config ##begin cdef diff --git a/workbench/classes/datatypes/bmp/bmpclass.c b/workbench/classes/datatypes/bmp/bmpclass.c index 88f9e0fa2d..f63665dc34 100644 --- a/workbench/classes/datatypes/bmp/bmpclass.c +++ b/workbench/classes/datatypes/bmp/bmpclass.c @@ -313,6 +313,11 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) alignwidth = (biWidth + 3) & ~3UL; alignbytes = alignwidth; break; + case 16: + alignbytes = ((biBitCount * biWidth + 31) / 32) * 4; + alignwidth = alignbytes / 2; + pixelfmt = PBPAFMT_RGB; + break; case 24: alignbytes = ((biBitCount * biWidth + 31) / 32) * 4; alignwidth = alignbytes / 3; @@ -331,7 +336,7 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) bmhd->bmh_Depth = biBitCount; /* get empty colormap, then fill in colormap to use*/ - if (biBitCount != 24) + if (biBitCount <= 8) { if( !(GetDTAttrs(o, PDTA_ColorRegisters, (IPTR)&colormap, PDTA_CRegs, (IPTR)&colorregs, @@ -374,8 +379,8 @@ 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 */ - if (biBitCount == 24) - bmphandle->linebufsize = alignbytes; + if (biBitCount > 8) + bmphandle->linebufsize = alignwidth * 3; else bmphandle->linebufsize = alignwidth; if (! (bmphandle->linebuf = bmphandle->linebufpos = AllocMem(bmphandle->linebufsize, MEMF_ANY)) ) @@ -390,6 +395,7 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) { int r, g, b; UBYTE *p; + UWORD pixel; bmphandle->linebufpos = bmphandle->linebuf; if (biBitCount == 24) @@ -412,6 +418,25 @@ static BOOL LoadBMP(struct IClass *cl, Object *o) } bmphandle->filebufpos += alignbytes; } + else if (biBitCount == 16) + { + if ( (bmphandle->filebufbytes -= alignbytes) < 0 && !LoadBMP_FillBuf(bmphandle, alignbytes) ) + { + D(bug("bmp.datatype/LoadBMP() --- early end of bitmap data, x %ld y %ld\n", x, y)); + //BMP_Exit(bmphandle, ERROR_OBJECT_WRONG_TYPE); + //return FALSE; + cont = 0; + } + for (x=0, p = bmphandle->filebufpos; xlinebufpos)++ = (pixel & 0x7c00) >> 7; + *(bmphandle->linebufpos)++ = (pixel & 0x03e0) >> 2; + *(bmphandle->linebufpos)++ = (pixel & 0x1f) << 3; + } + bmphandle->filebufpos += alignbytes; + } else { for (x=0; x