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
21 ***************************************************************************/
23 #include <proto/graphics.h>
25 #include "Chunky2Bitmap.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
)
37 const UBYTE
*a
= &array
[xstart
];
39 for(x
= 0; x
< width
; x
++)
42 WritePixel(rp
, x
+xstart
, ystart
);
46 #define WPL8(rp, xstart, ystart, width, array, tmprp) \
48 if(setPatchVersion >= ((43UL << 16) | 0UL)) \
49 WritePixelLine8(rp, xstart, ystart, width, array, tmprp); \
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
;
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
;
72 char *chunkyPtr
= chunky
;
74 InitRastPort(&remapRP
);
77 InitRastPort(&tempRP
);
78 tempRP
.BitMap
= tempBM
;
80 for(y
= 0; y
< height
; y
++)
82 WPL8(&remapRP
, 0, y
, width
, chunkyPtr
, &tempRP
);