Make hostlib test build again.
[AROS.git] / rom / graphics / readpixel.c
blobfae0a164196506d4c0e20c320f4375bb82725cee
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ReadPixel()
6 Lang: english
7 */
9 #include <graphics/rastport.h>
10 #include <graphics/clip.h>
11 #include <proto/graphics.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 #include <aros/debug.h>
18 struct prlut8_render_data
20 ULONG pen;
21 HIDDT_PixelLUT *pixlut;
24 static LONG pix_read_lut8(APTR prlr_data, OOP_Object *bm, OOP_Object *gc,
25 WORD x, WORD y, struct GfxBase *GfxBase);
27 /*****************************************************************************
29 NAME */
31 AROS_LH3(LONG, ReadPixel,
33 /* SYNOPSIS */
34 AROS_LHA(struct RastPort *, rp, A1),
35 AROS_LHA(WORD , x, D0),
36 AROS_LHA(WORD , y, D1),
38 /* LOCATION */
39 struct GfxBase *, GfxBase, 53, Graphics)
41 /* FUNCTION
42 Read the pen number of the given x,y coordinate.
44 INPUTS
45 rp - RastPort
46 x,y - Coordinate
48 RESULT
50 NOTES
52 EXAMPLE
54 BUGS
56 SEE ALSO
58 INTERNALS
59 This function takes layers into account. Some pixel that is
60 being read is not found on the display-bitmap but in some
61 clipped rectangle (cliprect) in a layer structure.
62 There is no support of anything else than bitplanes now.
63 (No chunky pixels)
64 This function resembles very much the function WritePixel()!!
66 HISTORY
67 29-10-95 digulla automatically created from
68 graphics_lib.fd and clib/graphics_protos.h
70 *****************************************************************************/
72 AROS_LIBFUNC_INIT
74 struct prlut8_render_data prlrd;
75 LONG ret;
77 HIDDT_PixelLUT pixlut = { AROS_PALETTE_SIZE, HIDD_BM_PIXTAB(rp->BitMap) };
79 FIX_GFXCOORD(x);
80 FIX_GFXCOORD(y);
82 if (IS_HIDD_BM(rp->BitMap))
83 prlrd.pixlut = &pixlut;
84 else
85 prlrd.pixlut = NULL;
87 prlrd.pen = -1;
89 ret = do_pixel_func(rp, x, y, pix_read_lut8, &prlrd, FALSE, GfxBase);
91 if (-1 == ret || -1 == (LONG)prlrd.pen)
93 D(bug("ReadPixel(), COULD NOT GET PEN. TRYING TO READ FROM SimpleRefresh cliprect ??"));
94 return (ULONG)-1;
97 return prlrd.pen;
99 AROS_LIBFUNC_EXIT
101 } /* ReadPixel */
103 static LONG pix_read_lut8(APTR prlr_data, OOP_Object *bm, OOP_Object *gc,
104 WORD x, WORD y, struct GfxBase *GfxBase)
106 struct prlut8_render_data *prlrd;
107 UBYTE pen;
109 prlrd = (struct prlut8_render_data *)prlr_data;
111 if (NULL != prlrd->pixlut)
113 HIDD_BM_GetImageLUT(bm, &pen, 1, x, y, 1, 1, prlrd->pixlut);
115 else
117 pen = HIDD_BM_GetPixel(bm, x, y);
120 prlrd->pen = pen;
122 return 0;