source: Daodan/MinGW/include/gdiplus/gdiplusheaders.h@ 1141

Last change on this file since 1141 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 16.6 KB
Line 
1/*
2 * gdiplusheaders.h
3 *
4 * GDI+ Bitmap, CachedBitmap, CustomLineCap, Font, FontCollection,
5 * FontFamily, Image, InstalledFontCollection, PrivateFontCollection,
6 * Region class definitions.
7 * Implementation of these classes is in gdiplusimpl.h.
8 *
9 * This file is part of the w32api package.
10 *
11 * Contributors:
12 * Created by Markus Koenig <markus@stber-koenig.de>
13 *
14 * THIS SOFTWARE IS NOT COPYRIGHTED
15 *
16 * This source code is offered for use in the public domain. You may
17 * use, modify or distribute it freely.
18 *
19 * This code is distributed in the hope that it will be useful but
20 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
21 * DISCLAIMED. This includes but is not limited to warranties of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 */
25
26#ifndef __GDIPLUS_HEADERS_H
27#define __GDIPLUS_HEADERS_H
28#if __GNUC__ >=3
29#pragma GCC system_header
30#endif
31
32#ifndef __cplusplus
33#error "A C++ compiler is required to include gdiplusheaders.h."
34#endif
35
36/*
37 * Note: Virtual inline functions (dtors, Clone()) are implemented here: If
38 * these were defined outside class scope, the compiler would always generate
39 * code for them (and the vtable), even if these classes were never used.
40 */
41
42class Bitmap;
43class Effect;
44class FontCollection;
45class FontFamily;
46class Graphics;
47class GraphicsPath;
48class Matrix;
49class Pen;
50
51class Image: public GdiplusBase
52{
53 friend class Bitmap;
54 friend class Metafile;
55 friend class CachedBitmap;
56 friend class Graphics;
57 friend class TextureBrush;
58
59public:
60 static Image* FromFile(const WCHAR *filename,
61 BOOL useEmbeddedColorManagement = FALSE);
62 static Image* FromStream(IStream *stream,
63 BOOL useEmbeddedColorManagement = FALSE);
64
65 Image(const WCHAR *filename, BOOL useEmbeddedColorManagement = FALSE);
66 Image(IStream *stream, BOOL useEmbeddedColorManagement = FALSE);
67
68 virtual ~Image()
69 {
70 DllExports::GdipDisposeImage(nativeImage);
71 }
72 virtual Image* Clone() const
73 {
74 GpImage *cloneImage = NULL;
75 Status status = updateStatus(DllExports::GdipCloneImage(
76 nativeImage, &cloneImage));
77 if (status == Ok) {
78 Image *result = new Image(cloneImage, lastStatus);
79 if (!result) {
80 DllExports::GdipDisposeImage(cloneImage);
81 lastStatus = OutOfMemory;
82 }
83 return result;
84 } else {
85 return NULL;
86 }
87 }
88
89 Status FindFirstItem(ImageItemData *item);
90 Status FindNextItem(ImageItemData *item);
91 Status GetAllPropertyItems(UINT totalBufferSize,
92 UINT numProperties, PropertyItem *allItems);
93 Status GetBounds(RectF *srcRect, Unit *srcUnit);
94 Status GetEncoderParameterList(const CLSID *clsidEncoder,
95 UINT size, EncoderParameters *buffer);
96 UINT GetEncoderParameterListSize(const CLSID *clsidEncoder);
97 UINT GetFlags();
98 UINT GetFrameCount(const GUID *dimensionID);
99 UINT GetFrameDimensionsCount();
100 Status GetFrameDimensionsList(GUID *dimensionIDs, UINT count);
101 UINT GetHeight();
102 REAL GetHorizontalResolution();
103 Status GetItemData(ImageItemData *item);
104 Status GetPalette(ColorPalette *palette, INT size);
105 INT GetPaletteSize();
106 Status GetPhysicalDimension(SizeF *size);
107 PixelFormat GetPixelFormat();
108 UINT GetPropertyCount();
109 Status GetPropertyIdList(UINT numOfProperty, PROPID *list);
110 Status GetPropertyItem(PROPID propId, UINT propSize,
111 PropertyItem *buffer);
112 UINT GetPropertyItemSize(PROPID propId);
113 Status GetPropertySize(UINT *totalBufferSize, UINT *numProperties);
114 Status GetRawFormat(GUID *format);
115 Image* GetThumbnailImage(UINT thumbWidth, UINT thumbHeight,
116 GetThumbnailImageAbort callback, VOID *callbackData);
117 ImageType GetType() const;
118 REAL GetVerticalResolution();
119 UINT GetWidth();
120 Status RemovePropertyItem(PROPID propId);
121 Status RotateFlip(RotateFlipType rotateFlipType);
122 Status Save(IStream *stream, const CLSID *clsidEncoder,
123 const EncoderParameters *encoderParams);
124 Status Save(const WCHAR *filename, const CLSID *clsidEncoder,
125 const EncoderParameters *encoderParams);
126 Status SaveAdd(const EncoderParameters *encoderParams);
127 Status SaveAdd(Image *newImage, const EncoderParameters *encoderParams);
128 Status SelectActiveFrame(const GUID *dimensionID, UINT frameIndex);
129 Status SetAbort(GdiplusAbort *pIAbort);
130 Status SetPalette(const ColorPalette *palette);
131 Status SetPropertyItem(const PropertyItem *item);
132
133 Status GetLastStatus() const
134 {
135 Status result = lastStatus;
136 lastStatus = Ok;
137 return result;
138 }
139
140private:
141 Image(GpImage *image, Status status):
142 nativeImage(image), lastStatus(status) {}
143 Image(const Image&);
144 Image& operator=(const Image&);
145
146 Status updateStatus(Status newStatus) const
147 {
148 if (newStatus != Ok) lastStatus = newStatus;
149 return newStatus;
150 }
151
152 GpImage *nativeImage;
153 mutable Status lastStatus;
154};
155
156class Bitmap: public Image
157{
158public:
159 static Bitmap* FromBITMAPINFO(const BITMAPINFO *gdiBitmapInfo,
160 VOID *gdiBitmapData);
161 static Bitmap* FromDirectDrawSurface7(IDirectDrawSurface7 *surface);
162 static Bitmap* FromFile(const WCHAR *filename,
163 BOOL useEmbeddedColorManagement = FALSE);
164 static Bitmap* FromHBITMAP(HBITMAP hbm, HPALETTE hpal);
165 static Bitmap* FromHICON(HICON icon);
166 static Bitmap* FromResource(HINSTANCE hInstance,
167 const WCHAR *bitmapName);
168 static Bitmap* FromStream(IStream *stream,
169 BOOL useEmbeddedColorManagement = FALSE);
170 static Status ApplyEffect(Bitmap **inputs, INT numInputs,
171 Effect *effect, RECT *ROI,
172 RECT *outputRect, Bitmap **output);
173 static Status InitializePalette(ColorPalette *palette,
174 PaletteType paletteType, INT optimalColors,
175 BOOL useTransparentColor, Bitmap *bitmap);
176
177 Bitmap(const BITMAPINFO *gdiBitmapInfo, VOID *gdiBitmapData);
178 Bitmap(IDirectDrawSurface7 *surface);
179 Bitmap(const WCHAR *filename, BOOL useEmbeddedColorManagement = FALSE);
180 Bitmap(HBITMAP hbm, HPALETTE hpal);
181 Bitmap(HICON hicon);
182 Bitmap(HINSTANCE hInstance, const WCHAR *bitmapName);
183 Bitmap(IStream *stream, BOOL useEmbeddedColorManagement = FALSE);
184 Bitmap(INT width, INT height, Graphics *target);
185 Bitmap(INT width, INT height, PixelFormat format = PixelFormat32bppARGB);
186 Bitmap(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0);
187
188 virtual ~Bitmap()
189 {
190 }
191 virtual Bitmap* Clone() const
192 {
193 GpImage *cloneImage = NULL;
194 Status status = updateStatus(DllExports::GdipCloneImage(
195 nativeImage, &cloneImage));
196 if (status == Ok) {
197 Bitmap *result = new Bitmap(cloneImage, lastStatus);
198 if (!result) {
199 DllExports::GdipDisposeImage(cloneImage);
200 lastStatus = OutOfMemory;
201 }
202 return result;
203 } else {
204 return NULL;
205 }
206 }
207
208 Bitmap* Clone(const RectF& rect, PixelFormat format) const;
209 Bitmap* Clone(const Rect& rect, PixelFormat format) const;
210 Bitmap* Clone(REAL x, REAL y, REAL width, REAL height,
211 PixelFormat format) const;
212 Bitmap* Clone(INT x, INT y, INT width, INT height,
213 PixelFormat format) const;
214
215 Status ApplyEffect(Effect *effect, RECT *ROI);
216 Status ConvertFormat(PixelFormat format, DitherType ditherType,
217 PaletteType paletteType, ColorPalette *palette,
218 REAL alphaThresholdPercent);
219 Status GetHBITMAP(const Color& colorBackground, HBITMAP *hbmReturn) const;
220 Status GetHICON(HICON *icon) const;
221 Status GetHistogram(HistogramFormat format, UINT numberOfEntries,
222 UINT *channel0, UINT *channel1,
223 UINT *channel2, UINT *channel3) const;
224 Status GetHistogramSize(HistogramFormat format,
225 UINT *numberOfEntries) const;
226 Status GetPixel(INT x, INT y, Color *color) const;
227 Status LockBits(const Rect *rect, UINT flags, PixelFormat format,
228 BitmapData *lockedBitmapData);
229 Status SetPixel(INT x, INT y, const Color& color);
230 Status SetResolution(REAL xdpi, REAL ydpi);
231 Status UnlockBits(BitmapData *lcokedBitmapData);
232
233private:
234 Bitmap(GpImage *image, Status status): Image(image, status) {}
235 Bitmap(const Bitmap&);
236 Bitmap& operator=(const Bitmap&);
237};
238
239class CachedBitmap: public GdiplusBase
240{
241 friend class Graphics;
242
243public:
244 CachedBitmap(Bitmap *bitmap, Graphics *graphics);
245 ~CachedBitmap();
246
247 Status GetLastStatus() const
248 {
249 return lastStatus;
250 }
251
252private:
253 CachedBitmap(const CachedBitmap&);
254 CachedBitmap& operator=(const CachedBitmap&);
255
256 GpCachedBitmap *nativeCachedBitmap;
257 Status lastStatus;
258};
259
260class CustomLineCap: public GdiplusBase
261{
262 friend class AdjustableArrowCap;
263 friend class Pen;
264
265public:
266 CustomLineCap(const GraphicsPath *fillPath,
267 const GraphicsPath *strokePath,
268 LineCap baseCap = LineCapFlat,
269 REAL baseInset = 0.0f);
270
271 virtual ~CustomLineCap()
272 {
273 DllExports::GdipDeleteCustomLineCap(nativeCustomLineCap);
274 }
275 virtual CustomLineCap* Clone() const
276 {
277 GpCustomLineCap *cloneCustomLineCap = NULL;
278 Status status = updateStatus(DllExports::GdipCloneCustomLineCap(
279 nativeCustomLineCap, &cloneCustomLineCap));
280 if (status == Ok) {
281 CustomLineCap *result = new CustomLineCap(
282 cloneCustomLineCap, lastStatus);
283 if (!result) {
284 DllExports::GdipDeleteCustomLineCap(cloneCustomLineCap);
285 lastStatus = OutOfMemory;
286 }
287 return result;
288 } else {
289 return NULL;
290 }
291 }
292
293 LineCap GetBaseCap() const;
294 REAL GetBaseInset() const;
295 Status GetStrokeCaps(LineCap *startCap, LineCap *endCap) const;
296 LineJoin GetStrokeJoin() const;
297 REAL GetWidthScale() const;
298 Status SetBaseCap(LineCap baseCap);
299 Status SetBaseInset(REAL inset);
300 Status SetStrokeCap(LineCap strokeCap);
301 Status SetStrokeCaps(LineCap startCap, LineCap endCap);
302 Status SetStrokeJoin(LineJoin lineJoin);
303 Status SetWidthScale(REAL widthScale);
304
305 Status GetLastStatus() const
306 {
307 Status result = lastStatus;
308 lastStatus = Ok;
309 return result;
310 }
311
312private:
313 CustomLineCap(GpCustomLineCap *customLineCap, Status status):
314 nativeCustomLineCap(customLineCap), lastStatus(status) {}
315 CustomLineCap(const CustomLineCap&);
316 CustomLineCap& operator=(const CustomLineCap&);
317
318 Status updateStatus(Status newStatus) const
319 {
320 if (newStatus != Ok) lastStatus = newStatus;
321 return newStatus;
322 }
323
324 GpCustomLineCap *nativeCustomLineCap;
325 mutable Status lastStatus;
326};
327
328class Font: public GdiplusBase
329{
330 friend class Graphics;
331
332public:
333 Font(const FontFamily *family, REAL emSize,
334 INT style = FontStyleRegular,
335 Unit unit = UnitPoint);
336 Font(HDC hdc, HFONT hfont);
337 Font(HDC hdc, const LOGFONTA *logfont);
338 Font(HDC hdc, const LOGFONTW *logfont);
339 Font(HDC hdc);
340 Font(const WCHAR *familyName, REAL emSize,
341 INT style = FontStyleRegular,
342 Unit unit = UnitPoint,
343 const FontCollection *fontCollection = NULL);
344 ~Font();
345 Font* Clone() const;
346
347 Status GetFamily(FontFamily *family) const;
348 REAL GetHeight(const Graphics *graphics) const;
349 REAL GetHeight(REAL dpi) const;
350 Status GetLogFontA(const Graphics *graphics, LOGFONTA *logfontA) const;
351 Status GetLogFontW(const Graphics *graphics, LOGFONTW *logfontW) const;
352 REAL GetSize() const;
353 INT GetStyle() const;
354 Unit GetUnit() const;
355
356 Status GetLastStatus() const
357 {
358 return lastStatus;
359 }
360 BOOL IsAvailable() const
361 {
362 return nativeFont != NULL;
363 }
364
365private:
366 Font(GpFont *font, Status status):
367 nativeFont(font), lastStatus(status) {}
368 Font(const Font&);
369 Font& operator=(const Font&);
370
371 Status updateStatus(Status newStatus) const
372 {
373 if (newStatus != Ok) lastStatus = newStatus;
374 return newStatus;
375 }
376
377 GpFont *nativeFont;
378 mutable Status lastStatus;
379};
380
381class FontCollection: public GdiplusBase
382{
383 friend class InstalledFontCollection;
384 friend class PrivateFontCollection;
385 friend class Font;
386 friend class FontFamily;
387
388public:
389 FontCollection();
390 virtual ~FontCollection() {}
391
392 Status GetFamilies(INT numSought, FontFamily *families,
393 INT *numFound) const;
394 INT GetFamilyCount() const;
395
396 Status GetLastStatus() const
397 {
398 return lastStatus;
399 }
400
401private:
402 FontCollection(const FontCollection&);
403 FontCollection& operator=(const FontCollection&);
404
405 Status updateStatus(Status newStatus) const
406 {
407 return lastStatus = newStatus;
408 }
409
410 GpFontCollection *nativeFontCollection;
411 mutable Status lastStatus;
412};
413
414class FontFamily: public GdiplusBase
415{
416 friend class Font;
417 friend class FontCollection;
418 friend class GraphicsPath;
419
420public:
421 static const FontFamily* GenericMonospace();
422 static const FontFamily* GenericSansSerif();
423 static const FontFamily* GenericSerif();
424
425 FontFamily();
426 FontFamily(const WCHAR *name,
427 const FontCollection *fontCollection = NULL);
428 ~FontFamily();
429 FontFamily* Clone() const;
430
431 UINT16 GetCellAscent(INT style) const;
432 UINT16 GetCellDescent(INT style) const;
433 UINT16 GetEmHeight(INT style) const;
434 Status GetFamilyName(WCHAR name[LF_FACESIZE],
435 LANGID language = LANG_NEUTRAL) const;
436 UINT16 GetLineSpacing(INT style) const;
437 BOOL IsStyleAvailable(INT style) const;
438
439 Status GetLastStatus() const
440 {
441 Status result = lastStatus;
442 lastStatus = Ok;
443 return result;
444 }
445 BOOL IsAvailable() const
446 {
447 return nativeFontFamily != NULL;
448 }
449
450private:
451 FontFamily(GpFontFamily *fontFamily, Status status):
452 nativeFontFamily(fontFamily), lastStatus(status) {}
453 FontFamily(const FontFamily&);
454 FontFamily& operator=(const FontFamily&);
455
456 Status updateStatus(Status newStatus) const
457 {
458 if (newStatus != Ok) lastStatus = newStatus;
459 return newStatus;
460 }
461
462 GpFontFamily *nativeFontFamily;
463 mutable Status lastStatus;
464};
465
466class InstalledFontCollection: public FontCollection
467{
468public:
469 InstalledFontCollection();
470 virtual ~InstalledFontCollection() {}
471};
472
473class PrivateFontCollection: public FontCollection
474{
475public:
476 PrivateFontCollection();
477
478 virtual ~PrivateFontCollection()
479 {
480 DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection);
481 }
482
483 Status AddFontFile(const WCHAR *filename);
484 Status AddMemoryFont(const VOID *memory, INT length);
485};
486
487class Region: public GdiplusBase
488{
489 friend class Graphics;
490
491public:
492 static Region* FromHRGN(HRGN hrgn);
493
494 Region();
495 Region(const RectF& rect);
496 Region(const Rect& rect);
497 Region(const GraphicsPath *path);
498 Region(const BYTE *regionData, INT size);
499 Region(HRGN hrgn);
500 ~Region();
501 Region* Clone() const;
502
503 Status Complement(const RectF& rect);
504 Status Complement(const Rect& rect);
505 Status Complement(const Region *region);
506 Status Complement(const GraphicsPath *path);
507 BOOL Equals(const Region *region, const Graphics *graphics) const;
508 Status Exclude(const RectF& rect);
509 Status Exclude(const Rect& rect);
510 Status Exclude(const Region *region);
511 Status Exclude(const GraphicsPath *path);
512 Status GetBounds(RectF *rect, const Graphics *graphics) const;
513 Status GetBounds(Rect *rect, const Graphics *graphics) const;
514 Status GetData(BYTE *buffer, UINT bufferSize, UINT *sizeFilled) const;
515 UINT GetDataSize() const;
516 HRGN GetHRGN(const Graphics *graphics) const;
517 Status GetRegionScans(const Matrix *matrix,
518 RectF *rects, INT *count) const;
519 Status GetRegionScans(const Matrix *matrix,
520 Rect *rects, INT *count) const;
521 UINT GetRegionScansCount(const Matrix *matrix) const;
522 Status Intersect(const RectF& rect);
523 Status Intersect(const Rect& rect);
524 Status Intersect(const Region *region);
525 Status Intersect(const GraphicsPath *path);
526 BOOL IsEmpty(const Graphics *graphics) const;
527 BOOL IsInfinite(const Graphics *graphics) const;
528 BOOL IsVisible(REAL x, REAL y,
529 const Graphics *graphics = NULL) const;
530 BOOL IsVisible(INT x, INT y,
531 const Graphics *graphics = NULL) const;
532 BOOL IsVisible(const PointF& point,
533 const Graphics *graphics = NULL) const;
534 BOOL IsVisible(const Point& point,
535 const Graphics *graphics = NULL) const;
536 BOOL IsVisible(REAL x, REAL y, REAL width, REAL height,
537 const Graphics *graphics = NULL) const;
538 BOOL IsVisible(INT x, INT y, INT width, INT height,
539 const Graphics *graphics = NULL) const;
540 BOOL IsVisible(const RectF& rect,
541 const Graphics *graphics = NULL) const;
542 BOOL IsVisible(const Rect& rect,
543 const Graphics *graphics = NULL) const;
544 Status MakeEmpty();
545 Status MakeInfinite();
546 Status Transform(const Matrix *matrix);
547 Status Translate(REAL dx, REAL dy);
548 Status Translate(INT dx, INT dy);
549 Status Union(const RectF& rect);
550 Status Union(const Rect& rect);
551 Status Union(const Region *region);
552 Status Union(const GraphicsPath *path);
553 Status Xor(const RectF& rect);
554 Status Xor(const Rect& rect);
555 Status Xor(const Region *region);
556 Status Xor(const GraphicsPath *path);
557
558 Status GetLastStatus() const
559 {
560 Status result = lastStatus;
561 lastStatus = Ok;
562 return result;
563 }
564
565private:
566 Region(GpRegion *region, Status status):
567 nativeRegion(region), lastStatus(status) {}
568 Region(const Region&);
569 Region& operator=(const Region&);
570
571 Status updateStatus(Status newStatus) const
572 {
573 if (newStatus != Ok) lastStatus = newStatus;
574 return newStatus;
575 }
576
577 GpRegion *nativeRegion;
578 mutable Status lastStatus;
579};
580
581#endif /* __GDIPLUS_HEADERS_H */
Note: See TracBrowser for help on using the repository browser.