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"
18 HIDDT_StdPixFmt pixfmt
;
23 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
24 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
, struct Rectangle
*rect
,
25 struct GfxBase
*GfxBase
);
27 /*****************************************************************************
30 #include <proto/cybergraphics.h>
32 AROS_LH10(ULONG
, ReadPixelArray
,
35 AROS_LHA(APTR
, dst
, A0
),
36 AROS_LHA(UWORD
, destx
, D0
),
37 AROS_LHA(UWORD
, desty
, D1
),
38 AROS_LHA(UWORD
, dstmod
, D2
),
39 AROS_LHA(struct RastPort
*, rp
, A1
),
40 AROS_LHA(UWORD
, srcx
, D3
),
41 AROS_LHA(UWORD
, srcy
, D4
),
42 AROS_LHA(UWORD
, width
, D5
),
43 AROS_LHA(UWORD
, height
, D6
),
44 AROS_LHA(UBYTE
, dstformat
, D7
),
47 struct Library
*, CyberGfxBase
, 20, Cybergraphics
)
50 Copies a rectangular portion of a RastPort to a block of raw pixel
54 dst - pointer to the pixel values.
55 destx, desty - top-lefthand corner of portion of destination rectangle
56 to write to (in pixels).
57 dstmod - the number of bytes in each row of the destination rectangle.
58 rp - the RastPort to read.
59 srcx, srcy - top-lefthand corner of portion of source RastPort to
61 width, height - size of the area to copy (in pixels).
62 dstformat - the format of the destination pixels. The following format
88 count - number of pixels read.
91 See WritePixelArray() for descriptions of pixel formats. Where a
92 RastPort does not support an alpha channel, destination alpha values
103 *****************************************************************************/
112 struct render_data data
;
114 if (width
== 0 || height
== 0)
117 /* Filter out unsupported modes */
118 if (dstformat
== RECTFMT_LUT8
|| dstformat
== RECTFMT_GREY8
)
120 D(bug("RECTFMT_LUT8 and RECTFMT_GREY8 are not supported "
121 "by ReadPixelArray()\n"));
125 /* This is cybergraphx. We only work wih HIDD bitmaps */
126 if (!IS_HIDD_BM(rp
->BitMap
))
128 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap "
129 "in ReadPixelArray() !!!\n"));
133 /* Preserve old drawmode */
134 old_drmd
= rp
->DrawMode
;
137 bppix
= GetRectFmtBytesPerPixel(dstformat
, rp
, CyberGfxBase
);
138 start_offset
= ((ULONG
)desty
) * dstmod
+ destx
* bppix
;
139 data
.array
= ((UBYTE
*)dst
) + start_offset
;
140 data
.pixfmt
= GetHIDDRectFmt(dstformat
, rp
, CyberGfxBase
);
141 data
.modulo
= dstmod
;
146 rr
.MaxX
= srcx
+ width
- 1;
147 rr
.MaxY
= srcy
+ height
- 1;
149 pixread
= DoRenderFunc(rp
, NULL
, &rr
, RenderHook
, &data
, FALSE
);
151 /* restore old drawmode */
152 SetDrMd(rp
, old_drmd
);
157 } /* ReadPixelArray */
159 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
160 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
,
161 struct Rectangle
*rect
, struct GfxBase
*GfxBase
)
163 ULONG width
= rect
->MaxX
- rect
->MinX
+ 1;
164 ULONG height
= rect
->MaxY
- rect
->MinY
+ 1;
165 UBYTE
*array
= data
->array
+ data
->modulo
* srcy
+ data
->bppix
* srcx
;
167 HIDD_BM_GetImage(dstbm_obj
, array
, data
->modulo
,
168 rect
->MinX
, rect
->MinY
, width
, height
, data
->pixfmt
);
170 return width
* height
;