Release 970525
[wine/multimedia.git] / graphics / metafiledrv / graphics.c
blobf0fbc020e0e1a07a2a4e2823294c95cb75610e48
1 /*
2 * Metafile driver graphics functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 */
7 #include <stdlib.h>
8 #include "graphics.h"
9 #include "gdi.h"
10 #include "dc.h"
11 #include "metafile.h"
12 #include "region.h"
13 #include "xmalloc.h"
14 #include "metafiledrv.h"
15 #include "stddebug.h"
16 #include "debug.h"
18 /**********************************************************************
19 * MFDRV_MoveToEx
21 BOOL32
22 MFDRV_MoveToEx(DC *dc,INT32 x,INT32 y,LPPOINT32 pt)
24 if (!MF_MetaParam2(dc,META_MOVETO,x,y))
25 return FALSE;
27 if (pt)
29 pt->x = dc->w.CursPosX;
30 pt->y = dc->w.CursPosY;
32 dc->w.CursPosX = x;
33 dc->w.CursPosY = y;
34 return TRUE;
37 /***********************************************************************
38 * MFDRV_LineTo
40 BOOL32
41 MFDRV_LineTo( DC *dc, INT32 x, INT32 y )
43 return MF_MetaParam2(dc, META_LINETO, x, y);
47 /***********************************************************************
48 * MFDRV_Arc
50 BOOL32
51 MFDRV_Arc( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
52 INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
54 return MF_MetaParam8(dc, META_ARC, left, top, right, bottom,
55 xstart, ystart, xend, yend);
59 /***********************************************************************
60 * MFDRV_Pie
62 BOOL32
63 MFDRV_Pie( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
64 INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
66 return MF_MetaParam8(dc, META_PIE, left, top, right, bottom,
67 xstart, ystart, xend, yend);
71 /***********************************************************************
72 * MFDRV_Chord
74 BOOL32
75 MFDRV_Chord( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom,
76 INT32 xstart, INT32 ystart, INT32 xend, INT32 yend )
78 return MF_MetaParam8(dc, META_CHORD, left, top, right, bottom,
79 xstart, ystart, xend, yend);
82 /***********************************************************************
83 * MFDRV_Ellipse
85 BOOL32
86 MFDRV_Ellipse( DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom )
88 return MF_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom);
91 /***********************************************************************
92 * MFDRV_Rectangle
94 BOOL32
95 MFDRV_Rectangle(DC *dc, INT32 left, INT32 top, INT32 right, INT32 bottom)
97 return MF_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom);
100 /***********************************************************************
101 * MFDRV_RoundRect
103 BOOL32
104 MFDRV_RoundRect( DC *dc, INT32 left, INT32 top, INT32 right,
105 INT32 bottom, INT32 ell_width, INT32 ell_height )
107 return MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
108 ell_width, ell_height);
111 /***********************************************************************
112 * MFDRV_SetPixel
114 COLORREF
115 MFDRV_SetPixel( DC *dc, INT32 x, INT32 y, COLORREF color )
117 return MF_MetaParam4(dc, META_SETPIXEL, x, y,HIWORD(color),LOWORD(color));
121 /**********************************************************************
122 * MFDRV_Polyline
124 BOOL32
125 MFDRV_Polyline( DC *dc, const LPPOINT32 pt, INT32 count )
127 register int i;
128 LPPOINT16 pt16;
129 BOOL16 ret;
131 pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
132 for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
133 ret = MF_MetaPoly(dc, META_POLYLINE, pt16, count);
135 free(pt16);
136 return ret;
140 /**********************************************************************
141 * MFDRV_Polygon
143 BOOL32
144 MFDRV_Polygon( DC *dc, LPPOINT32 pt, INT32 count )
146 register int i;
147 LPPOINT16 pt16;
148 BOOL16 ret;
150 pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
151 for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
152 ret = MF_MetaPoly(dc, META_POLYGON, pt16, count);
154 free(pt16);
155 return ret;
159 /**********************************************************************
160 * PolyPolygon
162 BOOL32
163 MFDRV_PolyPolygon( DC *dc, LPPOINT32 pt, LPINT32 counts, UINT32 polygons)
165 int i,j;
166 LPPOINT16 pt16;
167 LPPOINT32 curpt=pt;
168 BOOL32 ret;
170 for (i=0;i<polygons;i++) {
171 pt16=(LPPOINT16)xmalloc(sizeof(POINT16)*counts[i]);
172 for (j=counts[i];j--;) CONV_POINT32TO16(&(curpt[j]),&(pt16[j]));
173 ret = MF_MetaPoly(dc, META_POLYGON, pt16, counts[i]);
174 free(pt16);
175 if (!ret)
176 return FALSE;
177 curpt+=counts[i];
179 return TRUE;
183 /**********************************************************************
184 * MFDRV_ExtFloodFill
186 BOOL32
187 MFDRV_ExtFloodFill( DC *dc, INT32 x, INT32 y, COLORREF color, UINT32 fillType )
189 return MF_MetaParam4(dc,META_FLOODFILL,x,y,HIWORD(color),LOWORD(color));