New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / readpixelarray8.c
blob1201cf4acd4f3e7e86f3c2df85a819acdb8000df
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include "graphics_intern.h"
10 #include "gfxfuncsupport.h"
12 struct rp8_render_data
14 UBYTE *array;
15 ULONG modulo;
16 HIDDT_PixelLUT *pixlut;
19 static ULONG rp8_render(APTR rp8r_data, LONG srcx, LONG srcy,
20 OOP_Object *srcbm_obj, OOP_Object *gc,
21 LONG x1, LONG y1, LONG x2, LONG y2,
22 struct GfxBase *GfxBase);
24 /*****************************************************************************
26 NAME */
27 #include <clib/graphics_protos.h>
29 AROS_LH7(LONG, ReadPixelArray8,
31 /* SYNOPSIS */
32 AROS_LHA(struct RastPort * , rp , A0),
33 AROS_LHA(LONG , xstart , D0),
34 AROS_LHA(LONG , ystart , D1),
35 AROS_LHA(LONG , xstop , D2),
36 AROS_LHA(LONG , ystop , D3),
37 AROS_LHA(UBYTE * , array , A2),
38 AROS_LHA(struct RastPort * , temprp , A1),
40 /* LOCATION */
41 struct GfxBase *, GfxBase, 130, Graphics)
43 /* FUNCTION
45 INPUTS
47 RESULT
49 NOTES
51 EXAMPLE
53 BUGS
55 SEE ALSO
57 INTERNALS
59 HISTORY
60 27-11-96 digulla automatically created from
61 graphics_lib.fd and clib/graphics_protos.h
63 *****************************************************************************/
65 AROS_LIBFUNC_INIT
67 struct rp8_render_data rp8rd;
68 struct Rectangle rr;
69 HIDDT_PixelLUT pixlut;
70 LONG pixread = 0;
72 EnterFunc(bug("ReadPixelArray8(%p, %d, %d, %d, %d)\n",
73 rp, xstart, ystart, xstop, ystop));
75 FIX_GFXCOORD(xstart);
76 FIX_GFXCOORD(ystart);
77 FIX_GFXCOORD(xstop);
78 FIX_GFXCOORD(ystop);
80 if ((xstart > xstop) || (ystart > ystop)) return 0;
82 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
83 return 0;
85 #warning "ReadPixelArray8 on hi/truecolor screens or a LUT for it does not really make sense"
87 pixlut.entries = AROS_PALETTE_SIZE;
88 pixlut.pixels = IS_HIDD_BM(rp->BitMap) ? HIDD_BM_PIXTAB(rp->BitMap) : NULL;
90 rp8rd.array = array;
91 rp8rd.modulo = ((xstop - xstart + 1) + 15) & ~15;
92 rp8rd.pixlut = &pixlut;
94 rr.MinX = xstart;
95 rr.MinY = ystart;
96 rr.MaxX = xstop;
97 rr.MaxY = ystop;
99 pixread = do_render_func(rp, NULL, &rr, rp8_render, &rp8rd, FALSE, GfxBase);
101 RELEASE_DRIVERDATA(rp, GfxBase);
103 ReturnInt("ReadPixelArray8", LONG, pixread);
105 AROS_LIBFUNC_EXIT
107 } /* ReadPixelArray8 */
109 /****************************************************************************************/
111 static ULONG rp8_render(APTR rp8r_data, LONG srcx, LONG srcy,
112 OOP_Object *srcbm_obj, OOP_Object *gc,
113 LONG x1, LONG y1, LONG x2, LONG y2,
114 struct GfxBase *GfxBase)
116 struct rp8_render_data *rp8rd;
117 ULONG width, height;
119 rp8rd = (struct rp8_render_data *)rp8r_data;
121 width = x2 - x1 + 1;
122 height = y2 - y1 + 1;
124 HIDD_BM_GetImageLUT(srcbm_obj
125 , rp8rd->array + CHUNKY8_COORD_TO_BYTEIDX(srcx, srcy, rp8rd->modulo)
126 , rp8rd->modulo
127 , x1, y1
128 , width, height
129 , rp8rd->pixlut
132 return width * height;
135 /****************************************************************************************/