disable debug
[AROS.git] / workbench / libs / cgfx / writelutpixelarray.c
blob9426e61198cec41d12a705e5ad69bd5003b3d414
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <graphics/rastport.h>
11 #include <hidd/gfx.h>
13 #include "cybergraphics_intern.h"
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/cybergraphics.h>
21 AROS_LH11(LONG, WriteLUTPixelArray,
23 /* SYNOPSIS */
24 AROS_LHA(APTR , srcRect, A0),
25 AROS_LHA(UWORD , SrcX, D0),
26 AROS_LHA(UWORD , SrcY, D1),
27 AROS_LHA(UWORD , SrcMod, D2),
28 AROS_LHA(struct RastPort *, rp, A1),
29 AROS_LHA(APTR , CTable, A2),
30 AROS_LHA(UWORD , DestX, D3),
31 AROS_LHA(UWORD , DestY, D4),
32 AROS_LHA(UWORD , SizeX, D5),
33 AROS_LHA(UWORD , SizeY, D6),
34 AROS_LHA(UBYTE , CTabFormat, D7),
36 /* LOCATION */
37 struct Library *, CyberGfxBase, 33, Cybergraphics)
39 /* FUNCTION
40 Copies all or part of a rectangular block of raw pen values to a
41 RastPort. The pen values are converted to the RastPort's native pixel
42 values.
44 INPUTS
45 srcRect - pointer to the pixel values.
46 SrcX, SrcY - top-lefthand corner of portion of source rectangle to
47 copy (in pixels).
48 SrcMod - the number of bytes in each row of the source rectangle.
49 rp - the RastPort to write to.
50 CTable - the color table that maps the source pen values.
51 DestX, DestY - top-lefthand corner of portion of destination RastPort
52 to write to (in pixels).
53 SizeX, SizeY - size of the area to copy (in pixels).
54 CTabFormat - format of the color table. Only one format type is
55 currently supported:
56 CTABFMT_XRGB8 - the colour table is an array of 256 ULONGs.
57 Each entry begins with an unused byte, followed by 1 byte
58 for each component, in the order red, green, blue.
60 RESULT
61 count - the number of pixels written to.
63 NOTES
65 EXAMPLE
67 BUGS
69 SEE ALSO
71 INTERNALS
73 *****************************************************************************/
75 AROS_LIBFUNC_INIT
77 ULONG depth;
79 HIDDT_PixelLUT pixlut;
80 HIDDT_Pixel pixtab[256];
81 HIDDT_Color col;
82 ULONG i;
84 /* This is cybergraphx. We only work wih HIDD bitmaps */
85 if (!IS_HIDD_BM(rp->BitMap)) {
86 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap in WriteLUTPixelArray()!!!\n"));
87 return 0;
90 pixlut.entries = 256;
91 pixlut.pixels = pixtab;
93 depth = GetBitMapAttr(rp->BitMap, BMA_DEPTH);
95 /* This call does only support bitmaps with depth > 8. Use WritePixelArray8
96 for other bitmaps
99 if (depth <= 8) {
100 D(bug("!!! TRYING TO USE WriteLUTPixelArray() ON BITMAP WITH DEPTH <= 8\n"));
101 return 0;
104 /* Curently only one format is supported */
105 if (CTABFMT_XRGB8 != CTabFormat) {
106 D(bug("!!! WriteLUTPixelArray() CALLED WITH UNSUPPORTED CTAB FORMAT %d\n"
107 , CTabFormat));
108 return 0;
111 /* Convert the coltab into native pixels */
112 col.alpha = 0;
113 for (i = 0; i < 256; i ++)
115 register ULONG rgb = ((ULONG *)CTable)[i];
117 col.red = (HIDDT_ColComp)((rgb & 0x00FF0000) >> 8);
118 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
119 col.blue = (HIDDT_ColComp)((rgb & 0x000000FF) << 8);
121 pixtab[i] = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
124 /* Now blit the colors on to the screen */
125 return WritePixels8(rp, srcRect + CHUNKY8_COORD_TO_BYTEIDX(SrcX, SrcY, SrcMod), SrcMod,
126 DestX, DestY, DestX + SizeX - 1, DestY + SizeY - 1, &pixlut, TRUE);
128 AROS_LIBFUNC_EXIT
129 } /* WriteLUTPixelArray */