revert between 56095 -> 55830 in arch
[AROS.git] / rom / graphics / readpixelarray8.c
blob36d1744d90de8e447de9bde23b581daed8c5bf41
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
14 /****************************************************************************************/
17 struct rp8_render_data
19 UBYTE *array;
20 ULONG modulo;
21 HIDDT_PixelLUT *pixlut;
24 static ULONG rp8_render(APTR rp8r_data, WORD srcx, WORD srcy,
25 OOP_Object *srcbm_obj, OOP_Object *gc,
26 struct Rectangle *rect, struct GfxBase *GfxBase)
28 struct rp8_render_data *rp8rd = rp8r_data;
29 WORD width = rect->MaxX - rect->MinX + 1;
30 WORD height = rect->MaxY - rect->MinY + 1;
32 HIDD_BM_GetImageLUT(srcbm_obj, rp8rd->array + CHUNKY8_COORD_TO_BYTEIDX(srcx, srcy, rp8rd->modulo), rp8rd->modulo,
33 rect->MinX, rect->MinY, width, height, rp8rd->pixlut);
35 return width * height;
38 /*****************************************************************************
40 NAME */
41 #include <clib/graphics_protos.h>
43 AROS_LH7(LONG, ReadPixelArray8,
45 /* SYNOPSIS */
46 AROS_LHA(struct RastPort * , rp , A0),
47 AROS_LHA(WORD , xstart , D0),
48 AROS_LHA(WORD , ystart , D1),
49 AROS_LHA(WORD , xstop , D2),
50 AROS_LHA(WORD , ystop , D3),
51 AROS_LHA(UBYTE * , array , A2),
52 AROS_LHA(struct RastPort * , temprp , A1),
54 /* LOCATION */
55 struct GfxBase *, GfxBase, 130, Graphics)
57 /* FUNCTION
58 Read the pen numbers of a rectangular area into an array.
60 INPUTS
61 rp - RastPort
62 xstart,ystart - starting point
63 xstop,ystop - stopping point
64 array - array where pens are stored. Allocate at least
65 (((width+15)>>4)<<4)*(ystop-ystart+1) bytes.
66 temprp - temporary RastPort; copy of rp with
67 - Layers == NULL
68 - temprp->BitMap with Rows set to 1,
69 - temprp->BytesPerRow set to (((width+15)>>4)<<1),
70 and temporary memory allocated for
71 temprp->BitMap->Planes[])
73 RESULT
74 The number of pixels read.
76 NOTES
77 This function doesn't make sense on true-/hicolor rastports.
79 EXAMPLE
81 BUGS
83 SEE ALSO
85 INTERNALS
87 HISTORY
88 27-11-96 digulla automatically created from
89 graphics_lib.fd and clib/graphics_protos.h
91 *****************************************************************************/
93 AROS_LIBFUNC_INIT
95 struct rp8_render_data rp8rd;
96 struct Rectangle rr;
97 HIDDT_PixelLUT pixlut;
98 LONG pixread = 0;
100 EnterFunc(bug("ReadPixelArray8(%p, %d, %d, %d, %d)\n",
101 rp, xstart, ystart, xstop, ystop));
103 FIX_GFXCOORD(xstart);
104 FIX_GFXCOORD(ystart);
105 FIX_GFXCOORD(xstop);
106 FIX_GFXCOORD(ystop);
108 if ((xstart > xstop) || (ystart > ystop)) return 0;
110 /* FIXME: ReadPixelArray8 on hi/truecolor screens or
111 * a LUT for it does not really make sense
114 pixlut.entries = AROS_PALETTE_SIZE;
115 pixlut.pixels = IS_HIDD_BM(rp->BitMap) ? HIDD_BM_PIXTAB(rp->BitMap) : NULL;
117 rp8rd.array = array;
118 rp8rd.modulo = ((xstop - xstart + 1) + 15) & ~15;
119 rp8rd.pixlut = &pixlut;
121 rr.MinX = xstart;
122 rr.MinY = ystart;
123 rr.MaxX = xstop;
124 rr.MaxY = ystop;
126 pixread = do_render_func(rp, NULL, &rr, rp8_render, &rp8rd, FALSE, FALSE, GfxBase);
128 ReturnInt("ReadPixelArray8", LONG, pixread);
130 AROS_LIBFUNC_EXIT
132 } /* ReadPixelArray8 */