Nonsense removed: upper case and lower case the same time.
[AROS.git] / rom / graphics / readpixelarray8.c
blob5f7d02daa18b78df27df9ce3986e44cb3c37c26e
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
44 Read the pen numbers of a rectangular area into an array.
46 INPUTS
47 rp - RastPort
48 xstart,ystart - starting point
49 xstop,ystop - stopping point
50 array - array where pens are stored. Allocate at least
51 (((width+15)>>4)<<4)*(ystop-ystart+1) bytes.
52 temprp - temporary RastPort; copy of rp with
53 - Layers == NULL
54 - temprp->BitMap with Rows set to 1,
55 - temprp->BytesPerRow set to (((width+15)>>4)<<1),
56 and temporary memory allocated for
57 temprp->BitMap->Planes[])
59 RESULT
60 The number of pixels read.
62 NOTES
63 This function doesn't make sense on true-/hicolor rastports.
65 EXAMPLE
67 BUGS
69 SEE ALSO
71 INTERNALS
73 HISTORY
74 27-11-96 digulla automatically created from
75 graphics_lib.fd and clib/graphics_protos.h
77 *****************************************************************************/
79 AROS_LIBFUNC_INIT
81 struct rp8_render_data rp8rd;
82 struct Rectangle rr;
83 HIDDT_PixelLUT pixlut;
84 LONG pixread = 0;
86 EnterFunc(bug("ReadPixelArray8(%p, %d, %d, %d, %d)\n",
87 rp, xstart, ystart, xstop, ystop));
89 FIX_GFXCOORD(xstart);
90 FIX_GFXCOORD(ystart);
91 FIX_GFXCOORD(xstop);
92 FIX_GFXCOORD(ystop);
94 if ((xstart > xstop) || (ystart > ystop)) return 0;
96 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
97 return 0;
99 #warning "ReadPixelArray8 on hi/truecolor screens or a LUT for it does not really make sense"
101 pixlut.entries = AROS_PALETTE_SIZE;
102 pixlut.pixels = IS_HIDD_BM(rp->BitMap) ? HIDD_BM_PIXTAB(rp->BitMap) : NULL;
104 rp8rd.array = array;
105 rp8rd.modulo = ((xstop - xstart + 1) + 15) & ~15;
106 rp8rd.pixlut = &pixlut;
108 rr.MinX = xstart;
109 rr.MinY = ystart;
110 rr.MaxX = xstop;
111 rr.MaxY = ystop;
113 pixread = do_render_func(rp, NULL, &rr, rp8_render, &rp8rd, FALSE, FALSE, GfxBase);
115 RELEASE_DRIVERDATA(rp, GfxBase);
117 ReturnInt("ReadPixelArray8", LONG, pixread);
119 AROS_LIBFUNC_EXIT
121 } /* ReadPixelArray8 */
123 /****************************************************************************************/
125 static ULONG rp8_render(APTR rp8r_data, LONG srcx, LONG srcy,
126 OOP_Object *srcbm_obj, OOP_Object *gc,
127 LONG x1, LONG y1, LONG x2, LONG y2,
128 struct GfxBase *GfxBase)
130 struct rp8_render_data *rp8rd;
131 ULONG width, height;
133 rp8rd = (struct rp8_render_data *)rp8r_data;
135 width = x2 - x1 + 1;
136 height = y2 - y1 + 1;
138 HIDD_BM_GetImageLUT(srcbm_obj
139 , rp8rd->array + CHUNKY8_COORD_TO_BYTEIDX(srcx, srcy, rp8rd->modulo)
140 , rp8rd->modulo
141 , x1, y1
142 , width, height
143 , rp8rd->pixlut
146 return width * height;
149 /****************************************************************************************/