2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
10 #include <aros/debug.h>
12 #include "cybergraphics_intern.h"
13 #include "gfxfuncsupport.h"
21 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
22 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
, struct Rectangle
*rect
,
23 struct GfxBase
*GfxBase
);
25 /*****************************************************************************
28 #include <proto/cybergraphics.h>
30 AROS_LH10(ULONG
, WritePixelArrayAlpha
,
33 AROS_LHA(APTR
, src
, A0
),
34 AROS_LHA(UWORD
, srcx
, D0
),
35 AROS_LHA(UWORD
, srcy
, D1
),
36 AROS_LHA(UWORD
, srcmod
, D2
),
37 AROS_LHA(struct RastPort
*, rp
, A1
),
38 AROS_LHA(UWORD
, destx
, D3
),
39 AROS_LHA(UWORD
, desty
, D4
),
40 AROS_LHA(UWORD
, width
, D5
),
41 AROS_LHA(UWORD
, height
, D6
),
42 AROS_LHA(ULONG
, globalalpha
, D7
),
45 struct Library
*, CyberGfxBase
, 36, Cybergraphics
)
48 Alpha-blends all or part of a rectangular block of raw pixel values
49 into a RastPort. The source data must be in 32-bit ARGB format: 1 byte
50 per component, in the order alpha, red, green, blue.
53 srcRect - pointer to the pixel values.
54 srcx, srcy - top-lefthand corner of portion of source rectangle to
56 srcmod - the number of bytes in each row of the source rectangle.
57 rp - the RastPort to write to.
58 destx, desty - top-lefthand corner of portion of destination RastPort
59 to write to (in pixels).
60 width, height - size of the affected area (in pixels).
61 globalalpha - an alpha value applied globally to every pixel taken
62 from the source rectangle (the full 32-bit range of values is
63 used: 0 to 0xFFFFFFFF).
66 count - the number of pixels written to.
69 Because of the X11 driver you have to set the drawmode
70 to JAM1 with SetDrMd().
75 The globalalpha parameter is currently ignored.
78 WritePixelArray(), graphics.library/SetDrMd()
82 *****************************************************************************/
88 struct render_data data
;
91 if (width
== 0 || height
== 0)
94 /* This is cybergraphx. We only work wih HIDD bitmaps */
95 if (!IS_HIDD_BM(rp
->BitMap
))
97 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap "
98 "in WritePixelArrayAlpha() !!!\n"));
102 /* Compute the start of the array */
104 start_offset
= ((ULONG
)srcy
) * srcmod
+ srcx
* 4;
106 data
.array
= ((UBYTE
*)src
) + start_offset
;
107 data
.modulo
= srcmod
;
111 rr
.MaxX
= destx
+ width
- 1;
112 rr
.MaxY
= desty
+ height
- 1;
114 pixwritten
= DoRenderFunc(rp
, NULL
, &rr
, RenderHook
, &data
, TRUE
);
119 } /* WritePixelArrayAlpha */
121 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
122 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
, struct Rectangle
*rect
,
123 struct GfxBase
*GfxBase
)
125 ULONG width
= rect
->MaxX
- rect
->MinX
+ 1;
126 ULONG height
= rect
->MaxY
- rect
->MinY
+ 1;
127 UBYTE
*array
= data
->array
+ data
->modulo
* srcy
+ 4 * srcx
;
129 HIDD_BM_PutAlphaImage(dstbm_obj
, dst_gc
, array
, data
->modulo
,
130 rect
->MinX
, rect
->MinY
, width
, height
);
132 return width
* height
;