revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / cgfx / readrgbpixel.c
blob0fceb8ed763f2e53622276448fe4902bdf305a80
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <hidd/gfx.h>
10 #include <aros/debug.h>
12 #include "cybergraphics_intern.h"
14 struct render_data
16 HIDDT_Pixel pixel;
19 static LONG PixelHook(struct render_data *data, OOP_Object *bm, OOP_Object *gc,
20 LONG x, LONG y, struct GfxBase *GfxBase);
22 /*****************************************************************************
24 NAME */
25 #include <proto/cybergraphics.h>
27 AROS_LH3(ULONG, ReadRGBPixel,
29 /* SYNOPSIS */
30 AROS_LHA(struct RastPort *, rp , A1),
31 AROS_LHA(UWORD , x , D0),
32 AROS_LHA(UWORD , y , D1),
34 /* LOCATION */
35 struct Library *, CyberGfxBase, 18, Cybergraphics)
37 /* FUNCTION
38 Reads a particular pixel's color value from a RastPort.
40 INPUTS
41 rp - the RastPort to read from.
42 x, y - the coordinates of the pixel to read.
44 RESULT
45 color - the pixel's color value in 32-bit ARGB format: 1 byte
46 per component, in the order alpha, red, green, blue.
48 NOTES
50 EXAMPLE
52 BUGS
54 SEE ALSO
56 INTERNALS
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 struct render_data data;
63 HIDDT_Color col;
64 HIDDT_Pixel pix;
65 LONG ret;
67 /* This is cybergraphx. We only work wih HIDD bitmaps */
68 if (!IS_HIDD_BM(rp->BitMap))
70 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap "
71 "in ReadRGBPixel()!!!\n"));
72 return (ULONG)-1;
75 /* Get the HIDD pixel val */
76 ret = DoPixelFunc(rp, x, y, PixelHook, &data, FALSE);
78 if (-1 == ret)
79 return (ULONG)-1;
81 HIDD_BM_UnmapPixel(HIDD_BM_OBJ(rp->BitMap), data.pixel, &col);
83 /* HIDDT_ColComp are 16 Bit */
85 pix = ((col.alpha & 0xFF00) << 16)
86 | ((col.red & 0xFF00) << 8)
87 | (col.green & 0xFF00)
88 | ((col.blue & 0xFF00) >> 8);
90 return pix;
92 AROS_LIBFUNC_EXIT
93 } /* ReadRGBPixel */
95 static LONG PixelHook(struct render_data *data, OOP_Object *bm, OOP_Object *gc,
96 LONG x, LONG y, struct GfxBase *GfxBase)
98 data->pixel = HIDD_BM_GetPixel(bm, x, y);
99 return 0;