po: Update Ukrainian translation.
[wine/multimedia.git] / dlls / gdiplus / gdiplus_private.h
blob20812900a0357c301c26820c3fe221de8756689d
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_GP_PRIVATE_H_
20 #define __WINE_GP_PRIVATE_H_
22 #include <math.h>
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "winbase.h"
28 #include "winuser.h"
30 #include "objbase.h"
31 #include "ocidl.h"
32 #include "wine/list.h"
34 #include "gdiplus.h"
36 #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
37 #define MAX_ARC_PTS (13)
38 #define MAX_DASHLEN (16) /* this is a limitation of gdi */
39 #define INCH_HIMETRIC (2540)
41 #define VERSION_MAGIC 0xdbc01001
42 #define TENSION_CONST (0.3)
44 COLORREF ARGB2COLORREF(ARGB color) DECLSPEC_HIDDEN;
45 HBITMAP ARGB2BMP(ARGB color) DECLSPEC_HIDDEN;
46 extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
47 REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
48 extern REAL gdiplus_atan2(REAL dy, REAL dx) DECLSPEC_HIDDEN;
49 extern GpStatus hresult_to_status(HRESULT res) DECLSPEC_HIDDEN;
50 extern REAL convert_unit(REAL logpixels, GpUnit unit) DECLSPEC_HIDDEN;
52 extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics) DECLSPEC_HIDDEN;
54 extern GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result) DECLSPEC_HIDDEN;
55 extern GpStatus METAFILE_GetDC(GpMetafile* metafile, HDC *hdc) DECLSPEC_HIDDEN;
56 extern GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) DECLSPEC_HIDDEN;
57 extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN;
59 extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
60 REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN;
61 extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
62 REAL tension, REAL *x, REAL *y) DECLSPEC_HIDDEN;
64 extern void free_installed_fonts(void) DECLSPEC_HIDDEN;
66 extern void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font, HFONT *hfont) DECLSPEC_HIDDEN;
68 extern BOOL lengthen_path(GpPath *path, INT len) DECLSPEC_HIDDEN;
70 extern GpStatus trace_path(GpGraphics *graphics, GpPath *path) DECLSPEC_HIDDEN;
72 typedef struct region_element region_element;
73 extern void delete_element(region_element *element) DECLSPEC_HIDDEN;
75 extern GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result) DECLSPEC_HIDDEN;
77 static inline INT roundr(REAL x)
79 return (INT) floorf(x + 0.5);
82 static inline INT ceilr(REAL x)
84 return (INT) ceilf(x);
87 static inline REAL deg2rad(REAL degrees)
89 return M_PI * degrees / 180.0;
92 static inline ARGB color_over(ARGB bg, ARGB fg)
94 BYTE b, g, r, a;
95 BYTE bg_alpha, fg_alpha;
97 fg_alpha = (fg>>24)&0xff;
99 if (fg_alpha == 0xff) return fg;
101 if (fg_alpha == 0) return bg;
103 bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
105 if (bg_alpha == 0) return fg;
107 a = bg_alpha + fg_alpha;
108 b = ((bg&0xff)*bg_alpha + (fg&0xff)*fg_alpha)/a;
109 g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*fg_alpha)/a;
110 r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*fg_alpha)/a;
112 return (a<<24)|(r<<16)|(g<<8)|b;
115 extern const char *debugstr_rectf(CONST RectF* rc) DECLSPEC_HIDDEN;
117 extern const char *debugstr_pointf(CONST PointF* pt) DECLSPEC_HIDDEN;
119 extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
120 BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride) DECLSPEC_HIDDEN;
122 extern GpStatus convert_pixels(INT width, INT height,
123 INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
124 INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette) DECLSPEC_HIDDEN;
126 struct GpPen{
127 UINT style;
128 GpUnit unit;
129 REAL width;
130 GpLineCap endcap;
131 GpLineCap startcap;
132 GpDashCap dashcap;
133 GpCustomLineCap *customstart;
134 GpCustomLineCap *customend;
135 GpLineJoin join;
136 REAL miterlimit;
137 GpDashStyle dash;
138 REAL *dashes;
139 INT numdashes;
140 REAL offset; /* dash offset */
141 GpBrush *brush;
142 GpPenAlignment align;
145 struct GpGraphics{
146 HDC hdc;
147 HWND hwnd;
148 BOOL owndc;
149 GpImage *image;
150 SmoothingMode smoothing;
151 CompositingQuality compqual;
152 InterpolationMode interpolation;
153 PixelOffsetMode pixeloffset;
154 CompositingMode compmode;
155 TextRenderingHint texthint;
156 GpUnit unit; /* page unit */
157 REAL scale; /* page scale */
158 GpMatrix * worldtrans; /* world transform */
159 BOOL busy; /* hdc handle obtained by GdipGetDC */
160 GpRegion *clip;
161 UINT textcontrast; /* not used yet. get/set only */
162 struct list containers;
163 GraphicsContainer contid; /* last-issued container ID */
164 /* For giving the caller an HDC when we technically can't: */
165 HBITMAP temp_hbitmap;
166 int temp_hbitmap_width;
167 int temp_hbitmap_height;
168 BYTE *temp_bits;
169 HDC temp_hdc;
172 struct GpBrush{
173 GpBrushType bt;
176 struct GpHatch{
177 GpBrush brush;
178 HatchStyle hatchstyle;
179 ARGB forecol;
180 ARGB backcol;
183 struct GpSolidFill{
184 GpBrush brush;
185 ARGB color;
188 struct GpPathGradient{
189 GpBrush brush;
190 PathData pathdata;
191 ARGB centercolor;
192 GpWrapMode wrap;
193 BOOL gamma;
194 GpPointF center;
195 GpPointF focus;
196 REAL* blendfac; /* blend factors */
197 REAL* blendpos; /* blend positions */
198 INT blendcount;
201 struct GpLineGradient{
202 GpBrush brush;
203 GpPointF startpoint;
204 GpPointF endpoint;
205 ARGB startcolor;
206 ARGB endcolor;
207 RectF rect;
208 GpWrapMode wrap;
209 BOOL gamma;
210 REAL* blendfac; /* blend factors */
211 REAL* blendpos; /* blend positions */
212 INT blendcount;
213 ARGB* pblendcolor; /* preset blend colors */
214 REAL* pblendpos; /* preset blend positions */
215 INT pblendcount;
218 struct GpTexture{
219 GpBrush brush;
220 GpMatrix *transform;
221 GpImage *image;
222 GpImageAttributes *imageattributes;
223 BYTE *bitmap_bits; /* image bits converted to ARGB and run through imageattributes */
226 struct GpPath{
227 GpFillMode fill;
228 GpPathData pathdata;
229 BOOL newfigure; /* whether the next drawing action starts a new figure */
230 INT datalen; /* size of the arrays in pathdata */
233 struct GpMatrix{
234 REAL matrix[6];
237 struct GpPathIterator{
238 GpPathData pathdata;
239 INT subpath_pos; /* for NextSubpath methods */
240 INT marker_pos; /* for NextMarker methods */
241 INT pathtype_pos; /* for NextPathType methods */
244 struct GpCustomLineCap{
245 GpPathData pathdata;
246 BOOL fill; /* TRUE for fill, FALSE for stroke */
247 GpLineCap cap; /* as far as I can tell, this value is ignored */
248 REAL inset; /* how much to adjust the end of the line */
249 GpLineJoin join;
250 REAL scale;
253 struct GpAdustableArrowCap{
254 GpCustomLineCap cap;
257 struct GpImage{
258 IPicture* picture;
259 ImageType type;
260 GUID format;
261 UINT flags;
262 UINT palette_flags;
263 UINT palette_count;
264 UINT palette_size;
265 ARGB *palette_entries;
266 REAL xres, yres;
269 struct GpMetafile{
270 GpImage image;
271 GpRectF bounds;
272 GpUnit unit;
273 MetafileType metafile_type;
274 HENHMETAFILE hemf;
276 /* recording */
277 HDC record_dc;
278 GpGraphics *record_graphics;
279 BYTE *comment_data;
280 DWORD comment_data_size;
281 DWORD comment_data_length;
283 /* playback */
284 GpGraphics *playback_graphics;
285 HDC playback_dc;
286 GpPointF playback_points[3];
287 HANDLETABLE *handle_table;
288 int handle_count;
291 struct GpBitmap{
292 GpImage image;
293 INT width;
294 INT height;
295 PixelFormat format;
296 ImageLockMode lockmode;
297 INT numlocks;
298 BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
299 HBITMAP hbitmap;
300 HDC hdc;
301 BYTE *bits; /* actual image bits if this is a DIB */
302 INT stride; /* stride of bits if this is a DIB */
303 BYTE *own_bits; /* image bits that need to be freed with this object */
304 INT lockx, locky; /* X and Y coordinates of the rect when a bitmap is locked for writing. */
307 struct GpCachedBitmap{
308 GpImage *image;
311 struct color_key{
312 BOOL enabled;
313 ARGB low;
314 ARGB high;
317 struct color_matrix{
318 BOOL enabled;
319 ColorMatrixFlags flags;
320 ColorMatrix colormatrix;
321 ColorMatrix graymatrix;
324 struct color_remap_table{
325 BOOL enabled;
326 INT mapsize;
327 GDIPCONST ColorMap *colormap;
330 struct GpImageAttributes{
331 WrapMode wrap;
332 ARGB outside_color;
333 BOOL clamp;
334 struct color_key colorkeys[ColorAdjustTypeCount];
335 struct color_matrix colormatrices[ColorAdjustTypeCount];
336 struct color_remap_table colorremaptables[ColorAdjustTypeCount];
337 BOOL gamma_enabled[ColorAdjustTypeCount];
338 REAL gamma[ColorAdjustTypeCount];
341 struct GpFont{
342 LOGFONTW lfw;
343 REAL emSize;
344 REAL pixel_size;
345 UINT height;
346 LONG line_spacing;
347 Unit unit;
350 struct GpStringFormat{
351 INT attr;
352 LANGID lang;
353 LANGID digitlang;
354 StringAlignment align;
355 StringTrimming trimming;
356 HotkeyPrefix hkprefix;
357 StringAlignment vertalign;
358 StringDigitSubstitute digitsub;
359 INT tabcount;
360 REAL firsttab;
361 REAL *tabs;
362 CharacterRange *character_ranges;
363 INT range_count;
366 struct GpFontCollection{
367 GpFontFamily **FontFamilies;
368 INT count;
369 INT allocated;
372 struct GpFontFamily{
373 NEWTEXTMETRICW tmw;
374 WCHAR FamilyName[LF_FACESIZE];
377 /* internal use */
378 typedef enum RegionType
380 RegionDataRect = 0x10000000,
381 RegionDataPath = 0x10000001,
382 RegionDataEmptyRect = 0x10000002,
383 RegionDataInfiniteRect = 0x10000003,
384 } RegionType;
386 struct region_element
388 DWORD type; /* Rectangle, Path, SpecialRectangle, or CombineMode */
389 union
391 GpRectF rect;
392 struct
394 GpPath* path;
395 struct
397 DWORD size;
398 DWORD magic;
399 DWORD count;
400 DWORD flags;
401 } pathheader;
402 } pathdata;
403 struct
405 struct region_element *left; /* the original region */
406 struct region_element *right; /* what *left was combined with */
407 } combine;
408 } elementdata;
411 struct GpRegion{
412 struct
414 DWORD size;
415 DWORD checksum;
416 DWORD magic;
417 DWORD num_children;
418 } header;
419 region_element node;
422 typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
423 GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
424 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
425 INT lineno, const RectF *bounds, void *user_data);
427 GpStatus gdip_format_string(HDC hdc,
428 GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
429 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
430 gdip_format_string_callback callback, void *user_data) DECLSPEC_HIDDEN;
432 #endif