gdiplusgraphics.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  1. /*
  2. * gdiplusgraphics.h
  3. *
  4. * GDI+ Graphics class
  5. *
  6. * This file is part of the w32api package.
  7. *
  8. * Contributors:
  9. * Created by Markus Koenig <markus@stber-koenig.de>
  10. *
  11. * THIS SOFTWARE IS NOT COPYRIGHTED
  12. *
  13. * This source code is offered for use in the public domain. You may
  14. * use, modify or distribute it freely.
  15. *
  16. * This code is distributed in the hope that it will be useful but
  17. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18. * DISCLAIMED. This includes but is not limited to warranties of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. */
  22. #ifndef __GDIPLUS_GRAPHICS_H
  23. #define __GDIPLUS_GRAPHICS_H
  24. #if __GNUC__ >=3
  25. #pragma GCC system_header
  26. #endif
  27. #ifndef __cplusplus
  28. #error "A C++ compiler is required to include gdiplusgraphics.h."
  29. #endif
  30. class Graphics: public GdiplusBase
  31. {
  32. friend class Bitmap;
  33. friend class CachedBitmap;
  34. friend class Font;
  35. friend class GraphicsPath;
  36. friend class Metafile;
  37. friend class Region;
  38. public:
  39. static Graphics* FromHDC(HDC hdc)
  40. {
  41. return new Graphics(hdc);
  42. }
  43. static Graphics* FromHDC(HDC hdc, HANDLE hdevice)
  44. {
  45. return new Graphics(hdc, hdevice);
  46. }
  47. static Graphics* FromHWND(HWND hwnd, BOOL icm = FALSE)
  48. {
  49. return new Graphics(hwnd, icm);
  50. }
  51. static Graphics* FromImage(Image *image)
  52. {
  53. return new Graphics(image);
  54. }
  55. static HPALETTE GetHalftonePalette()
  56. {
  57. return DllExports::GdipCreateHalftonePalette();
  58. }
  59. Graphics(Image *image): nativeGraphics(NULL), lastStatus(Ok)
  60. {
  61. lastStatus = DllExports::GdipGetImageGraphicsContext(
  62. image ? image->nativeImage : NULL,
  63. &nativeGraphics);
  64. }
  65. Graphics(HDC hdc): nativeGraphics(NULL), lastStatus(Ok)
  66. {
  67. lastStatus = DllExports::GdipCreateFromHDC(
  68. hdc, &nativeGraphics);
  69. }
  70. Graphics(HDC hdc, HANDLE hdevice): nativeGraphics(NULL), lastStatus(Ok)
  71. {
  72. lastStatus = DllExports::GdipCreateFromHDC2(
  73. hdc, hdevice, &nativeGraphics);
  74. }
  75. Graphics(HWND hwnd, BOOL icm = FALSE):
  76. nativeGraphics(NULL), lastStatus(Ok)
  77. {
  78. if (icm) {
  79. lastStatus = DllExports::GdipCreateFromHWNDICM(
  80. hwnd, &nativeGraphics);
  81. } else {
  82. lastStatus = DllExports::GdipCreateFromHWND(
  83. hwnd, &nativeGraphics);
  84. }
  85. }
  86. ~Graphics()
  87. {
  88. DllExports::GdipDeleteGraphics(nativeGraphics);
  89. }
  90. Status AddMetafileComment(const BYTE *data, UINT sizeData)
  91. {
  92. return updateStatus(DllExports::GdipComment(
  93. nativeGraphics, sizeData, data));
  94. }
  95. GraphicsContainer BeginContainer()
  96. {
  97. GraphicsContainer result = 0;
  98. updateStatus(DllExports::GdipBeginContainer2(
  99. nativeGraphics, &result));
  100. return result;
  101. }
  102. GraphicsContainer BeginContainer(const RectF& dstrect,
  103. const RectF& srcrect, Unit unit)
  104. {
  105. GraphicsContainer result = 0;
  106. updateStatus(DllExports::GdipBeginContainer(
  107. nativeGraphics, &dstrect, &srcrect, unit,
  108. &result));
  109. return result;
  110. }
  111. GraphicsContainer BeginContainer(const Rect& dstrect,
  112. const Rect& srcrect, Unit unit)
  113. {
  114. GraphicsContainer result = 0;
  115. updateStatus(DllExports::GdipBeginContainerI(
  116. nativeGraphics, &dstrect, &srcrect, unit,
  117. &result));
  118. return result;
  119. }
  120. Status Clear(const Color& color)
  121. {
  122. return updateStatus(DllExports::GdipGraphicsClear(
  123. nativeGraphics, color.GetValue()));
  124. }
  125. Status DrawArc(const Pen *pen, REAL x, REAL y, REAL width, REAL height,
  126. REAL startAngle, REAL sweepAngle)
  127. {
  128. return updateStatus(DllExports::GdipDrawArc(
  129. nativeGraphics, pen ? pen->nativePen : NULL,
  130. x, y, width, height, startAngle, sweepAngle));
  131. }
  132. Status DrawArc(const Pen *pen, INT x, INT y, INT width, INT height,
  133. REAL startAngle, REAL sweepAngle)
  134. {
  135. return updateStatus(DllExports::GdipDrawArcI(
  136. nativeGraphics, pen ? pen->nativePen : NULL,
  137. x, y, width, height, startAngle, sweepAngle));
  138. }
  139. Status DrawArc(const Pen *pen, const RectF& rect,
  140. REAL startAngle, REAL sweepAngle)
  141. {
  142. return updateStatus(DllExports::GdipDrawArc(
  143. nativeGraphics, pen ? pen->nativePen : NULL,
  144. rect.X, rect.Y, rect.Width, rect.Height,
  145. startAngle, sweepAngle));
  146. }
  147. Status DrawArc(const Pen *pen, const Rect& rect,
  148. REAL startAngle, REAL sweepAngle)
  149. {
  150. return updateStatus(DllExports::GdipDrawArcI(
  151. nativeGraphics, pen ? pen->nativePen : NULL,
  152. rect.X, rect.Y, rect.Width, rect.Height,
  153. startAngle, sweepAngle));
  154. }
  155. Status DrawBezier(const Pen *pen,
  156. REAL x1, REAL y1, REAL x2, REAL y2,
  157. REAL x3, REAL y3, REAL x4, REAL y4)
  158. {
  159. return updateStatus(DllExports::GdipDrawBezier(
  160. nativeGraphics, pen ? pen->nativePen : NULL,
  161. x1, y1, x2, y2, x3, y3, x4, y4));
  162. }
  163. Status DrawBezier(const Pen *pen,
  164. INT x1, INT y1, INT x2, INT y2,
  165. INT x3, INT y3, INT x4, INT y4)
  166. {
  167. return updateStatus(DllExports::GdipDrawBezierI(
  168. nativeGraphics, pen ? pen->nativePen : NULL,
  169. x1, y1, x2, y2, x3, y3, x4, y4));
  170. }
  171. Status DrawBezier(const Pen *pen,
  172. const PointF& pt1, const PointF& pt2,
  173. const PointF& pt3, const PointF& pt4)
  174. {
  175. return updateStatus(DllExports::GdipDrawBezier(
  176. nativeGraphics, pen ? pen->nativePen : NULL,
  177. pt1.X, pt1.Y, pt2.X, pt2.Y,
  178. pt3.X, pt3.Y, pt4.X, pt4.Y));
  179. }
  180. Status DrawBezier(const Pen *pen,
  181. const Point& pt1, const Point& pt2,
  182. const Point& pt3, const Point& pt4)
  183. {
  184. return updateStatus(DllExports::GdipDrawBezierI(
  185. nativeGraphics, pen ? pen->nativePen : NULL,
  186. pt1.X, pt1.Y, pt2.X, pt2.Y,
  187. pt3.X, pt3.Y, pt4.X, pt4.Y));
  188. }
  189. Status DrawBeziers(const Pen *pen, const PointF *points, INT count)
  190. {
  191. return updateStatus(DllExports::GdipDrawBeziers(
  192. nativeGraphics, pen ? pen->nativePen : NULL,
  193. points, count));
  194. }
  195. Status DrawBeziers(const Pen *pen, const Point *points, INT count)
  196. {
  197. return updateStatus(DllExports::GdipDrawBeziersI(
  198. nativeGraphics, pen ? pen->nativePen : NULL,
  199. points, count));
  200. }
  201. Status DrawCachedBitmap(CachedBitmap *cb, INT x, INT y)
  202. {
  203. return updateStatus(DllExports::GdipDrawCachedBitmap(
  204. nativeGraphics,
  205. cb ? cb->nativeCachedBitmap : NULL,
  206. x, y));
  207. }
  208. Status DrawClosedCurve(const Pen *pen, const PointF *points, INT count)
  209. {
  210. return updateStatus(DllExports::GdipDrawClosedCurve(
  211. nativeGraphics, pen ? pen->nativePen : NULL,
  212. points, count));
  213. }
  214. Status DrawClosedCurve(const Pen *pen, const Point *points, INT count)
  215. {
  216. return updateStatus(DllExports::GdipDrawClosedCurveI(
  217. nativeGraphics, pen ? pen->nativePen : NULL,
  218. points, count));
  219. }
  220. Status DrawClosedCurve(const Pen *pen, const PointF *points, INT count,
  221. REAL tension)
  222. {
  223. return updateStatus(DllExports::GdipDrawClosedCurve2(
  224. nativeGraphics, pen ? pen->nativePen : NULL,
  225. points, count, tension));
  226. }
  227. Status DrawClosedCurve(const Pen *pen, const Point *points, INT count,
  228. REAL tension)
  229. {
  230. return updateStatus(DllExports::GdipDrawClosedCurve2I(
  231. nativeGraphics, pen ? pen->nativePen : NULL,
  232. points, count, tension));
  233. }
  234. Status DrawCurve(const Pen *pen, const PointF *points, INT count)
  235. {
  236. return updateStatus(DllExports::GdipDrawCurve(
  237. nativeGraphics, pen ? pen->nativePen : NULL,
  238. points, count));
  239. }
  240. Status DrawCurve(const Pen *pen, const Point *points, INT count)
  241. {
  242. return updateStatus(DllExports::GdipDrawCurveI(
  243. nativeGraphics, pen ? pen->nativePen : NULL,
  244. points, count));
  245. }
  246. Status DrawCurve(const Pen *pen, const PointF *points, INT count,
  247. REAL tension)
  248. {
  249. return updateStatus(DllExports::GdipDrawCurve2(
  250. nativeGraphics, pen ? pen->nativePen : NULL,
  251. points, count, tension));
  252. }
  253. Status DrawCurve(const Pen *pen, const Point *points, INT count,
  254. REAL tension)
  255. {
  256. return updateStatus(DllExports::GdipDrawCurve2I(
  257. nativeGraphics, pen ? pen->nativePen : NULL,
  258. points, count, tension));
  259. }
  260. Status DrawCurve(const Pen *pen, const PointF *points, INT count,
  261. INT offset, INT numberOfSegments, REAL tension)
  262. {
  263. return updateStatus(DllExports::GdipDrawCurve3(
  264. nativeGraphics, pen ? pen->nativePen : NULL,
  265. points, count, offset,
  266. numberOfSegments, tension));
  267. }
  268. Status DrawCurve(const Pen *pen, const Point *points, INT count,
  269. INT offset, INT numberOfSegments, REAL tension)
  270. {
  271. return updateStatus(DllExports::GdipDrawCurve3I(
  272. nativeGraphics, pen ? pen->nativePen : NULL,
  273. points, count, offset,
  274. numberOfSegments, tension));
  275. }
  276. Status DrawDriverString(const UINT16 *text, INT length,
  277. const Font *font, const Brush *brush,
  278. const PointF *positions, INT flags,
  279. const Matrix *matrix)
  280. {
  281. return updateStatus(DllExports::GdipDrawDriverString(
  282. nativeGraphics, text, length,
  283. font ? font->nativeFont : NULL,
  284. brush ? brush->nativeBrush : NULL,
  285. positions, flags,
  286. matrix ? matrix->nativeMatrix : NULL));
  287. }
  288. Status DrawEllipse(const Pen *pen,
  289. REAL x, REAL y, REAL width, REAL height)
  290. {
  291. return updateStatus(DllExports::GdipDrawEllipse(
  292. nativeGraphics, pen ? pen->nativePen : NULL,
  293. x, y, width, height));
  294. }
  295. Status DrawEllipse(const Pen *pen, INT x, INT y, INT width, INT height)
  296. {
  297. return updateStatus(DllExports::GdipDrawEllipseI(
  298. nativeGraphics, pen ? pen->nativePen : NULL,
  299. x, y, width, height));
  300. }
  301. Status DrawEllipse(const Pen *pen, const RectF& rect)
  302. {
  303. return updateStatus(DllExports::GdipDrawEllipse(
  304. nativeGraphics, pen ? pen->nativePen : NULL,
  305. rect.X, rect.Y, rect.Width, rect.Height));
  306. }
  307. Status DrawEllipse(const Pen *pen, const Rect& rect)
  308. {
  309. return updateStatus(DllExports::GdipDrawEllipseI(
  310. nativeGraphics, pen ? pen->nativePen : NULL,
  311. rect.X, rect.Y, rect.Width, rect.Height));
  312. }
  313. Status DrawImage(Image *image, REAL x, REAL y)
  314. {
  315. return updateStatus(DllExports::GdipDrawImage(
  316. nativeGraphics,
  317. image ? image->nativeImage : NULL,
  318. x, y));
  319. }
  320. Status DrawImage(Image *image, INT x, INT y)
  321. {
  322. return updateStatus(DllExports::GdipDrawImageI(
  323. nativeGraphics,
  324. image ? image->nativeImage : NULL,
  325. x, y));
  326. }
  327. Status DrawImage(Image *image, const PointF& point)
  328. {
  329. return updateStatus(DllExports::GdipDrawImage(
  330. nativeGraphics,
  331. image ? image->nativeImage : NULL,
  332. point.X, point.Y));
  333. }
  334. Status DrawImage(Image *image, const Point& point)
  335. {
  336. return updateStatus(DllExports::GdipDrawImageI(
  337. nativeGraphics,
  338. image ? image->nativeImage : NULL,
  339. point.X, point.Y));
  340. }
  341. Status DrawImage(Image *image, REAL x, REAL y, REAL width, REAL height)
  342. {
  343. return updateStatus(DllExports::GdipDrawImageRect(
  344. nativeGraphics,
  345. image ? image->nativeImage : NULL,
  346. x, y, width, height));
  347. }
  348. Status DrawImage(Image *image, INT x, INT y, INT width, INT height)
  349. {
  350. return updateStatus(DllExports::GdipDrawImageRectI(
  351. nativeGraphics,
  352. image ? image->nativeImage : NULL,
  353. x, y, width, height));
  354. }
  355. Status DrawImage(Image *image, const RectF& rect)
  356. {
  357. return updateStatus(DllExports::GdipDrawImageRect(
  358. nativeGraphics,
  359. image ? image->nativeImage : NULL,
  360. rect.X, rect.Y, rect.Width, rect.Height));
  361. }
  362. Status DrawImage(Image *image, const Rect& rect)
  363. {
  364. return updateStatus(DllExports::GdipDrawImageRectI(
  365. nativeGraphics,
  366. image ? image->nativeImage : NULL,
  367. rect.X, rect.Y, rect.Width, rect.Height));
  368. }
  369. Status DrawImage(Image *image, const PointF *destPoints, INT count)
  370. {
  371. return updateStatus(DllExports::GdipDrawImagePoints(
  372. nativeGraphics,
  373. image ? image->nativeImage : NULL,
  374. destPoints, count));
  375. }
  376. Status DrawImage(Image *image, const Point *destPoints, INT count)
  377. {
  378. return updateStatus(DllExports::GdipDrawImagePointsI(
  379. nativeGraphics,
  380. image ? image->nativeImage : NULL,
  381. destPoints, count));
  382. }
  383. Status DrawImage(Image *image, REAL x, REAL y, REAL srcx, REAL srcy,
  384. REAL srcwidth, REAL srcheight, Unit srcUnit)
  385. {
  386. return updateStatus(DllExports::GdipDrawImagePointRect(
  387. nativeGraphics,
  388. image ? image->nativeImage : NULL,
  389. x, y, srcx, srcy, srcwidth, srcheight,
  390. srcUnit));
  391. }
  392. Status DrawImage(Image *image, INT x, INT y, INT srcx, INT srcy,
  393. INT srcwidth, INT srcheight, Unit srcUnit)
  394. {
  395. return updateStatus(DllExports::GdipDrawImagePointRectI(
  396. nativeGraphics,
  397. image ? image->nativeImage : NULL,
  398. x, y, srcx, srcy, srcwidth, srcheight,
  399. srcUnit));
  400. }
  401. Status DrawImage(Image *image, const RectF& destRect,
  402. REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight,
  403. Unit srcUnit,
  404. const ImageAttributes *imageAttributes = NULL,
  405. DrawImageAbort callback = NULL,
  406. VOID *callbackData = NULL)
  407. {
  408. return updateStatus(DllExports::GdipDrawImageRectRect(
  409. nativeGraphics,
  410. image ? image->nativeImage : NULL,
  411. destRect.X, destRect.Y,
  412. destRect.Width, destRect.Height,
  413. srcx, srcy, srcwidth, srcheight, srcUnit,
  414. imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  415. callback, callbackData));
  416. }
  417. Status DrawImage(Image *image, const Rect& destRect,
  418. INT srcx, INT srcy, INT srcwidth, INT srcheight,
  419. Unit srcUnit,
  420. const ImageAttributes *imageAttributes = NULL,
  421. DrawImageAbort callback = NULL,
  422. VOID *callbackData = NULL)
  423. {
  424. return updateStatus(DllExports::GdipDrawImageRectRectI(
  425. nativeGraphics,
  426. image ? image->nativeImage : NULL,
  427. destRect.X, destRect.Y,
  428. destRect.Width, destRect.Height,
  429. srcx, srcy, srcwidth, srcheight, srcUnit,
  430. imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  431. callback, callbackData));
  432. }
  433. Status DrawImage(Image *image, const RectF& destRect,
  434. const RectF& sourceRect, Unit srcUnit,
  435. const ImageAttributes *imageAttributes = NULL)
  436. {
  437. return updateStatus(DllExports::GdipDrawImageRectRectI(
  438. nativeGraphics,
  439. image ? image->nativeImage : NULL,
  440. destRect.X, destRect.Y,
  441. destRect.Width, destRect.Height,
  442. sourceRect.X, sourceRect.Y,
  443. sourceRect.Width, sourceRect.Height, srcUnit,
  444. imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  445. NULL, NULL));
  446. }
  447. Status DrawImage(Image *image, const PointF *destPoints, INT count,
  448. REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight,
  449. Unit srcUnit,
  450. const ImageAttributes *imageAttributes = NULL,
  451. DrawImageAbort callback = NULL,
  452. VOID *callbackData = NULL)
  453. {
  454. return updateStatus(DllExports::GdipDrawImagePointsRect(
  455. nativeGraphics,
  456. image ? image->nativeImage : NULL,
  457. destPoints, count,
  458. srcx, srcy, srcwidth, srcheight, srcUnit,
  459. imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  460. callback, callbackData));
  461. }
  462. Status DrawImage(Image *image, const Point *destPoints, INT count,
  463. INT srcx, INT srcy, INT srcwidth, INT srcheight,
  464. Unit srcUnit,
  465. const ImageAttributes *imageAttributes = NULL,
  466. DrawImageAbort callback = NULL,
  467. VOID *callbackData = NULL)
  468. {
  469. return updateStatus(DllExports::GdipDrawImagePointsRectI(
  470. nativeGraphics,
  471. image ? image->nativeImage : NULL,
  472. destPoints, count,
  473. srcx, srcy, srcwidth, srcheight, srcUnit,
  474. imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  475. callback, callbackData));
  476. }
  477. // TODO: [GDI+ 1.1] Graphics::DrawImage(..Effect..)
  478. //Status DrawImage(Image *image, RectF *sourceRect, Matrix *matrix,
  479. // Effect *effect, ImageAttributes *imageAttributes,
  480. // Unit srcUnit)
  481. //{
  482. // return updateStatus(DllExports::GdipDrawImageFX(
  483. // nativeGraphics,
  484. // image ? image->nativeImage : NULL,
  485. // sourceRect,
  486. // matrix ? matrix->nativeMatrix : NULL,
  487. // effect ? effect->nativeEffect : NULL,
  488. // imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
  489. // srcUnit));
  490. //}
  491. Status DrawLine(const Pen *pen, REAL x1, REAL y1, REAL x2, REAL y2)
  492. {
  493. return updateStatus(DllExports::GdipDrawLine(
  494. nativeGraphics, pen ? pen->nativePen : NULL,
  495. x1, y1, x2, y2));
  496. }
  497. Status DrawLine(const Pen *pen, INT x1, INT y1, INT x2, INT y2)
  498. {
  499. return updateStatus(DllExports::GdipDrawLineI(
  500. nativeGraphics, pen ? pen->nativePen : NULL,
  501. x1, y1, x2, y2));
  502. }
  503. Status DrawLine(const Pen *pen, const PointF& pt1, const PointF& pt2)
  504. {
  505. return updateStatus(DllExports::GdipDrawLine(
  506. nativeGraphics, pen ? pen->nativePen : NULL,
  507. pt1.X, pt1.Y, pt2.X, pt2.Y));
  508. }
  509. Status DrawLine(const Pen *pen, const Point& pt1, const Point& pt2)
  510. {
  511. return updateStatus(DllExports::GdipDrawLineI(
  512. nativeGraphics, pen ? pen->nativePen : NULL,
  513. pt1.X, pt1.Y, pt2.X, pt2.Y));
  514. }
  515. Status DrawLines(const Pen *pen, const PointF *points, INT count)
  516. {
  517. return updateStatus(DllExports::GdipDrawLines(
  518. nativeGraphics, pen ? pen->nativePen : NULL,
  519. points, count));
  520. }
  521. Status DrawLines(const Pen *pen, const Point *points, INT count)
  522. {
  523. return updateStatus(DllExports::GdipDrawLinesI(
  524. nativeGraphics, pen ? pen->nativePen : NULL,
  525. points, count));
  526. }
  527. Status DrawPath(const Pen *pen, const GraphicsPath *path)
  528. {
  529. return updateStatus(DllExports::GdipDrawPath(
  530. nativeGraphics, pen ? pen->nativePen : NULL,
  531. path ? path->nativePath : NULL));
  532. }
  533. Status DrawPie(const Pen *pen, REAL x, REAL y, REAL width, REAL height,
  534. REAL startAngle, REAL sweepAngle)
  535. {
  536. return updateStatus(DllExports::GdipDrawPie(
  537. nativeGraphics, pen ? pen->nativePen : NULL,
  538. x, y, width, height, startAngle, sweepAngle));
  539. }
  540. Status DrawPie(const Pen *pen, INT x, INT y, INT width, INT height,
  541. REAL startAngle, REAL sweepAngle)
  542. {
  543. return updateStatus(DllExports::GdipDrawPieI(
  544. nativeGraphics, pen ? pen->nativePen : NULL,
  545. x, y, width, height, startAngle, sweepAngle));
  546. }
  547. Status DrawPie(const Pen *pen, const RectF& rect,
  548. REAL startAngle, REAL sweepAngle)
  549. {
  550. return updateStatus(DllExports::GdipDrawPie(
  551. nativeGraphics, pen ? pen->nativePen : NULL,
  552. rect.X, rect.Y, rect.Width, rect.Height,
  553. startAngle, sweepAngle));
  554. }
  555. Status DrawPie(const Pen *pen, const Rect& rect,
  556. REAL startAngle, REAL sweepAngle)
  557. {
  558. return updateStatus(DllExports::GdipDrawPieI(
  559. nativeGraphics, pen ? pen->nativePen : NULL,
  560. rect.X, rect.Y, rect.Width, rect.Height,
  561. startAngle, sweepAngle));
  562. }
  563. Status DrawPolygon(const Pen *pen, const PointF *points, INT count)
  564. {
  565. return updateStatus(DllExports::GdipDrawPolygon(
  566. nativeGraphics, pen ? pen->nativePen : NULL,
  567. points, count));
  568. }
  569. Status DrawPolygon(const Pen *pen, const Point *points, INT count)
  570. {
  571. return updateStatus(DllExports::GdipDrawPolygonI(
  572. nativeGraphics, pen ? pen->nativePen : NULL,
  573. points, count));
  574. }
  575. Status DrawRectangle(const Pen *pen,
  576. REAL x, REAL y, REAL width, REAL height)
  577. {
  578. return updateStatus(DllExports::GdipDrawRectangle(
  579. nativeGraphics, pen ? pen->nativePen : NULL,
  580. x, y, width, height));
  581. }
  582. Status DrawRectangle(const Pen *pen,
  583. INT x, INT y, INT width, INT height)
  584. {
  585. return updateStatus(DllExports::GdipDrawRectangleI(
  586. nativeGraphics, pen ? pen->nativePen : NULL,
  587. x, y, width, height));
  588. }
  589. Status DrawRectangle(const Pen *pen, const RectF& rect)
  590. {
  591. return updateStatus(DllExports::GdipDrawRectangle(
  592. nativeGraphics, pen ? pen->nativePen : NULL,
  593. rect.X, rect.Y, rect.Width, rect.Height));
  594. }
  595. Status DrawRectangle(const Pen *pen, const Rect& rect)
  596. {
  597. return updateStatus(DllExports::GdipDrawRectangleI(
  598. nativeGraphics, pen ? pen->nativePen : NULL,
  599. rect.X, rect.Y, rect.Width, rect.Height));
  600. }
  601. Status DrawRectangles(const Pen *pen, const RectF *rects, INT count)
  602. {
  603. return updateStatus(DllExports::GdipDrawRectangles(
  604. nativeGraphics, pen ? pen->nativePen : NULL,
  605. rects, count));
  606. }
  607. Status DrawRectangles(const Pen *pen, const Rect *rects, INT count)
  608. {
  609. return updateStatus(DllExports::GdipDrawRectanglesI(
  610. nativeGraphics, pen ? pen->nativePen : NULL,
  611. rects, count));
  612. }
  613. Status DrawString(const WCHAR *string, INT length, const Font *font,
  614. const PointF& origin, const Brush *brush)
  615. {
  616. RectF layoutRect(origin.X, origin.Y, 0.0f, 0.0f);
  617. return updateStatus(DllExports::GdipDrawString(
  618. nativeGraphics, string, length,
  619. font ? font->nativeFont : NULL,
  620. &layoutRect, NULL,
  621. brush ? brush->nativeBrush : NULL));
  622. }
  623. Status DrawString(const WCHAR *string, INT length,
  624. const Font *font, const PointF& origin,
  625. const StringFormat *stringFormat, const Brush *brush)
  626. {
  627. RectF layoutRect(origin.X, origin.Y, 0.0f, 0.0f);
  628. return updateStatus(DllExports::GdipDrawString(
  629. nativeGraphics, string, length,
  630. font ? font->nativeFont : NULL,
  631. &layoutRect,
  632. stringFormat ? stringFormat->nativeStringFormat : NULL,
  633. brush ? brush->nativeBrush : NULL));
  634. }
  635. Status DrawString(const WCHAR *string, INT length,
  636. const Font *font, const RectF& layoutRect,
  637. const StringFormat *stringFormat, const Brush *brush)
  638. {
  639. return updateStatus(DllExports::GdipDrawString(
  640. nativeGraphics, string, length,
  641. font ? font->nativeFont : NULL,
  642. &layoutRect,
  643. stringFormat ? stringFormat->nativeStringFormat : NULL,
  644. brush ? brush->nativeBrush : NULL));
  645. }
  646. Status EndContainer(GraphicsContainer state)
  647. {
  648. return updateStatus(DllExports::GdipEndContainer(
  649. nativeGraphics, state));
  650. }
  651. Status EnumerateMetafile(const Metafile *metafile,
  652. const PointF& destPoint,
  653. EnumerateMetafileProc callback,
  654. VOID *callbackData = NULL,
  655. ImageAttributes *imageAttributes = NULL)
  656. {
  657. return updateStatus(DllExports::GdipEnumerateMetafileDestPoint(
  658. nativeGraphics,
  659. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  660. destPoint, callback, callbackData,
  661. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  662. }
  663. Status EnumerateMetafile(const Metafile *metafile,
  664. const Point& destPoint,
  665. EnumerateMetafileProc callback,
  666. VOID *callbackData = NULL,
  667. ImageAttributes *imageAttributes = NULL)
  668. {
  669. return updateStatus(DllExports::GdipEnumerateMetafileDestPointI(
  670. nativeGraphics,
  671. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  672. destPoint, callback, callbackData,
  673. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  674. }
  675. Status EnumerateMetafile(const Metafile *metafile,
  676. const RectF& destRect,
  677. EnumerateMetafileProc callback,
  678. VOID *callbackData = NULL,
  679. ImageAttributes *imageAttributes = NULL)
  680. {
  681. return updateStatus(DllExports::GdipEnumerateMetafileDestRect(
  682. nativeGraphics,
  683. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  684. destRect, callback, callbackData,
  685. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  686. }
  687. Status EnumerateMetafile(const Metafile *metafile,
  688. const Rect& destRect,
  689. EnumerateMetafileProc callback,
  690. VOID *callbackData = NULL,
  691. ImageAttributes *imageAttributes = NULL)
  692. {
  693. return updateStatus(DllExports::GdipEnumerateMetafileDestRectI(
  694. nativeGraphics,
  695. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  696. destRect, callback, callbackData,
  697. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  698. }
  699. Status EnumerateMetafile(const Metafile *metafile,
  700. const PointF *destPoints, INT count,
  701. EnumerateMetafileProc callback,
  702. VOID *callbackData = NULL,
  703. ImageAttributes *imageAttributes = NULL)
  704. {
  705. return updateStatus(DllExports::GdipEnumerateMetafileDestPoints(
  706. nativeGraphics,
  707. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  708. destPoints, count, callback, callbackData,
  709. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  710. }
  711. Status EnumerateMetafile(const Metafile *metafile,
  712. const Point *destPoints, INT count,
  713. EnumerateMetafileProc callback,
  714. VOID *callbackData = NULL,
  715. ImageAttributes *imageAttributes = NULL)
  716. {
  717. return updateStatus(DllExports::GdipEnumerateMetafileDestPointsI(
  718. nativeGraphics,
  719. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  720. destPoints, count, callback, callbackData,
  721. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  722. }
  723. Status EnumerateMetafile(const Metafile *metafile,
  724. const PointF& destPoint,
  725. const RectF& srcRect, Unit srcUnit,
  726. EnumerateMetafileProc callback,
  727. VOID *callbackData = NULL,
  728. ImageAttributes *imageAttributes = NULL)
  729. {
  730. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoint(
  731. nativeGraphics,
  732. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  733. destPoint, srcRect, srcUnit,
  734. callback, callbackData,
  735. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  736. }
  737. Status EnumerateMetafile(const Metafile *metafile,
  738. const Point& destPoint,
  739. const Rect& srcRect, Unit srcUnit,
  740. EnumerateMetafileProc callback,
  741. VOID *callbackData = NULL,
  742. ImageAttributes *imageAttributes = NULL)
  743. {
  744. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointI(
  745. nativeGraphics,
  746. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  747. destPoint, srcRect, srcUnit,
  748. callback, callbackData,
  749. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  750. }
  751. Status EnumerateMetafile(const Metafile *metafile,
  752. const RectF& destRect,
  753. const RectF& srcRect, Unit srcUnit,
  754. EnumerateMetafileProc callback,
  755. VOID *callbackData = NULL,
  756. ImageAttributes *imageAttributes = NULL)
  757. {
  758. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestRect(
  759. nativeGraphics,
  760. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  761. destRect, srcRect, srcUnit,
  762. callback, callbackData,
  763. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  764. }
  765. Status EnumerateMetafile(const Metafile *metafile,
  766. const Rect& destRect,
  767. const Rect& srcRect, Unit srcUnit,
  768. EnumerateMetafileProc callback,
  769. VOID *callbackData = NULL,
  770. ImageAttributes *imageAttributes = NULL)
  771. {
  772. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestRectI(
  773. nativeGraphics,
  774. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  775. destRect, srcRect, srcUnit,
  776. callback, callbackData,
  777. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  778. }
  779. Status EnumerateMetafile(const Metafile *metafile,
  780. const PointF* destPoints, INT count,
  781. const RectF& srcRect, Unit srcUnit,
  782. EnumerateMetafileProc callback,
  783. VOID *callbackData = NULL,
  784. ImageAttributes *imageAttributes = NULL)
  785. {
  786. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoints(
  787. nativeGraphics,
  788. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  789. destPoints, count, srcRect, srcUnit,
  790. callback, callbackData,
  791. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  792. }
  793. Status EnumerateMetafile(const Metafile *metafile,
  794. const Point* destPoints, INT count,
  795. const Rect& srcRect, Unit srcUnit,
  796. EnumerateMetafileProc callback,
  797. VOID *callbackData = NULL,
  798. ImageAttributes *imageAttributes = NULL)
  799. {
  800. return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointsI(
  801. nativeGraphics,
  802. metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
  803. destPoints, count, srcRect, srcUnit,
  804. callback, callbackData,
  805. imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
  806. }
  807. Status ExcludeClip(const RectF& rect)
  808. {
  809. return updateStatus(DllExports::GdipSetClipRect(
  810. nativeGraphics,
  811. rect.X, rect.Y, rect.Width, rect.Height,
  812. CombineModeExclude));
  813. }
  814. Status ExcludeClip(const Rect& rect)
  815. {
  816. return updateStatus(DllExports::GdipSetClipRectI(
  817. nativeGraphics,
  818. rect.X, rect.Y, rect.Width, rect.Height,
  819. CombineModeExclude));
  820. }
  821. Status ExcludeClip(const Region *region)
  822. {
  823. return updateStatus(DllExports::GdipSetClipRegion(
  824. nativeGraphics,
  825. region ? region->nativeRegion : NULL,
  826. CombineModeExclude));
  827. }
  828. Status FillClosedCurve(const Brush *brush,
  829. const PointF *points, INT count)
  830. {
  831. return updateStatus(DllExports::GdipFillClosedCurve(
  832. nativeGraphics,
  833. brush ? brush->nativeBrush : NULL,
  834. points, count));
  835. }
  836. Status FillClosedCurve(const Brush *brush,
  837. const Point *points, INT count)
  838. {
  839. return updateStatus(DllExports::GdipFillClosedCurveI(
  840. nativeGraphics,
  841. brush ? brush->nativeBrush : NULL,
  842. points, count));
  843. }
  844. Status FillClosedCurve(const Brush *brush,
  845. const PointF *points, INT count,
  846. FillMode fillMode, REAL tension = 0.5f)
  847. {
  848. return updateStatus(DllExports::GdipFillClosedCurve2(
  849. nativeGraphics,
  850. brush ? brush->nativeBrush : NULL,
  851. points, count, tension, fillMode));
  852. }
  853. Status FillClosedCurve(const Brush *brush,
  854. const Point *points, INT count,
  855. FillMode fillMode, REAL tension = 0.5f)
  856. {
  857. return updateStatus(DllExports::GdipFillClosedCurve2I(
  858. nativeGraphics,
  859. brush ? brush->nativeBrush : NULL,
  860. points, count, tension, fillMode));
  861. }
  862. Status FillEllipse(const Brush *brush,
  863. REAL x, REAL y, REAL width, REAL height)
  864. {
  865. return updateStatus(DllExports::GdipFillEllipse(
  866. nativeGraphics,
  867. brush ? brush->nativeBrush : NULL,
  868. x, y, width, height));
  869. }
  870. Status FillEllipse(const Brush *brush,
  871. INT x, INT y, INT width, INT height)
  872. {
  873. return updateStatus(DllExports::GdipFillEllipseI(
  874. nativeGraphics,
  875. brush ? brush->nativeBrush : NULL,
  876. x, y, width, height));
  877. }
  878. Status FillEllipse(const Brush *brush, const RectF& rect)
  879. {
  880. return updateStatus(DllExports::GdipFillEllipse(
  881. nativeGraphics,
  882. brush ? brush->nativeBrush : NULL,
  883. rect.X, rect.Y, rect.Width, rect.Height));
  884. }
  885. Status FillEllipse(const Brush *brush, const Rect& rect)
  886. {
  887. return updateStatus(DllExports::GdipFillEllipseI(
  888. nativeGraphics,
  889. brush ? brush->nativeBrush : NULL,
  890. rect.X, rect.Y, rect.Width, rect.Height));
  891. }
  892. Status FillPath(const Brush *brush, const GraphicsPath *path)
  893. {
  894. return updateStatus(DllExports::GdipFillPath(
  895. nativeGraphics,
  896. brush ? brush->nativeBrush : NULL,
  897. path ? path->nativePath : NULL));
  898. }
  899. Status FillPie(const Brush *brush,
  900. REAL x, REAL y, REAL width, REAL height,
  901. REAL startAngle, REAL sweepAngle)
  902. {
  903. return updateStatus(DllExports::GdipFillPie(
  904. nativeGraphics,
  905. brush ? brush->nativeBrush : NULL,
  906. x, y, width, height, startAngle, sweepAngle));
  907. }
  908. Status FillPie(const Brush *brush, INT x, INT y, INT width, INT height,
  909. REAL startAngle, REAL sweepAngle)
  910. {
  911. return updateStatus(DllExports::GdipFillPieI(
  912. nativeGraphics,
  913. brush ? brush->nativeBrush : NULL,
  914. x, y, width, height, startAngle, sweepAngle));
  915. }
  916. Status FillPie(const Brush *brush, const RectF& rect,
  917. REAL startAngle, REAL sweepAngle)
  918. {
  919. return updateStatus(DllExports::GdipFillPie(
  920. nativeGraphics,
  921. brush ? brush->nativeBrush : NULL,
  922. rect.X, rect.Y, rect.Width, rect.Height,
  923. startAngle, sweepAngle));
  924. }
  925. Status FillPie(const Brush *brush, const Rect& rect,
  926. REAL startAngle, REAL sweepAngle)
  927. {
  928. return updateStatus(DllExports::GdipFillPieI(
  929. nativeGraphics,
  930. brush ? brush->nativeBrush : NULL,
  931. rect.X, rect.Y, rect.Width, rect.Height,
  932. startAngle, sweepAngle));
  933. }
  934. Status FillPolygon(const Brush *brush, const PointF *points, INT count)
  935. {
  936. return updateStatus(DllExports::GdipFillPolygon(
  937. nativeGraphics,
  938. brush ? brush->nativeBrush : NULL,
  939. points, count, FillModeAlternate));
  940. }
  941. Status FillPolygon(const Brush *brush, const Point *points, INT count)
  942. {
  943. return updateStatus(DllExports::GdipFillPolygonI(
  944. nativeGraphics,
  945. brush ? brush->nativeBrush : NULL,
  946. points, count, FillModeAlternate));
  947. }
  948. Status FillPolygon(const Brush *brush, const PointF *points, INT count,
  949. FillMode fillMode)
  950. {
  951. return updateStatus(DllExports::GdipFillPolygon(
  952. nativeGraphics,
  953. brush ? brush->nativeBrush : NULL,
  954. points, count, fillMode));
  955. }
  956. Status FillPolygon(const Brush *brush, const Point *points, INT count,
  957. FillMode fillMode)
  958. {
  959. return updateStatus(DllExports::GdipFillPolygonI(
  960. nativeGraphics,
  961. brush ? brush->nativeBrush : NULL,
  962. points, count, fillMode));
  963. }
  964. Status FillRectangle(const Brush *brush,
  965. REAL x, REAL y, REAL width, REAL height)
  966. {
  967. return updateStatus(DllExports::GdipFillRectangle(
  968. nativeGraphics,
  969. brush ? brush->nativeBrush : NULL,
  970. x, y, width, height));
  971. }
  972. Status FillRectangle(const Brush *brush,
  973. INT x, INT y, INT width, INT height)
  974. {
  975. return updateStatus(DllExports::GdipFillRectangleI(
  976. nativeGraphics,
  977. brush ? brush->nativeBrush : NULL,
  978. x, y, width, height));
  979. }
  980. Status FillRectangle(const Brush *brush, const RectF& rect)
  981. {
  982. return updateStatus(DllExports::GdipFillRectangle(
  983. nativeGraphics,
  984. brush ? brush->nativeBrush : NULL,
  985. rect.X, rect.Y, rect.Width, rect.Height));
  986. }
  987. Status FillRectangle(const Brush *brush, const Rect& rect)
  988. {
  989. return updateStatus(DllExports::GdipFillRectangleI(
  990. nativeGraphics,
  991. brush ? brush->nativeBrush : NULL,
  992. rect.X, rect.Y, rect.Width, rect.Height));
  993. }
  994. Status FillRectangles(const Brush *brush, const RectF *rects, INT count)
  995. {
  996. return updateStatus(DllExports::GdipFillRectangles(
  997. nativeGraphics,
  998. brush ? brush->nativeBrush : NULL,
  999. rects, count));
  1000. }
  1001. Status FillRectangles(const Brush *brush, const Rect *rects, INT count)
  1002. {
  1003. return updateStatus(DllExports::GdipFillRectanglesI(
  1004. nativeGraphics,
  1005. brush ? brush->nativeBrush : NULL,
  1006. rects, count));
  1007. }
  1008. Status FillRegion(const Brush *brush, const Region *region)
  1009. {
  1010. return updateStatus(DllExports::GdipFillRegion(
  1011. nativeGraphics,
  1012. brush ? brush->nativeBrush : NULL,
  1013. region ? region->nativeRegion : NULL));
  1014. }
  1015. VOID Flush(FlushIntention intention = FlushIntentionFlush)
  1016. {
  1017. updateStatus(DllExports::GdipFlush(nativeGraphics, intention));
  1018. }
  1019. Status GetClip(Region *region) const
  1020. {
  1021. return updateStatus(DllExports::GdipGetClip(
  1022. nativeGraphics,
  1023. region ? region->nativeRegion : NULL));
  1024. }
  1025. Status GetClipBounds(RectF *rect) const
  1026. {
  1027. return updateStatus(DllExports::GdipGetClipBounds(
  1028. nativeGraphics, rect));
  1029. }
  1030. Status GetClipBounds(Rect *rect) const
  1031. {
  1032. return updateStatus(DllExports::GdipGetClipBoundsI(
  1033. nativeGraphics, rect));
  1034. }
  1035. CompositingMode GetCompositingMode() const
  1036. {
  1037. CompositingMode result = CompositingModeSourceOver;
  1038. updateStatus(DllExports::GdipGetCompositingMode(
  1039. nativeGraphics, &result));
  1040. return result;
  1041. }
  1042. CompositingQuality GetCompositingQuality() const
  1043. {
  1044. CompositingQuality result = CompositingQualityDefault;
  1045. updateStatus(DllExports::GdipGetCompositingQuality(
  1046. nativeGraphics, &result));
  1047. return result;
  1048. }
  1049. REAL GetDpiX() const
  1050. {
  1051. REAL result = 0.0f;
  1052. updateStatus(DllExports::GdipGetDpiX(nativeGraphics, &result));
  1053. return result;
  1054. }
  1055. REAL GetDpiY() const
  1056. {
  1057. REAL result = 0.0f;
  1058. updateStatus(DllExports::GdipGetDpiY(nativeGraphics, &result));
  1059. return result;
  1060. }
  1061. HDC GetHDC()
  1062. {
  1063. HDC result = NULL;
  1064. updateStatus(DllExports::GdipGetDC(nativeGraphics, &result));
  1065. return result;
  1066. }
  1067. InterpolationMode GetInterpolationMode() const
  1068. {
  1069. InterpolationMode result = InterpolationModeDefault;
  1070. updateStatus(DllExports::GdipGetInterpolationMode(
  1071. nativeGraphics, &result));
  1072. return result;
  1073. }
  1074. Status GetLastStatus() const
  1075. {
  1076. Status result = lastStatus;
  1077. lastStatus = Ok;
  1078. return result;
  1079. }
  1080. Status GetNearestColor(Color *color) const
  1081. {
  1082. return updateStatus(DllExports::GdipGetNearestColor(
  1083. nativeGraphics, color ? &color->Value : NULL));
  1084. }
  1085. REAL GetPageScale() const
  1086. {
  1087. REAL result = 0.0f;
  1088. updateStatus(DllExports::GdipGetPageScale(
  1089. nativeGraphics, &result));
  1090. return result;
  1091. }
  1092. Unit GetPageUnit() const
  1093. {
  1094. Unit result = UnitWorld;
  1095. updateStatus(DllExports::GdipGetPageUnit(
  1096. nativeGraphics, &result));
  1097. return result;
  1098. }
  1099. PixelOffsetMode GetPixelOffsetMode() const
  1100. {
  1101. PixelOffsetMode result = PixelOffsetModeDefault;
  1102. updateStatus(DllExports::GdipGetPixelOffsetMode(
  1103. nativeGraphics, &result));
  1104. return result;
  1105. }
  1106. Status GetRenderingOrigin(INT *x, INT *y) const
  1107. {
  1108. return updateStatus(DllExports::GdipGetRenderingOrigin(
  1109. nativeGraphics, x, y));
  1110. }
  1111. SmoothingMode GetSmoothingMode() const
  1112. {
  1113. SmoothingMode result = SmoothingModeDefault;
  1114. updateStatus(DllExports::GdipGetSmoothingMode(
  1115. nativeGraphics, &result));
  1116. return result;
  1117. }
  1118. UINT GetTextContrast() const
  1119. {
  1120. UINT result = 0;
  1121. updateStatus(DllExports::GdipGetTextContrast(
  1122. nativeGraphics, &result));
  1123. return result;
  1124. }
  1125. TextRenderingHint GetTextRenderingHint() const
  1126. {
  1127. TextRenderingHint result = TextRenderingHintSystemDefault;
  1128. updateStatus(DllExports::GdipGetTextRenderingHint(
  1129. nativeGraphics, &result));
  1130. return result;
  1131. }
  1132. Status GetTransform(Matrix *matrix) const
  1133. {
  1134. return updateStatus(DllExports::GdipGetWorldTransform(
  1135. nativeGraphics,
  1136. matrix ? matrix->nativeMatrix : NULL));
  1137. }
  1138. Status GetVisibleClipBounds(RectF *rect) const
  1139. {
  1140. return updateStatus(DllExports::GdipGetVisibleClipBounds(
  1141. nativeGraphics, rect));
  1142. }
  1143. Status GetVisibleClipBounds(Rect *rect) const
  1144. {
  1145. return updateStatus(DllExports::GdipGetVisibleClipBoundsI(
  1146. nativeGraphics, rect));
  1147. }
  1148. Status IntersectClip(const RectF& rect)
  1149. {
  1150. return updateStatus(DllExports::GdipSetClipRect(
  1151. nativeGraphics,
  1152. rect.X, rect.Y, rect.Width, rect.Height,
  1153. CombineModeIntersect));
  1154. }
  1155. Status IntersectClip(const Rect& rect)
  1156. {
  1157. return updateStatus(DllExports::GdipSetClipRectI(
  1158. nativeGraphics,
  1159. rect.X, rect.Y, rect.Width, rect.Height,
  1160. CombineModeIntersect));
  1161. }
  1162. Status IntersectClip(const Region *region)
  1163. {
  1164. return updateStatus(DllExports::GdipSetClipRegion(
  1165. nativeGraphics,
  1166. region ? region->nativeRegion : NULL,
  1167. CombineModeIntersect));
  1168. }
  1169. BOOL IsClipEmpty() const
  1170. {
  1171. BOOL result = FALSE;
  1172. updateStatus(DllExports::GdipIsClipEmpty(
  1173. nativeGraphics, &result));
  1174. return result;
  1175. }
  1176. BOOL IsVisible(REAL x, REAL y) const
  1177. {
  1178. BOOL result = FALSE;
  1179. updateStatus(DllExports::GdipIsVisiblePoint(
  1180. nativeGraphics, x, y, &result));
  1181. return result;
  1182. }
  1183. BOOL IsVisible(INT x, INT y) const
  1184. {
  1185. BOOL result = FALSE;
  1186. updateStatus(DllExports::GdipIsVisiblePointI(
  1187. nativeGraphics, x, y, &result));
  1188. return result;
  1189. }
  1190. BOOL IsVisible(const PointF& point) const
  1191. {
  1192. BOOL result = FALSE;
  1193. updateStatus(DllExports::GdipIsVisiblePoint(
  1194. nativeGraphics, point.X, point.Y, &result));
  1195. return result;
  1196. }
  1197. BOOL IsVisible(const Point& point) const
  1198. {
  1199. BOOL result = FALSE;
  1200. updateStatus(DllExports::GdipIsVisiblePointI(
  1201. nativeGraphics, point.X, point.Y, &result));
  1202. return result;
  1203. }
  1204. BOOL IsVisible(REAL x, REAL y, REAL width, REAL height) const
  1205. {
  1206. BOOL result = FALSE;
  1207. updateStatus(DllExports::GdipIsVisibleRect(
  1208. nativeGraphics, x, y, width, height, &result));
  1209. return result;
  1210. }
  1211. BOOL IsVisible(INT x, INT y, INT width, INT height) const
  1212. {
  1213. BOOL result = FALSE;
  1214. updateStatus(DllExports::GdipIsVisibleRectI(
  1215. nativeGraphics, x, y, width, height, &result));
  1216. return result;
  1217. }
  1218. BOOL IsVisible(const RectF& rect) const
  1219. {
  1220. BOOL result = FALSE;
  1221. updateStatus(DllExports::GdipIsVisibleRect(
  1222. nativeGraphics, rect.X, rect.Y,
  1223. rect.Width, rect.Height, &result));
  1224. return result;
  1225. }
  1226. BOOL IsVisible(const Rect& rect) const
  1227. {
  1228. BOOL result = FALSE;
  1229. updateStatus(DllExports::GdipIsVisibleRectI(
  1230. nativeGraphics, rect.X, rect.Y,
  1231. rect.Width, rect.Height, &result));
  1232. return result;
  1233. }
  1234. BOOL IsVisibleClipEmpty() const
  1235. {
  1236. BOOL result = FALSE;
  1237. updateStatus(DllExports::GdipIsVisibleClipEmpty(
  1238. nativeGraphics, &result));
  1239. return result;
  1240. }
  1241. Status MeasureCharacterRanges(const WCHAR *string, INT length,
  1242. const Font *font, const RectF& layoutRect,
  1243. const StringFormat *stringFormat,
  1244. INT regionCount, Region *regions) const
  1245. {
  1246. if (regionCount <= 0 || !regions)
  1247. return lastStatus = InvalidParameter;
  1248. GpRegion **nativeRegionArray = (GpRegion**)
  1249. DllExports::GdipAlloc(regionCount * sizeof(GpRegion*));
  1250. if (!nativeRegionArray)
  1251. return lastStatus = OutOfMemory;
  1252. for (int i = 0; i < regionCount; ++i) {
  1253. nativeRegionArray[i] = regions[i].nativeRegion;
  1254. }
  1255. Status status = updateStatus(DllExports::GdipMeasureCharacterRanges(
  1256. nativeGraphics, string, length,
  1257. font ? font->nativeFont : NULL,
  1258. layoutRect,
  1259. stringFormat ? stringFormat->nativeStringFormat : NULL,
  1260. regionCount, nativeRegionArray));
  1261. DllExports::GdipFree(nativeRegionArray);
  1262. return status;
  1263. }
  1264. Status MeasureDriverString(const UINT16 *text, INT length,
  1265. const Font *font, const PointF *positions, INT flags,
  1266. const Matrix *matrix, RectF *boundingBox) const
  1267. {
  1268. return updateStatus(DllExports::GdipMeasureDriverString(
  1269. nativeGraphics, text, length,
  1270. font ? font->nativeFont : NULL,
  1271. positions, flags,
  1272. matrix ? matrix->nativeMatrix : NULL,
  1273. boundingBox));
  1274. }
  1275. Status MeasureString(const WCHAR *string, INT length,
  1276. const Font *font, const RectF& layoutRect,
  1277. RectF *boundingBox) const
  1278. {
  1279. return updateStatus(DllExports::GdipMeasureString(
  1280. nativeGraphics, string, length,
  1281. font ? font->nativeFont : NULL,
  1282. &layoutRect, NULL, boundingBox, NULL, NULL));
  1283. }
  1284. Status MeasureString(const WCHAR *string, INT length,
  1285. const Font *font, const RectF& layoutRect,
  1286. const StringFormat *stringFormat, RectF *boundingBox,
  1287. INT *codepointsFitted = NULL,
  1288. INT *linesFitted = NULL) const
  1289. {
  1290. return updateStatus(DllExports::GdipMeasureString(
  1291. nativeGraphics, string, length,
  1292. font ? font->nativeFont : NULL,
  1293. &layoutRect,
  1294. stringFormat ? stringFormat->nativeStringFormat : NULL,
  1295. boundingBox, codepointsFitted, linesFitted));
  1296. }
  1297. Status MeasureString(const WCHAR *string, INT length,
  1298. const Font *font, const SizeF& layoutRectSize,
  1299. const StringFormat *stringFormat, SizeF *size,
  1300. INT *codepointsFitted = NULL,
  1301. INT *linesFitted = NULL) const
  1302. {
  1303. if (!size) return lastStatus = InvalidParameter;
  1304. RectF layoutRect(PointF(0.0f, 0.0f), layoutRectSize);
  1305. RectF boundingBox;
  1306. Status status = updateStatus(DllExports::GdipMeasureString(
  1307. nativeGraphics, string, length,
  1308. font ? font->nativeFont : NULL,
  1309. &layoutRect,
  1310. stringFormat ? stringFormat->nativeStringFormat : NULL,
  1311. &boundingBox, codepointsFitted, linesFitted));
  1312. boundingBox.GetSize(size);
  1313. return status;
  1314. }
  1315. Status MeasureString(const WCHAR *string, INT length,
  1316. const Font *font, const PointF& origin,
  1317. RectF *boundingBox) const
  1318. {
  1319. RectF layoutRect(origin, SizeF(0.0f, 0.0f));
  1320. return updateStatus(DllExports::GdipMeasureString(
  1321. nativeGraphics, string, length,
  1322. font ? font->nativeFont : NULL,
  1323. &layoutRect, NULL, boundingBox, NULL, NULL));
  1324. }
  1325. Status MeasureString(const WCHAR *string, INT length,
  1326. const Font *font, const PointF& origin,
  1327. const StringFormat *stringFormat,
  1328. RectF *boundingBox) const
  1329. {
  1330. RectF layoutRect(origin, SizeF(0.0f, 0.0f));
  1331. return updateStatus(DllExports::GdipMeasureString(
  1332. nativeGraphics, string, length,
  1333. font ? font->nativeFont : NULL,
  1334. &layoutRect,
  1335. stringFormat ? stringFormat->nativeStringFormat : NULL,
  1336. boundingBox, NULL, NULL));
  1337. }
  1338. Status MultiplyTransform(const Matrix *matrix,
  1339. MatrixOrder order = MatrixOrderPrepend)
  1340. {
  1341. return updateStatus(DllExports::GdipMultiplyWorldTransform(
  1342. nativeGraphics,
  1343. matrix ? matrix->nativeMatrix : NULL, order));
  1344. }
  1345. VOID ReleaseHDC(HDC hdc)
  1346. {
  1347. updateStatus(DllExports::GdipReleaseDC(nativeGraphics, hdc));
  1348. }
  1349. Status ResetClip()
  1350. {
  1351. return updateStatus(DllExports::GdipResetClip(nativeGraphics));
  1352. }
  1353. Status ResetTransform()
  1354. {
  1355. return updateStatus(DllExports::GdipResetWorldTransform(
  1356. nativeGraphics));
  1357. }
  1358. Status Restore(GraphicsState state)
  1359. {
  1360. return updateStatus(DllExports::GdipRestoreGraphics(
  1361. nativeGraphics, state));
  1362. }
  1363. Status RotateTransform(REAL angle,
  1364. MatrixOrder order = MatrixOrderPrepend)
  1365. {
  1366. return updateStatus(DllExports::GdipRotateWorldTransform(
  1367. nativeGraphics, angle, order));
  1368. }
  1369. GraphicsState Save() const
  1370. {
  1371. GraphicsState result = 0;
  1372. updateStatus(DllExports::GdipSaveGraphics(
  1373. nativeGraphics, &result));
  1374. return result;
  1375. }
  1376. Status ScaleTransform(REAL sx, REAL sy,
  1377. MatrixOrder order = MatrixOrderPrepend)
  1378. {
  1379. return updateStatus(DllExports::GdipScaleWorldTransform(
  1380. nativeGraphics, sx, sy, order));
  1381. }
  1382. VOID SetAbort()
  1383. {
  1384. updateStatus(NotImplemented);
  1385. }
  1386. Status SetClip(const Graphics *g,
  1387. CombineMode combineMode = CombineModeReplace)
  1388. {
  1389. return updateStatus(DllExports::GdipSetClipGraphics(
  1390. nativeGraphics, g ? g->nativeGraphics : NULL,
  1391. combineMode));
  1392. }
  1393. Status SetClip(const RectF& rect,
  1394. CombineMode combineMode = CombineModeReplace)
  1395. {
  1396. return updateStatus(DllExports::GdipSetClipRect(
  1397. nativeGraphics,
  1398. rect.X, rect.Y, rect.Width, rect.Height,
  1399. combineMode));
  1400. }
  1401. Status SetClip(const Rect& rect,
  1402. CombineMode combineMode = CombineModeReplace)
  1403. {
  1404. return updateStatus(DllExports::GdipSetClipRectI(
  1405. nativeGraphics,
  1406. rect.X, rect.Y, rect.Width, rect.Height,
  1407. combineMode));
  1408. }
  1409. Status SetClip(const GraphicsPath *path,
  1410. CombineMode combineMode = CombineModeReplace)
  1411. {
  1412. return updateStatus(DllExports::GdipSetClipPath(
  1413. nativeGraphics,
  1414. path ? path->nativePath : NULL,
  1415. combineMode));
  1416. }
  1417. Status SetClip(const Region *region,
  1418. CombineMode combineMode = CombineModeReplace)
  1419. {
  1420. return updateStatus(DllExports::GdipSetClipRegion(
  1421. nativeGraphics,
  1422. region ? region->nativeRegion : NULL,
  1423. combineMode));
  1424. }
  1425. Status SetClip(HRGN hRgn, CombineMode combineMode = CombineModeReplace)
  1426. {
  1427. return updateStatus(DllExports::GdipSetClipHrgn(
  1428. nativeGraphics, hRgn, combineMode));
  1429. }
  1430. Status SetCompositingMode(CompositingMode compositingMode)
  1431. {
  1432. return updateStatus(DllExports::GdipSetCompositingMode(
  1433. nativeGraphics, compositingMode));
  1434. }
  1435. Status SetCompositingQuality(CompositingQuality compositingQuality)
  1436. {
  1437. return updateStatus(DllExports::GdipSetCompositingQuality(
  1438. nativeGraphics, compositingQuality));
  1439. }
  1440. Status SetInterpolationMode(InterpolationMode interpolationMode)
  1441. {
  1442. return updateStatus(DllExports::GdipSetInterpolationMode(
  1443. nativeGraphics, interpolationMode));
  1444. }
  1445. Status SetPageScale(REAL scale)
  1446. {
  1447. return updateStatus(DllExports::GdipSetPageScale(
  1448. nativeGraphics, scale));
  1449. }
  1450. Status SetPageUnit(Unit unit)
  1451. {
  1452. return updateStatus(DllExports::GdipSetPageUnit(
  1453. nativeGraphics, unit));
  1454. }
  1455. Status SetPixelOffsetMode(PixelOffsetMode pixelOffsetMode)
  1456. {
  1457. return updateStatus(DllExports::GdipSetPixelOffsetMode(
  1458. nativeGraphics, pixelOffsetMode));
  1459. }
  1460. Status SetRenderingOrigin(INT x, INT y)
  1461. {
  1462. return updateStatus(DllExports::GdipSetRenderingOrigin(
  1463. nativeGraphics, x, y));
  1464. }
  1465. Status SetSmoothingMode(SmoothingMode smoothingMode)
  1466. {
  1467. return updateStatus(DllExports::GdipSetSmoothingMode(
  1468. nativeGraphics, smoothingMode));
  1469. }
  1470. Status SetTextContrast(UINT contrast)
  1471. {
  1472. return updateStatus(DllExports::GdipSetTextContrast(
  1473. nativeGraphics, contrast));
  1474. }
  1475. Status SetTextRenderingHint(TextRenderingHint textRenderingHint)
  1476. {
  1477. return updateStatus(DllExports::GdipSetTextRenderingHint(
  1478. nativeGraphics, textRenderingHint));
  1479. }
  1480. Status SetTransform(const Matrix *matrix)
  1481. {
  1482. return updateStatus(DllExports::GdipSetWorldTransform(
  1483. nativeGraphics,
  1484. matrix ? matrix->nativeMatrix : NULL));
  1485. }
  1486. Status TransformPoints(CoordinateSpace destSpace,
  1487. CoordinateSpace srcSpace,
  1488. PointF *pts, INT count) const
  1489. {
  1490. return updateStatus(DllExports::GdipTransformPoints(
  1491. nativeGraphics, destSpace, srcSpace,
  1492. pts, count));
  1493. }
  1494. Status TransformPoints(CoordinateSpace destSpace,
  1495. CoordinateSpace srcSpace,
  1496. Point *pts, INT count) const
  1497. {
  1498. return updateStatus(DllExports::GdipTransformPointsI(
  1499. nativeGraphics, destSpace, srcSpace,
  1500. pts, count));
  1501. }
  1502. Status TranslateClip(REAL dx, REAL dy)
  1503. {
  1504. return updateStatus(DllExports::GdipTranslateClip(
  1505. nativeGraphics, dx, dy));
  1506. }
  1507. Status TranslateClip(INT dx, INT dy)
  1508. {
  1509. return updateStatus(DllExports::GdipTranslateClipI(
  1510. nativeGraphics, dx, dy));
  1511. }
  1512. Status TranslateTransform(REAL dx, REAL dy,
  1513. MatrixOrder order = MatrixOrderPrepend)
  1514. {
  1515. return updateStatus(DllExports::GdipTranslateWorldTransform(
  1516. nativeGraphics, dx, dy, order));
  1517. }
  1518. private:
  1519. Graphics(const Graphics&);
  1520. Graphics& operator=(const Graphics&);
  1521. Status updateStatus(Status newStatus) const
  1522. {
  1523. if (newStatus != Ok) lastStatus = newStatus;
  1524. return newStatus;
  1525. }
  1526. GpGraphics *nativeGraphics;
  1527. mutable Status lastStatus;
  1528. };
  1529. #endif /* __GDIPLUS_GRAPHICS_H */