Fixed missing fprintf argument.
[AROS.git] / rom / graphics / readpixel.c
bloba604dd51933f83e5a9c0c4826785416107c3571b
1 /*
2 Copyright © 1995-2001, 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 LONG x, LONG y, struct GfxBase *GfxBase);
27 /*****************************************************************************
29 NAME */
31 AROS_LH3(LONG, ReadPixel,
33 /* SYNOPSIS */
34 AROS_LHA(struct RastPort *, rp, A1),
35 AROS_LHA(LONG , x, D0),
36 AROS_LHA(LONG , y, D1),
38 /* LOCATION */
39 struct GfxBase *, GfxBase, 53, Graphics)
41 /* FUNCTION
43 INPUTS
45 RESULT
47 NOTES
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
56 This function takes layers into account. Some pixel that is
57 being read is not found on the display-bitmap but in some
58 clipped rectangle (cliprect) in a layer structure.
59 There is no support of anything else than bitplanes now.
60 (No chunky pixels)
61 This function resembles very much the function WritePixel()!!
63 HISTORY
64 29-10-95 digulla automatically created from
65 graphics_lib.fd and clib/graphics_protos.h
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
70 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
72 struct prlut8_render_data prlrd;
73 LONG ret;
75 HIDDT_PixelLUT pixlut = { AROS_PALETTE_SIZE, HIDD_BM_PIXTAB(rp->BitMap) };
77 FIX_GFXCOORD(x);
78 FIX_GFXCOORD(y);
80 if(!OBTAIN_DRIVERDATA(rp, GfxBase))
81 return ((ULONG)-1L);
83 if (IS_HIDD_BM(rp->BitMap))
84 prlrd.pixlut = &pixlut;
85 else
86 prlrd.pixlut = NULL;
88 prlrd.pen = -1;
90 ret = do_pixel_func(rp, x, y, pix_read_lut8, &prlrd, GfxBase);
92 RELEASE_DRIVERDATA(rp, GfxBase);
94 if (-1 == ret || -1 == (LONG)prlrd.pen)
96 D(bug("ReadPixel(), COULD NOT GET PEN. TRYING TO READ FROM SimpleRefresh cliprect ??"));
97 return (ULONG)-1;
100 return prlrd.pen;
102 AROS_LIBFUNC_EXIT
104 } /* ReadPixel */
106 static LONG pix_read_lut8(APTR prlr_data, OOP_Object *bm, OOP_Object *gc,
107 LONG x, LONG y, struct GfxBase *GfxBase)
109 struct prlut8_render_data *prlrd;
111 prlrd = (struct prlut8_render_data *)prlr_data;
113 if (NULL != prlrd->pixlut)
115 HIDD_BM_GetImageLUT(bm, (UBYTE *)&prlrd->pen, 1, x, y, 1, 1, prlrd->pixlut);
117 else
119 prlrd->pen = HIDD_BM_GetPixel(bm, x, y);
122 return 0;