wip prep commit in lieu of gfx subsystem update changes.
[AROS.git] / workbench / libs / cgfx / writergbpixel.c
blob48a2a93672a79d7064e368da4eafde962a3dce48
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_LH4(LONG, WriteRGBPixel,
29 /* SYNOPSIS */
30 AROS_LHA(struct RastPort *, rp , A1),
31 AROS_LHA(UWORD , x , D0),
32 AROS_LHA(UWORD , y , D1),
33 AROS_LHA(ULONG , pixel , D2),
35 /* LOCATION */
36 struct Library *, CyberGfxBase, 19, Cybergraphics)
38 /* FUNCTION
39 Writes a new color value to a pixel in a RastPort.
41 INPUTS
42 rp - the RastPort to write to.
43 x, y - the coordinates of the pixel to write.
44 pixel - the pixel's new color value in 32-bit ARGB format: 1 byte
45 per component, in the order alpha, red, green, blue.
47 RESULT
48 error - 0 if no error occurred, or -1 if (x, y) is outside the
49 RastPort.
51 NOTES
53 EXAMPLE
55 BUGS
57 SEE ALSO
59 INTERNALS
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 struct render_data data;
66 HIDDT_Color col;
67 LONG retval;
69 /* This is cybergraphx. We only work wih HIDD bitmaps */
70 if (!IS_HIDD_BM(rp->BitMap))
72 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap "
73 "in WriteRGBPixel() !!!\n"));
74 return 0;
77 /* HIDDT_ColComp are 16 Bit */
79 col.alpha = (HIDDT_ColComp)((pixel >> 16) & 0x0000FF00);
80 col.red = (HIDDT_ColComp)((pixel >> 8) & 0x0000FF00);
81 col.green = (HIDDT_ColComp)(pixel & 0x0000FF00);
82 col.blue = (HIDDT_ColComp)((pixel << 8) & 0x0000FF00);
84 data.pixel = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
86 retval = DoPixelFunc(rp, x, y, PixelHook, &data, TRUE);
88 return retval;
90 AROS_LIBFUNC_EXIT
91 } /* WriteRGBPixel */
93 static LONG PixelHook(struct render_data *data, OOP_Object *bm, OOP_Object *gc,
94 LONG x, LONG y, struct GfxBase *GfxBase)
96 HIDD_BM_PutPixel(bm, x, y, data->pixel);
98 return 0;