grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / nlist / nbitmap_mcc / Chunky2Bitmap.c
bloba388c35f4da3fee4e7c10059554a2e3785aaf7ea
1 /***************************************************************************
3 NBitmap.mcc - New Bitmap MUI Custom Class
4 Copyright (C) 2006 by Daniel Allsopp
5 Copyright (C) 2007-2013 by NList Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 NList classes Support Site: http://www.sf.net/projects/nlist-classes
19 $Id$
21 ***************************************************************************/
23 #include <proto/graphics.h>
25 #include "Chunky2Bitmap.h"
26 #include "SetPatch.h"
28 #include "private.h"
30 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
31 #define WPL8(rp, xstart, ystart, width, array, tmprp) WritePixelLine8(rp, xstart, ystart, width, array, tmprp)
32 #else // __amigaos4 || __MORPHOS__ || __AROS__
33 // WritePixelLine8() is broken on plain OS3.1 systems, don't use it!
34 static void _WritePixelLine8(struct RastPort *rp, UWORD xstart, UWORD ystart, UWORD width, const UBYTE *array, UNUSED struct RastPort *tmprp)
36 UWORD x;
37 const UBYTE *a = &array[xstart];
39 for(x = 0; x < width; x++)
41 SetAPen(rp, *a++);
42 WritePixel(rp, x+xstart, ystart);
46 #define WPL8(rp, xstart, ystart, width, array, tmprp) \
47 { \
48 if(setPatchVersion >= ((43UL << 16) | 0UL)) \
49 WritePixelLine8(rp, xstart, ystart, width, array, tmprp); \
50 else \
51 _WritePixelLine8(rp, xstart, ystart, width, array, tmprp); \
53 #endif // __amigaos4 || __MORPHOS__ || __AROS__
55 struct BitMap *Chunky2Bitmap(APTR chunky, ULONG width, ULONG height, ULONG depth)
57 struct BitMap *bm = NULL;
59 ENTER();
61 if(chunky != NULL && width > 0 && height > 0)
63 if((bm = AllocBitMap(width, height, min(8, depth), BMF_CLEAR|BMF_MINPLANES, NULL)) != NULL)
65 struct BitMap *tempBM;
67 if((tempBM = AllocBitMap(width, 1, min(8, depth), BMF_CLEAR, NULL)) != NULL)
69 struct RastPort remapRP;
70 struct RastPort tempRP;
71 ULONG y;
72 char *chunkyPtr = chunky;
74 InitRastPort(&remapRP);
75 remapRP.BitMap = bm;
77 InitRastPort(&tempRP);
78 tempRP.BitMap = tempBM;
80 for(y = 0; y < height; y++)
82 WPL8(&remapRP, 0, y, width, chunkyPtr, &tempRP);
84 chunkyPtr += width;
87 FreeBitMap(tempBM);
89 else
91 FreeBitMap(bm);
92 bm = NULL;
97 RETURN(bm);
98 return bm;