GdiPlusGraphics.h 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497
  1. //Download by http://www.NewXing.com
  2. /**************************************************************************\
  3. *
  4. * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
  5. *
  6. * Module Name:
  7. *
  8. * GdiplusGraphics.h
  9. *
  10. * Abstract:
  11. *
  12. * GDI+ Graphics Object
  13. *
  14. \**************************************************************************/
  15. #ifndef _GDIPLUSGRAPHICS_H
  16. #define _GDIPLUSGRAPHICS_H
  17. class Graphics : public GdiplusBase
  18. {
  19. public:
  20. friend class Region;
  21. friend class GraphicsPath;
  22. friend class Image;
  23. friend class Bitmap;
  24. friend class Metafile;
  25. friend class Font;
  26. friend class FontFamily;
  27. friend class FontCollection;
  28. friend class CachedBitmap;
  29. static Graphics* FromHDC(IN HDC hdc)
  30. {
  31. return new Graphics(hdc);
  32. }
  33. static Graphics* FromHDC(IN HDC hdc,
  34. IN HANDLE hdevice)
  35. {
  36. return new Graphics(hdc, hdevice);
  37. }
  38. static Graphics* FromHWND(IN HWND hwnd,
  39. IN BOOL icm = FALSE)
  40. {
  41. return new Graphics(hwnd, icm);
  42. }
  43. static Graphics* FromImage(IN Image *image)
  44. {
  45. return new Graphics(image);
  46. }
  47. Graphics(IN HDC hdc)
  48. {
  49. GpGraphics *graphics = NULL;
  50. lastResult = DllExports::GdipCreateFromHDC(hdc, &graphics);
  51. SetNativeGraphics(graphics);
  52. }
  53. Graphics(IN HDC hdc,
  54. IN HANDLE hdevice)
  55. {
  56. GpGraphics *graphics = NULL;
  57. lastResult = DllExports::GdipCreateFromHDC2(hdc, hdevice, &graphics);
  58. SetNativeGraphics(graphics);
  59. }
  60. Graphics(IN HWND hwnd,
  61. IN BOOL icm = FALSE)
  62. {
  63. GpGraphics *graphics = NULL;
  64. if (icm)
  65. {
  66. lastResult = DllExports::GdipCreateFromHWNDICM(hwnd, &graphics);
  67. }
  68. else
  69. {
  70. lastResult = DllExports::GdipCreateFromHWND(hwnd, &graphics);
  71. }
  72. SetNativeGraphics(graphics);
  73. }
  74. Graphics(IN Image* image)
  75. {
  76. GpGraphics *graphics = NULL;
  77. if (image != NULL)
  78. {
  79. lastResult = DllExports::GdipGetImageGraphicsContext(
  80. image->nativeImage, &graphics);
  81. }
  82. SetNativeGraphics(graphics);
  83. }
  84. ~Graphics()
  85. {
  86. DllExports::GdipDeleteGraphics(nativeGraphics);
  87. }
  88. VOID Flush(IN FlushIntention intention = FlushIntentionFlush)
  89. {
  90. DllExports::GdipFlush(nativeGraphics, intention);
  91. }
  92. //------------------------------------------------------------------------
  93. // GDI Interop methods
  94. //------------------------------------------------------------------------
  95. // Locks the graphics until ReleaseDC is called
  96. HDC GetHDC()
  97. {
  98. HDC hdc = NULL;
  99. SetStatus(DllExports::GdipGetDC(nativeGraphics, &hdc));
  100. return hdc;
  101. }
  102. VOID ReleaseHDC(IN HDC hdc)
  103. {
  104. SetStatus(DllExports::GdipReleaseDC(nativeGraphics, hdc));
  105. }
  106. //------------------------------------------------------------------------
  107. // Rendering modes
  108. //------------------------------------------------------------------------
  109. Status SetRenderingOrigin(IN INT x, IN INT y)
  110. {
  111. return SetStatus(
  112. DllExports::GdipSetRenderingOrigin(
  113. nativeGraphics, x, y
  114. )
  115. );
  116. }
  117. Status GetRenderingOrigin(OUT INT *x, OUT INT *y) const
  118. {
  119. return SetStatus(
  120. DllExports::GdipGetRenderingOrigin(
  121. nativeGraphics, x, y
  122. )
  123. );
  124. }
  125. Status SetCompositingMode(IN CompositingMode compositingMode)
  126. {
  127. return SetStatus(DllExports::GdipSetCompositingMode(nativeGraphics,
  128. compositingMode));
  129. }
  130. CompositingMode GetCompositingMode() const
  131. {
  132. CompositingMode mode;
  133. SetStatus(DllExports::GdipGetCompositingMode(nativeGraphics,
  134. &mode));
  135. return mode;
  136. }
  137. Status SetCompositingQuality(IN CompositingQuality compositingQuality)
  138. {
  139. return SetStatus(DllExports::GdipSetCompositingQuality(
  140. nativeGraphics,
  141. compositingQuality));
  142. }
  143. CompositingQuality GetCompositingQuality() const
  144. {
  145. CompositingQuality quality;
  146. SetStatus(DllExports::GdipGetCompositingQuality(
  147. nativeGraphics,
  148. &quality));
  149. return quality;
  150. }
  151. Status SetTextRenderingHint(IN TextRenderingHint newMode)
  152. {
  153. return SetStatus(DllExports::GdipSetTextRenderingHint(nativeGraphics,
  154. newMode));
  155. }
  156. TextRenderingHint GetTextRenderingHint() const
  157. {
  158. TextRenderingHint hint;
  159. SetStatus(DllExports::GdipGetTextRenderingHint(nativeGraphics,
  160. &hint));
  161. return hint;
  162. }
  163. Status SetTextContrast(IN UINT contrast)
  164. {
  165. return SetStatus(DllExports::GdipSetTextContrast(nativeGraphics,
  166. contrast));
  167. }
  168. UINT GetTextContrast() const
  169. {
  170. UINT contrast;
  171. SetStatus(DllExports::GdipGetTextContrast(nativeGraphics,
  172. &contrast));
  173. return contrast;
  174. }
  175. InterpolationMode GetInterpolationMode() const
  176. {
  177. InterpolationMode mode = InterpolationModeInvalid;
  178. SetStatus(DllExports::GdipGetInterpolationMode(nativeGraphics,
  179. &mode));
  180. return mode;
  181. }
  182. Status SetInterpolationMode(IN InterpolationMode interpolationMode)
  183. {
  184. return SetStatus(DllExports::GdipSetInterpolationMode(nativeGraphics,
  185. interpolationMode));
  186. }
  187. SmoothingMode GetSmoothingMode() const
  188. {
  189. SmoothingMode smoothingMode = SmoothingModeInvalid;
  190. SetStatus(DllExports::GdipGetSmoothingMode(nativeGraphics,
  191. &smoothingMode));
  192. return smoothingMode;
  193. }
  194. Status SetSmoothingMode(IN SmoothingMode smoothingMode)
  195. {
  196. return SetStatus(DllExports::GdipSetSmoothingMode(nativeGraphics,
  197. smoothingMode));
  198. }
  199. PixelOffsetMode GetPixelOffsetMode() const
  200. {
  201. PixelOffsetMode pixelOffsetMode = PixelOffsetModeInvalid;
  202. SetStatus(DllExports::GdipGetPixelOffsetMode(nativeGraphics,
  203. &pixelOffsetMode));
  204. return pixelOffsetMode;
  205. }
  206. Status SetPixelOffsetMode(IN PixelOffsetMode pixelOffsetMode)
  207. {
  208. return SetStatus(DllExports::GdipSetPixelOffsetMode(nativeGraphics,
  209. pixelOffsetMode));
  210. }
  211. //------------------------------------------------------------------------
  212. // Manipulate current world transform
  213. //------------------------------------------------------------------------
  214. Status SetTransform(IN const Matrix* matrix)
  215. {
  216. return SetStatus(DllExports::GdipSetWorldTransform(nativeGraphics,
  217. matrix->nativeMatrix));
  218. }
  219. Status ResetTransform()
  220. {
  221. return SetStatus(DllExports::GdipResetWorldTransform(nativeGraphics));
  222. }
  223. Status MultiplyTransform(IN const Matrix* matrix,
  224. IN MatrixOrder order = MatrixOrderPrepend)
  225. {
  226. return SetStatus(DllExports::GdipMultiplyWorldTransform(nativeGraphics,
  227. matrix->nativeMatrix,
  228. order));
  229. }
  230. Status TranslateTransform(IN REAL dx,
  231. IN REAL dy,
  232. IN MatrixOrder order = MatrixOrderPrepend)
  233. {
  234. return SetStatus(DllExports::GdipTranslateWorldTransform(nativeGraphics,
  235. dx, dy, order));
  236. }
  237. Status ScaleTransform(IN REAL sx,
  238. IN REAL sy,
  239. IN MatrixOrder order = MatrixOrderPrepend)
  240. {
  241. return SetStatus(DllExports::GdipScaleWorldTransform(nativeGraphics,
  242. sx, sy, order));
  243. }
  244. Status RotateTransform(IN REAL angle,
  245. IN MatrixOrder order = MatrixOrderPrepend)
  246. {
  247. return SetStatus(DllExports::GdipRotateWorldTransform(nativeGraphics,
  248. angle, order));
  249. }
  250. Status GetTransform(OUT Matrix* matrix) const
  251. {
  252. return SetStatus(DllExports::GdipGetWorldTransform(nativeGraphics,
  253. matrix->nativeMatrix));
  254. }
  255. Status SetPageUnit(IN Unit unit)
  256. {
  257. return SetStatus(DllExports::GdipSetPageUnit(nativeGraphics,
  258. unit));
  259. }
  260. Status SetPageScale(IN REAL scale)
  261. {
  262. return SetStatus(DllExports::GdipSetPageScale(nativeGraphics,
  263. scale));
  264. }
  265. Unit GetPageUnit() const
  266. {
  267. Unit unit;
  268. SetStatus(DllExports::GdipGetPageUnit(nativeGraphics, &unit));
  269. return unit;
  270. }
  271. REAL GetPageScale() const
  272. {
  273. REAL scale;
  274. SetStatus(DllExports::GdipGetPageScale(nativeGraphics, &scale));
  275. return scale;
  276. }
  277. REAL GetDpiX() const
  278. {
  279. REAL dpi;
  280. SetStatus(DllExports::GdipGetDpiX(nativeGraphics, &dpi));
  281. return dpi;
  282. }
  283. REAL GetDpiY() const
  284. {
  285. REAL dpi;
  286. SetStatus(DllExports::GdipGetDpiY(nativeGraphics, &dpi));
  287. return dpi;
  288. }
  289. Status TransformPoints(IN CoordinateSpace destSpace,
  290. IN CoordinateSpace srcSpace,
  291. IN OUT PointF* pts,
  292. IN INT count) const
  293. {
  294. return SetStatus(DllExports::GdipTransformPoints(nativeGraphics,
  295. destSpace,
  296. srcSpace,
  297. pts,
  298. count));
  299. }
  300. Status TransformPoints(IN CoordinateSpace destSpace,
  301. IN CoordinateSpace srcSpace,
  302. IN OUT PointI* pts,
  303. IN INT count) const
  304. {
  305. return SetStatus(DllExports::GdipTransformPointsI(nativeGraphics,
  306. destSpace,
  307. srcSpace,
  308. pts,
  309. count));
  310. }
  311. //------------------------------------------------------------------------
  312. // GetNearestColor (for <= 8bpp surfaces). Note: Alpha is ignored.
  313. //------------------------------------------------------------------------
  314. Status GetNearestColor(IN OUT GdiPlusColor* color) const
  315. {
  316. if (color == NULL)
  317. {
  318. return SetStatus(InvalidParameter);
  319. }
  320. ARGB argb = color->GetValue();
  321. Status status = SetStatus(DllExports::GdipGetNearestColor(nativeGraphics, &argb));
  322. color->SetValue(argb);
  323. return status;
  324. }
  325. Status DrawLine(IN const Pen* pen,
  326. IN REAL x1,
  327. IN REAL y1,
  328. IN REAL x2,
  329. IN REAL y2)
  330. {
  331. return SetStatus(DllExports::GdipDrawLine(nativeGraphics,
  332. pen->nativePen, x1, y1, x2,
  333. y2));
  334. }
  335. Status DrawLine(IN const Pen* pen,
  336. IN const PointF& pt1,
  337. IN const PointF& pt2)
  338. {
  339. return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
  340. }
  341. Status DrawLines(IN const Pen* pen,
  342. IN const PointF* points,
  343. IN INT count)
  344. {
  345. return SetStatus(DllExports::GdipDrawLines(nativeGraphics,
  346. pen->nativePen,
  347. points, count));
  348. }
  349. Status DrawLine(IN const Pen* pen,
  350. IN INT x1,
  351. IN INT y1,
  352. IN INT x2,
  353. IN INT y2)
  354. {
  355. return SetStatus(DllExports::GdipDrawLineI(nativeGraphics,
  356. pen->nativePen,
  357. x1,
  358. y1,
  359. x2,
  360. y2));
  361. }
  362. Status DrawLine(IN const Pen* pen,
  363. IN const PointI& pt1,
  364. IN const PointI& pt2)
  365. {
  366. return DrawLine(pen,
  367. pt1.X,
  368. pt1.Y,
  369. pt2.X,
  370. pt2.Y);
  371. }
  372. Status DrawLines(IN const Pen* pen,
  373. IN const PointI* points,
  374. IN INT count)
  375. {
  376. return SetStatus(DllExports::GdipDrawLinesI(nativeGraphics,
  377. pen->nativePen,
  378. points,
  379. count));
  380. }
  381. Status DrawArc(IN const Pen* pen,
  382. IN REAL x,
  383. IN REAL y,
  384. IN REAL width,
  385. IN REAL height,
  386. IN REAL startAngle,
  387. IN REAL sweepAngle)
  388. {
  389. return SetStatus(DllExports::GdipDrawArc(nativeGraphics,
  390. pen->nativePen,
  391. x,
  392. y,
  393. width,
  394. height,
  395. startAngle,
  396. sweepAngle));
  397. }
  398. Status DrawArc(IN const Pen* pen,
  399. IN const RectF& rect,
  400. IN REAL startAngle,
  401. IN REAL sweepAngle)
  402. {
  403. return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height,
  404. startAngle, sweepAngle);
  405. }
  406. Status DrawArc(IN const Pen* pen,
  407. IN INT x,
  408. IN INT y,
  409. IN INT width,
  410. IN INT height,
  411. IN REAL startAngle,
  412. IN REAL sweepAngle)
  413. {
  414. return SetStatus(DllExports::GdipDrawArcI(nativeGraphics,
  415. pen->nativePen,
  416. x,
  417. y,
  418. width,
  419. height,
  420. startAngle,
  421. sweepAngle));
  422. }
  423. Status DrawArc(IN const Pen* pen,
  424. IN const Rect& rect,
  425. IN REAL startAngle,
  426. IN REAL sweepAngle)
  427. {
  428. return DrawArc(pen,
  429. rect.X,
  430. rect.Y,
  431. rect.Width,
  432. rect.Height,
  433. startAngle,
  434. sweepAngle);
  435. }
  436. Status DrawBezier(IN const Pen* pen,
  437. IN REAL x1,
  438. IN REAL y1,
  439. IN REAL x2,
  440. IN REAL y2,
  441. IN REAL x3,
  442. IN REAL y3,
  443. IN REAL x4,
  444. IN REAL y4)
  445. {
  446. return SetStatus(DllExports::GdipDrawBezier(nativeGraphics,
  447. pen->nativePen, x1, y1,
  448. x2, y2, x3, y3, x4, y4));
  449. }
  450. Status DrawBezier(IN const Pen* pen,
  451. IN const PointF& pt1,
  452. IN const PointF& pt2,
  453. IN const PointF& pt3,
  454. IN const PointF& pt4)
  455. {
  456. return DrawBezier(pen,
  457. pt1.X,
  458. pt1.Y,
  459. pt2.X,
  460. pt2.Y,
  461. pt3.X,
  462. pt3.Y,
  463. pt4.X,
  464. pt4.Y);
  465. }
  466. Status DrawBeziers(IN const Pen* pen,
  467. IN const PointF* points,
  468. IN INT count)
  469. {
  470. return SetStatus(DllExports::GdipDrawBeziers(nativeGraphics,
  471. pen->nativePen,
  472. points,
  473. count));
  474. }
  475. Status DrawBezier(IN const Pen* pen,
  476. IN INT x1,
  477. IN INT y1,
  478. IN INT x2,
  479. IN INT y2,
  480. IN INT x3,
  481. IN INT y3,
  482. IN INT x4,
  483. IN INT y4)
  484. {
  485. return SetStatus(DllExports::GdipDrawBezierI(nativeGraphics,
  486. pen->nativePen,
  487. x1,
  488. y1,
  489. x2,
  490. y2,
  491. x3,
  492. y3,
  493. x4,
  494. y4));
  495. }
  496. Status DrawBezier(IN const Pen* pen,
  497. IN const PointI& pt1,
  498. IN const PointI& pt2,
  499. IN const PointI& pt3,
  500. IN const PointI& pt4)
  501. {
  502. return DrawBezier(pen,
  503. pt1.X,
  504. pt1.Y,
  505. pt2.X,
  506. pt2.Y,
  507. pt3.X,
  508. pt3.Y,
  509. pt4.X,
  510. pt4.Y);
  511. }
  512. Status DrawBeziers(IN const Pen* pen,
  513. IN const PointI* points,
  514. IN INT count)
  515. {
  516. return SetStatus(DllExports::GdipDrawBeziersI(nativeGraphics,
  517. pen->nativePen,
  518. points,
  519. count));
  520. }
  521. Status DrawRectangle(IN const Pen* pen,
  522. IN const RectF& rect)
  523. {
  524. return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
  525. }
  526. Status DrawRectangle(IN const Pen* pen,
  527. IN REAL x,
  528. IN REAL y,
  529. IN REAL width,
  530. IN REAL height)
  531. {
  532. return SetStatus(DllExports::GdipDrawRectangle(nativeGraphics,
  533. pen->nativePen, x, y,
  534. width, height));
  535. }
  536. Status DrawRectangles(IN const Pen* pen,
  537. IN const RectF* rects,
  538. IN INT count)
  539. {
  540. return SetStatus(DllExports::GdipDrawRectangles(nativeGraphics,
  541. pen->nativePen,
  542. rects, count));
  543. }
  544. Status DrawRectangle(IN const Pen* pen,
  545. IN const Rect& rect)
  546. {
  547. return DrawRectangle(pen,
  548. rect.X,
  549. rect.Y,
  550. rect.Width,
  551. rect.Height);
  552. }
  553. Status DrawRectangle(IN const Pen* pen,
  554. IN INT x,
  555. IN INT y,
  556. IN INT width,
  557. IN INT height)
  558. {
  559. return SetStatus(DllExports::GdipDrawRectangleI(nativeGraphics,
  560. pen->nativePen,
  561. x,
  562. y,
  563. width,
  564. height));
  565. }
  566. Status DrawRectangles(IN const Pen* pen,
  567. IN const Rect* rects,
  568. IN INT count)
  569. {
  570. return SetStatus(DllExports::GdipDrawRectanglesI(nativeGraphics,
  571. pen->nativePen,
  572. rects,
  573. count));
  574. }
  575. Status DrawEllipse(IN const Pen* pen,
  576. IN const RectF& rect)
  577. {
  578. return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
  579. }
  580. Status DrawEllipse(IN const Pen* pen,
  581. IN REAL x,
  582. IN REAL y,
  583. IN REAL width,
  584. IN REAL height)
  585. {
  586. return SetStatus(DllExports::GdipDrawEllipse(nativeGraphics,
  587. pen->nativePen,
  588. x,
  589. y,
  590. width,
  591. height));
  592. }
  593. Status DrawEllipse(IN const Pen* pen,
  594. IN const Rect& rect)
  595. {
  596. return DrawEllipse(pen,
  597. rect.X,
  598. rect.Y,
  599. rect.Width,
  600. rect.Height);
  601. }
  602. Status DrawEllipse(IN const Pen* pen,
  603. IN INT x,
  604. IN INT y,
  605. IN INT width,
  606. IN INT height)
  607. {
  608. return SetStatus(DllExports::GdipDrawEllipseI(nativeGraphics,
  609. pen->nativePen,
  610. x,
  611. y,
  612. width,
  613. height));
  614. }
  615. Status DrawPie(IN const Pen* pen,
  616. IN const RectF& rect,
  617. IN REAL startAngle,
  618. IN REAL sweepAngle)
  619. {
  620. return DrawPie(pen,
  621. rect.X,
  622. rect.Y,
  623. rect.Width,
  624. rect.Height,
  625. startAngle,
  626. sweepAngle);
  627. }
  628. Status DrawPie(IN const Pen* pen,
  629. IN REAL x,
  630. IN REAL y,
  631. IN REAL width,
  632. IN REAL height,
  633. IN REAL startAngle,
  634. IN REAL sweepAngle)
  635. {
  636. return SetStatus(DllExports::GdipDrawPie(nativeGraphics,
  637. pen->nativePen,
  638. x,
  639. y,
  640. width,
  641. height,
  642. startAngle,
  643. sweepAngle));
  644. }
  645. Status DrawPie(IN const Pen* pen,
  646. IN const Rect& rect,
  647. IN REAL startAngle,
  648. IN REAL sweepAngle)
  649. {
  650. return DrawPie(pen,
  651. rect.X,
  652. rect.Y,
  653. rect.Width,
  654. rect.Height,
  655. startAngle,
  656. sweepAngle);
  657. }
  658. Status DrawPie(IN const Pen* pen,
  659. IN INT x,
  660. IN INT y,
  661. IN INT width,
  662. IN INT height,
  663. IN REAL startAngle,
  664. IN REAL sweepAngle)
  665. {
  666. return SetStatus(DllExports::GdipDrawPieI(nativeGraphics,
  667. pen->nativePen,
  668. x,
  669. y,
  670. width,
  671. height,
  672. startAngle,
  673. sweepAngle));
  674. }
  675. Status DrawPolygon(IN const Pen* pen,
  676. IN const PointF* points,
  677. IN INT count)
  678. {
  679. return SetStatus(DllExports::GdipDrawPolygon(nativeGraphics,
  680. pen->nativePen,
  681. points,
  682. count));
  683. }
  684. Status DrawPolygon(IN const Pen* pen,
  685. IN const PointI* points,
  686. IN INT count)
  687. {
  688. return SetStatus(DllExports::GdipDrawPolygonI(nativeGraphics,
  689. pen->nativePen,
  690. points,
  691. count));
  692. }
  693. Status DrawPath(IN const Pen* pen,
  694. IN const GraphicsPath* path)
  695. {
  696. return SetStatus(DllExports::GdipDrawPath(nativeGraphics,
  697. pen ? pen->nativePen : NULL,
  698. path ? path->nativePath : NULL));
  699. }
  700. Status DrawCurve(IN const Pen* pen,
  701. IN const PointF* points,
  702. IN INT count)
  703. {
  704. return SetStatus(DllExports::GdipDrawCurve(nativeGraphics,
  705. pen->nativePen, points,
  706. count));
  707. }
  708. Status DrawCurve(IN const Pen* pen,
  709. IN const PointF* points,
  710. IN INT count,
  711. IN REAL tension)
  712. {
  713. return SetStatus(DllExports::GdipDrawCurve2(nativeGraphics,
  714. pen->nativePen, points,
  715. count, tension));
  716. }
  717. Status DrawCurve(IN const Pen* pen,
  718. IN const PointF* points,
  719. IN INT count,
  720. IN INT offset,
  721. IN INT numberOfSegments,
  722. IN REAL tension = 0.5f)
  723. {
  724. return SetStatus(DllExports::GdipDrawCurve3(nativeGraphics,
  725. pen->nativePen, points,
  726. count, offset,
  727. numberOfSegments, tension));
  728. }
  729. Status DrawCurve(IN const Pen* pen,
  730. IN const PointI* points,
  731. IN INT count)
  732. {
  733. return SetStatus(DllExports::GdipDrawCurveI(nativeGraphics,
  734. pen->nativePen,
  735. points,
  736. count));
  737. }
  738. Status DrawCurve(IN const Pen* pen,
  739. IN const PointI* points,
  740. IN INT count,
  741. IN REAL tension)
  742. {
  743. return SetStatus(DllExports::GdipDrawCurve2I(nativeGraphics,
  744. pen->nativePen,
  745. points,
  746. count,
  747. tension));
  748. }
  749. Status DrawCurve(IN const Pen* pen,
  750. IN const PointI* points,
  751. IN INT count,
  752. IN INT offset,
  753. IN INT numberOfSegments,
  754. IN REAL tension = 0.5f)
  755. {
  756. return SetStatus(DllExports::GdipDrawCurve3I(nativeGraphics,
  757. pen->nativePen,
  758. points,
  759. count,
  760. offset,
  761. numberOfSegments,
  762. tension));
  763. }
  764. Status DrawClosedCurve(IN const Pen* pen,
  765. IN const PointF* points,
  766. IN INT count)
  767. {
  768. return SetStatus(DllExports::GdipDrawClosedCurve(nativeGraphics,
  769. pen->nativePen,
  770. points, count));
  771. }
  772. Status DrawClosedCurve(IN const Pen *pen,
  773. IN const PointF* points,
  774. IN INT count,
  775. IN REAL tension)
  776. {
  777. return SetStatus(DllExports::GdipDrawClosedCurve2(nativeGraphics,
  778. pen->nativePen,
  779. points, count,
  780. tension));
  781. }
  782. Status DrawClosedCurve(IN const Pen* pen,
  783. IN const PointI* points,
  784. IN INT count)
  785. {
  786. return SetStatus(DllExports::GdipDrawClosedCurveI(nativeGraphics,
  787. pen->nativePen,
  788. points,
  789. count));
  790. }
  791. Status DrawClosedCurve(IN const Pen *pen,
  792. IN const PointI* points,
  793. IN INT count,
  794. IN REAL tension)
  795. {
  796. return SetStatus(DllExports::GdipDrawClosedCurve2I(nativeGraphics,
  797. pen->nativePen,
  798. points,
  799. count,
  800. tension));
  801. }
  802. Status Clear(IN const GdiPlusColor &color)
  803. {
  804. return SetStatus(DllExports::GdipGraphicsClear(
  805. nativeGraphics,
  806. color.GetValue()));
  807. }
  808. Status FillRectangle(IN const Brush* brush,
  809. IN const RectF& rect)
  810. {
  811. return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
  812. }
  813. Status FillRectangle(IN const Brush* brush,
  814. IN REAL x,
  815. IN REAL y,
  816. IN REAL width,
  817. IN REAL height)
  818. {
  819. return SetStatus(DllExports::GdipFillRectangle(nativeGraphics,
  820. brush->nativeBrush, x, y,
  821. width, height));
  822. }
  823. Status FillRectangles(IN const Brush* brush,
  824. IN const RectF* rects,
  825. IN INT count)
  826. {
  827. return SetStatus(DllExports::GdipFillRectangles(nativeGraphics,
  828. brush->nativeBrush,
  829. rects, count));
  830. }
  831. Status FillRectangle(IN const Brush* brush,
  832. IN const Rect& rect)
  833. {
  834. return FillRectangle(brush,
  835. rect.X,
  836. rect.Y,
  837. rect.Width,
  838. rect.Height);
  839. }
  840. Status FillRectangle(IN const Brush* brush,
  841. IN INT x,
  842. IN INT y,
  843. IN INT width,
  844. IN INT height)
  845. {
  846. return SetStatus(DllExports::GdipFillRectangleI(nativeGraphics,
  847. brush->nativeBrush,
  848. x,
  849. y,
  850. width,
  851. height));
  852. }
  853. Status FillRectangles(IN const Brush* brush,
  854. IN const Rect* rects,
  855. IN INT count)
  856. {
  857. return SetStatus(DllExports::GdipFillRectanglesI(nativeGraphics,
  858. brush->nativeBrush,
  859. rects,
  860. count));
  861. }
  862. Status FillPolygon(IN const Brush* brush,
  863. IN const PointF* points,
  864. IN INT count)
  865. {
  866. return FillPolygon(brush, points, count, FillModeAlternate);
  867. }
  868. Status FillPolygon(IN const Brush* brush,
  869. IN const PointF* points,
  870. IN INT count,
  871. IN FillMode fillMode)
  872. {
  873. return SetStatus(DllExports::GdipFillPolygon(nativeGraphics,
  874. brush->nativeBrush,
  875. points, count, fillMode));
  876. }
  877. Status FillPolygon(IN const Brush* brush,
  878. IN const PointI* points,
  879. IN INT count)
  880. {
  881. return FillPolygon(brush, points, count, FillModeAlternate);
  882. }
  883. Status FillPolygon(IN const Brush* brush,
  884. IN const PointI* points,
  885. IN INT count,
  886. IN FillMode fillMode)
  887. {
  888. return SetStatus(DllExports::GdipFillPolygonI(nativeGraphics,
  889. brush->nativeBrush,
  890. points, count,
  891. fillMode));
  892. }
  893. Status FillEllipse(IN const Brush* brush,
  894. IN const RectF& rect)
  895. {
  896. return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  897. }
  898. Status FillEllipse(IN const Brush* brush,
  899. IN REAL x,
  900. IN REAL y,
  901. IN REAL width,
  902. IN REAL height)
  903. {
  904. return SetStatus(DllExports::GdipFillEllipse(nativeGraphics,
  905. brush->nativeBrush, x, y,
  906. width, height));
  907. }
  908. Status FillEllipse(IN const Brush* brush,
  909. IN const Rect& rect)
  910. {
  911. return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  912. }
  913. Status FillEllipse(IN const Brush* brush,
  914. IN INT x,
  915. IN INT y,
  916. IN INT width,
  917. IN INT height)
  918. {
  919. return SetStatus(DllExports::GdipFillEllipseI(nativeGraphics,
  920. brush->nativeBrush,
  921. x,
  922. y,
  923. width,
  924. height));
  925. }
  926. Status FillPie(IN const Brush* brush,
  927. IN const RectF& rect,
  928. IN REAL startAngle,
  929. IN REAL sweepAngle)
  930. {
  931. return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  932. startAngle, sweepAngle);
  933. }
  934. Status FillPie(IN const Brush* brush,
  935. IN REAL x,
  936. IN REAL y,
  937. IN REAL width,
  938. IN REAL height,
  939. IN REAL startAngle,
  940. IN REAL sweepAngle)
  941. {
  942. return SetStatus(DllExports::GdipFillPie(nativeGraphics,
  943. brush->nativeBrush, x, y,
  944. width, height, startAngle,
  945. sweepAngle));
  946. }
  947. Status FillPie(IN const Brush* brush,
  948. IN const Rect& rect,
  949. IN REAL startAngle,
  950. IN REAL sweepAngle)
  951. {
  952. return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  953. startAngle, sweepAngle);
  954. }
  955. Status FillPie(IN const Brush* brush,
  956. IN INT x,
  957. IN INT y,
  958. IN INT width,
  959. IN INT height,
  960. IN REAL startAngle,
  961. IN REAL sweepAngle)
  962. {
  963. return SetStatus(DllExports::GdipFillPieI(nativeGraphics,
  964. brush->nativeBrush,
  965. x,
  966. y,
  967. width,
  968. height,
  969. startAngle,
  970. sweepAngle));
  971. }
  972. Status FillPath(IN const Brush* brush,
  973. IN const GraphicsPath* path)
  974. {
  975. return SetStatus(DllExports::GdipFillPath(nativeGraphics,
  976. brush->nativeBrush,
  977. path->nativePath));
  978. }
  979. Status FillClosedCurve(IN const Brush* brush,
  980. IN const PointF* points,
  981. IN INT count)
  982. {
  983. return SetStatus(DllExports::GdipFillClosedCurve(nativeGraphics,
  984. brush->nativeBrush,
  985. points, count));
  986. }
  987. Status FillClosedCurve(IN const Brush* brush,
  988. IN const PointF* points,
  989. IN INT count,
  990. IN FillMode fillMode,
  991. IN REAL tension = 0.5f)
  992. {
  993. return SetStatus(DllExports::GdipFillClosedCurve2(nativeGraphics,
  994. brush->nativeBrush,
  995. points, count,
  996. tension, fillMode));
  997. }
  998. Status FillClosedCurve(IN const Brush* brush,
  999. IN const PointI* points,
  1000. IN INT count)
  1001. {
  1002. return SetStatus(DllExports::GdipFillClosedCurveI(nativeGraphics,
  1003. brush->nativeBrush,
  1004. points,
  1005. count));
  1006. }
  1007. Status FillClosedCurve(IN const Brush* brush,
  1008. IN const PointI* points,
  1009. IN INT count,
  1010. IN FillMode fillMode,
  1011. IN REAL tension = 0.5f)
  1012. {
  1013. return SetStatus(DllExports::GdipFillClosedCurve2I(nativeGraphics,
  1014. brush->nativeBrush,
  1015. points, count,
  1016. tension, fillMode));
  1017. }
  1018. Status FillRegion(IN const Brush* brush,
  1019. IN const Region* region)
  1020. {
  1021. return SetStatus(DllExports::GdipFillRegion(nativeGraphics,
  1022. brush->nativeBrush,
  1023. region->nativeRegion));
  1024. }
  1025. Status
  1026. DrawString(
  1027. IN const WCHAR *string,
  1028. IN INT length,
  1029. IN const Font *font,
  1030. IN const RectF &layoutRect,
  1031. IN const StringFormat *stringFormat,
  1032. IN const Brush *brush
  1033. )
  1034. {
  1035. return SetStatus(DllExports::GdipDrawString(
  1036. nativeGraphics,
  1037. string,
  1038. length,
  1039. font ? font->nativeFont : NULL,
  1040. &layoutRect,
  1041. stringFormat ? stringFormat->nativeFormat : NULL,
  1042. brush ? brush->nativeBrush : NULL
  1043. ));
  1044. }
  1045. Status
  1046. DrawString(
  1047. const WCHAR *string,
  1048. INT length,
  1049. const Font *font,
  1050. const PointF &origin,
  1051. const Brush *brush
  1052. )
  1053. {
  1054. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1055. return SetStatus(DllExports::GdipDrawString(
  1056. nativeGraphics,
  1057. string,
  1058. length,
  1059. font ? font->nativeFont : NULL,
  1060. &rect,
  1061. NULL,
  1062. brush ? brush->nativeBrush : NULL
  1063. ));
  1064. }
  1065. Status
  1066. DrawString(
  1067. const WCHAR *string,
  1068. INT length,
  1069. const Font *font,
  1070. const PointF &origin,
  1071. const StringFormat *stringFormat,
  1072. const Brush *brush
  1073. )
  1074. {
  1075. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1076. return SetStatus(DllExports::GdipDrawString(
  1077. nativeGraphics,
  1078. string,
  1079. length,
  1080. font ? font->nativeFont : NULL,
  1081. &rect,
  1082. stringFormat ? stringFormat->nativeFormat : NULL,
  1083. brush ? brush->nativeBrush : NULL
  1084. ));
  1085. }
  1086. Status
  1087. MeasureString(
  1088. IN const WCHAR *string,
  1089. IN INT length,
  1090. IN const Font *font,
  1091. IN const RectF &layoutRect,
  1092. IN const StringFormat *stringFormat,
  1093. OUT RectF *boundingBox,
  1094. OUT INT *codepointsFitted = 0,
  1095. OUT INT *linesFilled = 0
  1096. ) const
  1097. {
  1098. return SetStatus(DllExports::GdipMeasureString(
  1099. nativeGraphics,
  1100. string,
  1101. length,
  1102. font ? font->nativeFont : NULL,
  1103. &layoutRect,
  1104. stringFormat ? stringFormat->nativeFormat : NULL,
  1105. boundingBox,
  1106. codepointsFitted,
  1107. linesFilled
  1108. ));
  1109. }
  1110. Status
  1111. MeasureString(
  1112. IN const WCHAR *string,
  1113. IN INT length,
  1114. IN const Font *font,
  1115. IN const SizeF &layoutRectSize,
  1116. IN const StringFormat *stringFormat,
  1117. OUT SizeF *size,
  1118. OUT INT *codepointsFitted = 0,
  1119. OUT INT *linesFilled = 0
  1120. ) const
  1121. {
  1122. RectF layoutRect(0, 0, layoutRectSize.Width, layoutRectSize.Height);
  1123. RectF boundingBox;
  1124. Status status;
  1125. if (size == NULL)
  1126. {
  1127. return SetStatus(InvalidParameter);
  1128. }
  1129. status = SetStatus(DllExports::GdipMeasureString(
  1130. nativeGraphics,
  1131. string,
  1132. length,
  1133. font ? font->nativeFont : NULL,
  1134. &layoutRect,
  1135. stringFormat ? stringFormat->nativeFormat : NULL,
  1136. size ? &boundingBox : NULL,
  1137. codepointsFitted,
  1138. linesFilled
  1139. ));
  1140. if (size && status == Ok)
  1141. {
  1142. size->Width = boundingBox.Width;
  1143. size->Height = boundingBox.Height;
  1144. }
  1145. return status;
  1146. }
  1147. Status
  1148. MeasureString(
  1149. IN const WCHAR *string,
  1150. IN INT length,
  1151. IN const Font *font,
  1152. IN const PointF &origin,
  1153. IN const StringFormat *stringFormat,
  1154. OUT RectF *boundingBox
  1155. ) const
  1156. {
  1157. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1158. return SetStatus(DllExports::GdipMeasureString(
  1159. nativeGraphics,
  1160. string,
  1161. length,
  1162. font ? font->nativeFont : NULL,
  1163. &rect,
  1164. stringFormat ? stringFormat->nativeFormat : NULL,
  1165. boundingBox,
  1166. NULL,
  1167. NULL
  1168. ));
  1169. }
  1170. Status
  1171. MeasureString(
  1172. IN const WCHAR *string,
  1173. IN INT length,
  1174. IN const Font *font,
  1175. IN const RectF &layoutRect,
  1176. OUT RectF *boundingBox
  1177. ) const
  1178. {
  1179. return SetStatus(DllExports::GdipMeasureString(
  1180. nativeGraphics,
  1181. string,
  1182. length,
  1183. font ? font->nativeFont : NULL,
  1184. &layoutRect,
  1185. NULL,
  1186. boundingBox,
  1187. NULL,
  1188. NULL
  1189. ));
  1190. }
  1191. Status
  1192. MeasureString(
  1193. IN const WCHAR *string,
  1194. IN INT length,
  1195. IN const Font *font,
  1196. IN const PointF &origin,
  1197. OUT RectF *boundingBox
  1198. ) const
  1199. {
  1200. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1201. return SetStatus(DllExports::GdipMeasureString(
  1202. nativeGraphics,
  1203. string,
  1204. length,
  1205. font ? font->nativeFont : NULL,
  1206. &rect,
  1207. NULL,
  1208. boundingBox,
  1209. NULL,
  1210. NULL
  1211. ));
  1212. }
  1213. Status
  1214. MeasureCharacterRanges(
  1215. IN const WCHAR *string,
  1216. IN INT length,
  1217. IN const Font *font,
  1218. IN const RectF &layoutRect,
  1219. IN const StringFormat *stringFormat,
  1220. IN INT regionCount,
  1221. OUT Region *regions
  1222. ) const
  1223. {
  1224. if (!regions || regionCount <= 0)
  1225. {
  1226. return InvalidParameter;
  1227. }
  1228. GpRegion **nativeRegions = new GpRegion* [regionCount];
  1229. if (!nativeRegions)
  1230. {
  1231. return OutOfMemory;
  1232. }
  1233. for (INT i = 0; i < regionCount; i++)
  1234. {
  1235. nativeRegions[i] = regions[i].nativeRegion;
  1236. }
  1237. Status status = SetStatus(DllExports::GdipMeasureCharacterRanges(
  1238. nativeGraphics,
  1239. string,
  1240. length,
  1241. font ? font->nativeFont : NULL,
  1242. layoutRect,
  1243. stringFormat ? stringFormat->nativeFormat : NULL,
  1244. regionCount,
  1245. nativeRegions
  1246. ));
  1247. delete [] nativeRegions;
  1248. return status;
  1249. }
  1250. Status DrawDriverString(
  1251. IN const UINT16 *text,
  1252. IN INT length,
  1253. IN const Font *font,
  1254. IN const Brush *brush,
  1255. IN const PointF *positions,
  1256. IN INT flags,
  1257. IN const Matrix *matrix
  1258. )
  1259. {
  1260. return SetStatus(DllExports::GdipDrawDriverString(
  1261. nativeGraphics,
  1262. text,
  1263. length,
  1264. font ? font->nativeFont : NULL,
  1265. brush ? brush->nativeBrush : NULL,
  1266. positions,
  1267. flags,
  1268. matrix ? matrix->nativeMatrix : NULL
  1269. ));
  1270. }
  1271. Status MeasureDriverString(
  1272. IN const UINT16 *text,
  1273. IN INT length,
  1274. IN const Font *font,
  1275. IN const PointF *positions,
  1276. IN INT flags,
  1277. IN const Matrix *matrix,
  1278. OUT RectF *boundingBox
  1279. ) const
  1280. {
  1281. return SetStatus(DllExports::GdipMeasureDriverString(
  1282. nativeGraphics,
  1283. text,
  1284. length,
  1285. font ? font->nativeFont : NULL,
  1286. positions,
  1287. flags,
  1288. matrix ? matrix->nativeMatrix : NULL,
  1289. boundingBox
  1290. ));
  1291. }
  1292. // Draw a cached bitmap on this graphics destination offset by
  1293. // x, y. Note this will fail with WrongState if the CachedBitmap
  1294. // native format differs from this Graphics.
  1295. Status DrawCachedBitmap(IN CachedBitmap *cb,
  1296. IN INT x,
  1297. IN INT y)
  1298. {
  1299. return SetStatus(DllExports::GdipDrawCachedBitmap(
  1300. nativeGraphics,
  1301. cb->nativeCachedBitmap,
  1302. x, y
  1303. ));
  1304. }
  1305. Status DrawImage(IN Image* image,
  1306. IN const PointF& point)
  1307. {
  1308. return DrawImage(image, point.X, point.Y);
  1309. }
  1310. Status DrawImage(IN Image* image,
  1311. IN REAL x,
  1312. IN REAL y)
  1313. {
  1314. return SetStatus(DllExports::GdipDrawImage(nativeGraphics,
  1315. image ? image->nativeImage
  1316. : NULL,
  1317. x,
  1318. y));
  1319. }
  1320. Status DrawImage(IN Image* image,
  1321. IN const RectF& rect)
  1322. {
  1323. return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
  1324. }
  1325. Status DrawImage(IN Image* image,
  1326. IN REAL x,
  1327. IN REAL y,
  1328. IN REAL width,
  1329. IN REAL height)
  1330. {
  1331. return SetStatus(DllExports::GdipDrawImageRect(nativeGraphics,
  1332. image ? image->nativeImage
  1333. : NULL,
  1334. x,
  1335. y,
  1336. width,
  1337. height));
  1338. }
  1339. Status DrawImage(IN Image* image,
  1340. IN const PointI& point)
  1341. {
  1342. return DrawImage(image, point.X, point.Y);
  1343. }
  1344. Status DrawImage(IN Image* image,
  1345. IN INT x,
  1346. IN INT y)
  1347. {
  1348. return SetStatus(DllExports::GdipDrawImageI(nativeGraphics,
  1349. image ? image->nativeImage
  1350. : NULL,
  1351. x,
  1352. y));
  1353. }
  1354. Status DrawImage(IN Image* image,
  1355. IN const Rect& rect)
  1356. {
  1357. return DrawImage(image,
  1358. rect.X,
  1359. rect.Y,
  1360. rect.Width,
  1361. rect.Height);
  1362. }
  1363. Status DrawImage(IN Image* image,
  1364. IN INT x,
  1365. IN INT y,
  1366. IN INT width,
  1367. IN INT height) {
  1368. return SetStatus(DllExports::GdipDrawImageRectI(nativeGraphics,
  1369. image ? image->nativeImage
  1370. : NULL,
  1371. x,
  1372. y,
  1373. width,
  1374. height));
  1375. }
  1376. // Affine Draw Image
  1377. // destPoints.length = 3: rect => parallelogram
  1378. // destPoints[0] <=> top-left corner of the source rectangle
  1379. // destPoints[1] <=> top-right corner
  1380. // destPoints[2] <=> bottom-left corner
  1381. // destPoints.length = 4: rect => quad
  1382. // destPoints[3] <=> bottom-right corner
  1383. Status DrawImage(IN Image* image,
  1384. IN const PointF* destPoints,
  1385. IN INT count)
  1386. {
  1387. if (count != 3 && count != 4)
  1388. return SetStatus(InvalidParameter);
  1389. return SetStatus(DllExports::GdipDrawImagePoints(nativeGraphics,
  1390. image ? image->nativeImage
  1391. : NULL,
  1392. destPoints, count));
  1393. }
  1394. Status DrawImage(IN Image* image,
  1395. IN const PointI* destPoints,
  1396. IN INT count)
  1397. {
  1398. if (count != 3 && count != 4)
  1399. return SetStatus(InvalidParameter);
  1400. return SetStatus(DllExports::GdipDrawImagePointsI(nativeGraphics,
  1401. image ? image->nativeImage
  1402. : NULL,
  1403. destPoints,
  1404. count));
  1405. }
  1406. Status DrawImage(IN Image* image,
  1407. IN REAL x,
  1408. IN REAL y,
  1409. IN REAL srcx,
  1410. IN REAL srcy,
  1411. IN REAL srcwidth,
  1412. IN REAL srcheight,
  1413. IN Unit srcUnit)
  1414. {
  1415. return SetStatus(DllExports::GdipDrawImagePointRect(nativeGraphics,
  1416. image ? image->nativeImage
  1417. : NULL,
  1418. x, y,
  1419. srcx, srcy,
  1420. srcwidth, srcheight, srcUnit));
  1421. }
  1422. Status DrawImage(IN Image* image,
  1423. IN const RectF& destRect,
  1424. IN REAL srcx,
  1425. IN REAL srcy,
  1426. IN REAL srcwidth,
  1427. IN REAL srcheight,
  1428. IN Unit srcUnit,
  1429. IN const ImageAttributes* imageAttributes = NULL,
  1430. IN DrawImageAbort callback = NULL,
  1431. IN VOID* callbackData = NULL)
  1432. {
  1433. return SetStatus(DllExports::GdipDrawImageRectRect(nativeGraphics,
  1434. image ? image->nativeImage
  1435. : NULL,
  1436. destRect.X,
  1437. destRect.Y,
  1438. destRect.Width,
  1439. destRect.Height,
  1440. srcx, srcy,
  1441. srcwidth, srcheight,
  1442. srcUnit,
  1443. imageAttributes
  1444. ? imageAttributes->nativeImageAttr
  1445. : NULL,
  1446. callback,
  1447. callbackData));
  1448. }
  1449. Status DrawImage(IN Image* image,
  1450. IN const PointF* destPoints,
  1451. IN INT count,
  1452. IN REAL srcx,
  1453. IN REAL srcy,
  1454. IN REAL srcwidth,
  1455. IN REAL srcheight,
  1456. IN Unit srcUnit,
  1457. IN const ImageAttributes* imageAttributes = NULL,
  1458. IN DrawImageAbort callback = NULL,
  1459. IN VOID* callbackData = NULL)
  1460. {
  1461. return SetStatus(DllExports::GdipDrawImagePointsRect(nativeGraphics,
  1462. image ? image->nativeImage
  1463. : NULL,
  1464. destPoints, count,
  1465. srcx, srcy,
  1466. srcwidth,
  1467. srcheight,
  1468. srcUnit,
  1469. imageAttributes
  1470. ? imageAttributes->nativeImageAttr
  1471. : NULL,
  1472. callback,
  1473. callbackData));
  1474. }
  1475. Status DrawImage(IN Image* image,
  1476. IN INT x,
  1477. IN INT y,
  1478. IN INT srcx,
  1479. IN INT srcy,
  1480. IN INT srcwidth,
  1481. IN INT srcheight,
  1482. IN Unit srcUnit)
  1483. {
  1484. return SetStatus(DllExports::GdipDrawImagePointRectI(nativeGraphics,
  1485. image ? image->nativeImage
  1486. : NULL,
  1487. x,
  1488. y,
  1489. srcx,
  1490. srcy,
  1491. srcwidth,
  1492. srcheight,
  1493. srcUnit));
  1494. }
  1495. Status DrawImage(IN Image* image,
  1496. IN const Rect& destRect,
  1497. IN INT srcx,
  1498. IN INT srcy,
  1499. IN INT srcwidth,
  1500. IN INT srcheight,
  1501. IN Unit srcUnit,
  1502. IN const ImageAttributes* imageAttributes = NULL,
  1503. IN DrawImageAbort callback = NULL,
  1504. IN VOID* callbackData = NULL)
  1505. {
  1506. return SetStatus(DllExports::GdipDrawImageRectRectI(nativeGraphics,
  1507. image ? image->nativeImage
  1508. : NULL,
  1509. destRect.X,
  1510. destRect.Y,
  1511. destRect.Width,
  1512. destRect.Height,
  1513. srcx,
  1514. srcy,
  1515. srcwidth,
  1516. srcheight,
  1517. srcUnit,
  1518. imageAttributes
  1519. ? imageAttributes->nativeImageAttr
  1520. : NULL,
  1521. callback,
  1522. callbackData));
  1523. }
  1524. Status DrawImage(IN Image* image,
  1525. IN const PointI* destPoints,
  1526. IN INT count,
  1527. IN INT srcx,
  1528. IN INT srcy,
  1529. IN INT srcwidth,
  1530. IN INT srcheight,
  1531. IN Unit srcUnit,
  1532. IN const ImageAttributes* imageAttributes = NULL,
  1533. IN DrawImageAbort callback = NULL,
  1534. IN VOID* callbackData = NULL)
  1535. {
  1536. return SetStatus(DllExports::GdipDrawImagePointsRectI(nativeGraphics,
  1537. image ? image->nativeImage
  1538. : NULL,
  1539. destPoints,
  1540. count,
  1541. srcx,
  1542. srcy,
  1543. srcwidth,
  1544. srcheight,
  1545. srcUnit,
  1546. imageAttributes
  1547. ? imageAttributes->nativeImageAttr
  1548. : NULL,
  1549. callback,
  1550. callbackData));
  1551. }
  1552. // The following methods are for playing an EMF+ to a graphics
  1553. // via the enumeration interface. Each record of the EMF+ is
  1554. // sent to the callback (along with the callbackData). Then
  1555. // the callback can invoke the Metafile::PlayRecord method
  1556. // to play the particular record.
  1557. Status
  1558. EnumerateMetafile(
  1559. IN const Metafile * metafile,
  1560. IN const PointF & destPoint,
  1561. IN EnumerateMetafileProc callback,
  1562. IN VOID * callbackData = NULL,
  1563. IN const ImageAttributes * imageAttributes = NULL
  1564. )
  1565. {
  1566. return SetStatus(DllExports::GdipEnumerateMetafileDestPoint(
  1567. nativeGraphics,
  1568. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1569. destPoint,
  1570. callback,
  1571. callbackData,
  1572. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1573. }
  1574. Status
  1575. EnumerateMetafile(
  1576. IN const Metafile * metafile,
  1577. IN const PointI & destPoint,
  1578. IN EnumerateMetafileProc callback,
  1579. IN VOID * callbackData = NULL,
  1580. IN const ImageAttributes * imageAttributes = NULL
  1581. )
  1582. {
  1583. return SetStatus(DllExports::GdipEnumerateMetafileDestPointI(
  1584. nativeGraphics,
  1585. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1586. destPoint,
  1587. callback,
  1588. callbackData,
  1589. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1590. }
  1591. Status
  1592. EnumerateMetafile(
  1593. IN const Metafile * metafile,
  1594. IN const RectF & destRect,
  1595. IN EnumerateMetafileProc callback,
  1596. IN VOID * callbackData = NULL,
  1597. IN const ImageAttributes * imageAttributes = NULL
  1598. )
  1599. {
  1600. return SetStatus(DllExports::GdipEnumerateMetafileDestRect(
  1601. nativeGraphics,
  1602. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1603. destRect,
  1604. callback,
  1605. callbackData,
  1606. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1607. }
  1608. Status
  1609. EnumerateMetafile(
  1610. IN const Metafile * metafile,
  1611. IN const Rect & destRect,
  1612. IN EnumerateMetafileProc callback,
  1613. IN VOID * callbackData = NULL,
  1614. IN const ImageAttributes * imageAttributes = NULL
  1615. )
  1616. {
  1617. return SetStatus(DllExports::GdipEnumerateMetafileDestRectI(
  1618. nativeGraphics,
  1619. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1620. destRect,
  1621. callback,
  1622. callbackData,
  1623. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1624. }
  1625. Status
  1626. EnumerateMetafile(
  1627. IN const Metafile * metafile,
  1628. IN const PointF * destPoints,
  1629. IN INT count,
  1630. IN EnumerateMetafileProc callback,
  1631. IN VOID * callbackData = NULL,
  1632. IN const ImageAttributes * imageAttributes = NULL
  1633. )
  1634. {
  1635. return SetStatus(DllExports::GdipEnumerateMetafileDestPoints(
  1636. nativeGraphics,
  1637. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1638. destPoints,
  1639. count,
  1640. callback,
  1641. callbackData,
  1642. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1643. }
  1644. Status
  1645. EnumerateMetafile(
  1646. IN const Metafile * metafile,
  1647. IN const PointI * destPoints,
  1648. IN INT count,
  1649. IN EnumerateMetafileProc callback,
  1650. IN VOID * callbackData = NULL,
  1651. IN const ImageAttributes * imageAttributes = NULL
  1652. )
  1653. {
  1654. return SetStatus(DllExports::GdipEnumerateMetafileDestPointsI(
  1655. nativeGraphics,
  1656. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1657. destPoints,
  1658. count,
  1659. callback,
  1660. callbackData,
  1661. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1662. }
  1663. Status
  1664. EnumerateMetafile(
  1665. IN const Metafile * metafile,
  1666. IN const PointF & destPoint,
  1667. IN const RectF & srcRect,
  1668. IN Unit srcUnit,
  1669. IN EnumerateMetafileProc callback,
  1670. IN VOID * callbackData = NULL,
  1671. IN const ImageAttributes * imageAttributes = NULL
  1672. )
  1673. {
  1674. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoint(
  1675. nativeGraphics,
  1676. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1677. destPoint,
  1678. srcRect,
  1679. srcUnit,
  1680. callback,
  1681. callbackData,
  1682. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1683. }
  1684. Status
  1685. EnumerateMetafile(
  1686. IN const Metafile * metafile,
  1687. IN const PointI & destPoint,
  1688. IN const Rect & srcRect,
  1689. IN Unit srcUnit,
  1690. IN EnumerateMetafileProc callback,
  1691. IN VOID * callbackData = NULL,
  1692. IN const ImageAttributes * imageAttributes = NULL
  1693. )
  1694. {
  1695. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointI(
  1696. nativeGraphics,
  1697. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1698. destPoint,
  1699. srcRect,
  1700. srcUnit,
  1701. callback,
  1702. callbackData,
  1703. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1704. }
  1705. Status
  1706. EnumerateMetafile(
  1707. IN const Metafile * metafile,
  1708. IN const RectF & destRect,
  1709. IN const RectF & srcRect,
  1710. IN Unit srcUnit,
  1711. IN EnumerateMetafileProc callback,
  1712. IN VOID * callbackData = NULL,
  1713. IN const ImageAttributes * imageAttributes = NULL
  1714. )
  1715. {
  1716. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestRect(
  1717. nativeGraphics,
  1718. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1719. destRect,
  1720. srcRect,
  1721. srcUnit,
  1722. callback,
  1723. callbackData,
  1724. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1725. }
  1726. Status
  1727. EnumerateMetafile(
  1728. IN const Metafile * metafile,
  1729. IN const Rect & destRect,
  1730. IN const Rect & srcRect,
  1731. IN Unit srcUnit,
  1732. IN EnumerateMetafileProc callback,
  1733. IN VOID * callbackData = NULL,
  1734. IN const ImageAttributes * imageAttributes = NULL
  1735. )
  1736. {
  1737. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestRectI(
  1738. nativeGraphics,
  1739. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1740. destRect,
  1741. srcRect,
  1742. srcUnit,
  1743. callback,
  1744. callbackData,
  1745. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1746. }
  1747. Status
  1748. EnumerateMetafile(
  1749. IN const Metafile * metafile,
  1750. IN const PointF * destPoints,
  1751. IN INT count,
  1752. IN const RectF & srcRect,
  1753. IN Unit srcUnit,
  1754. IN EnumerateMetafileProc callback,
  1755. IN VOID * callbackData = NULL,
  1756. IN const ImageAttributes * imageAttributes = NULL
  1757. )
  1758. {
  1759. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoints(
  1760. nativeGraphics,
  1761. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1762. destPoints,
  1763. count,
  1764. srcRect,
  1765. srcUnit,
  1766. callback,
  1767. callbackData,
  1768. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1769. }
  1770. Status
  1771. EnumerateMetafile(
  1772. IN const Metafile * metafile,
  1773. IN const PointI * destPoints,
  1774. IN INT count,
  1775. IN const Rect & srcRect,
  1776. IN Unit srcUnit,
  1777. IN EnumerateMetafileProc callback,
  1778. IN VOID * callbackData = NULL,
  1779. IN const ImageAttributes * imageAttributes = NULL
  1780. )
  1781. {
  1782. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointsI(
  1783. nativeGraphics,
  1784. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1785. destPoints,
  1786. count,
  1787. srcRect,
  1788. srcUnit,
  1789. callback,
  1790. callbackData,
  1791. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1792. }
  1793. Status SetClip(IN const Graphics* g,
  1794. IN CombineMode combineMode = CombineModeReplace)
  1795. {
  1796. return SetStatus(DllExports::GdipSetClipGraphics(nativeGraphics,
  1797. g->nativeGraphics,
  1798. combineMode));
  1799. }
  1800. Status SetClip(IN const RectF& rect,
  1801. IN CombineMode combineMode = CombineModeReplace)
  1802. {
  1803. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1804. rect.X, rect.Y,
  1805. rect.Width, rect.Height,
  1806. combineMode));
  1807. }
  1808. Status SetClip(IN const Rect& rect,
  1809. IN CombineMode combineMode = CombineModeReplace)
  1810. {
  1811. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1812. rect.X, rect.Y,
  1813. rect.Width, rect.Height,
  1814. combineMode));
  1815. }
  1816. Status SetClip(IN const GraphicsPath* path,
  1817. IN CombineMode combineMode = CombineModeReplace)
  1818. {
  1819. return SetStatus(DllExports::GdipSetClipPath(nativeGraphics,
  1820. path->nativePath,
  1821. combineMode));
  1822. }
  1823. Status SetClip(IN const Region* region,
  1824. IN CombineMode combineMode = CombineModeReplace)
  1825. {
  1826. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1827. region->nativeRegion,
  1828. combineMode));
  1829. }
  1830. // This is different than the other SetClip methods because it assumes
  1831. // that the HRGN is already in device units, so it doesn't transform
  1832. // the coordinates in the HRGN.
  1833. Status SetClip(IN HRGN hRgn,
  1834. IN CombineMode combineMode = CombineModeReplace)
  1835. {
  1836. return SetStatus(DllExports::GdipSetClipHrgn(nativeGraphics, hRgn,
  1837. combineMode));
  1838. }
  1839. Status IntersectClip(IN const RectF& rect)
  1840. {
  1841. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1842. rect.X, rect.Y,
  1843. rect.Width, rect.Height,
  1844. CombineModeIntersect));
  1845. }
  1846. Status IntersectClip(IN const Rect& rect)
  1847. {
  1848. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1849. rect.X, rect.Y,
  1850. rect.Width, rect.Height,
  1851. CombineModeIntersect));
  1852. }
  1853. Status IntersectClip(IN const Region* region)
  1854. {
  1855. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1856. region->nativeRegion,
  1857. CombineModeIntersect));
  1858. }
  1859. Status ExcludeClip(IN const RectF& rect)
  1860. {
  1861. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1862. rect.X, rect.Y,
  1863. rect.Width, rect.Height,
  1864. CombineModeExclude));
  1865. }
  1866. Status ExcludeClip(IN const Rect& rect)
  1867. {
  1868. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1869. rect.X, rect.Y,
  1870. rect.Width, rect.Height,
  1871. CombineModeExclude));
  1872. }
  1873. Status ExcludeClip(IN const Region* region)
  1874. {
  1875. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1876. region->nativeRegion,
  1877. CombineModeExclude));
  1878. }
  1879. Status ResetClip()
  1880. {
  1881. return SetStatus(DllExports::GdipResetClip(nativeGraphics));
  1882. }
  1883. Status TranslateClip(IN REAL dx,
  1884. IN REAL dy)
  1885. {
  1886. return SetStatus(DllExports::GdipTranslateClip(nativeGraphics, dx, dy));
  1887. }
  1888. Status TranslateClip(IN INT dx,
  1889. IN INT dy)
  1890. {
  1891. return SetStatus(DllExports::GdipTranslateClipI(nativeGraphics,
  1892. dx, dy));
  1893. }
  1894. Status GetClip(OUT Region* region) const
  1895. {
  1896. return SetStatus(DllExports::GdipGetClip(nativeGraphics,
  1897. region->nativeRegion));
  1898. }
  1899. Status GetClipBounds(OUT RectF* rect) const
  1900. {
  1901. return SetStatus(DllExports::GdipGetClipBounds(nativeGraphics, rect));
  1902. }
  1903. Status GetClipBounds(OUT Rect* rect) const
  1904. {
  1905. return SetStatus(DllExports::GdipGetClipBoundsI(nativeGraphics, rect));
  1906. }
  1907. BOOL IsClipEmpty() const
  1908. {
  1909. BOOL booln = FALSE;
  1910. SetStatus(DllExports::GdipIsClipEmpty(nativeGraphics, &booln));
  1911. return booln;
  1912. }
  1913. Status GetVisibleClipBounds(OUT RectF *rect) const
  1914. {
  1915. return SetStatus(DllExports::GdipGetVisibleClipBounds(nativeGraphics,
  1916. rect));
  1917. }
  1918. Status GetVisibleClipBounds(OUT Rect *rect) const
  1919. {
  1920. return SetStatus(DllExports::GdipGetVisibleClipBoundsI(nativeGraphics,
  1921. rect));
  1922. }
  1923. BOOL IsVisibleClipEmpty() const
  1924. {
  1925. BOOL booln = FALSE;
  1926. SetStatus(DllExports::GdipIsVisibleClipEmpty(nativeGraphics, &booln));
  1927. return booln;
  1928. }
  1929. BOOL IsVisible(IN INT x,
  1930. IN INT y) const
  1931. {
  1932. return IsVisible(PointI(x,y));
  1933. }
  1934. BOOL IsVisible(IN const PointI& point) const
  1935. {
  1936. BOOL booln = FALSE;
  1937. SetStatus(DllExports::GdipIsVisiblePointI(nativeGraphics,
  1938. point.X,
  1939. point.Y,
  1940. &booln));
  1941. return booln;
  1942. }
  1943. BOOL IsVisible(IN INT x,
  1944. IN INT y,
  1945. IN INT width,
  1946. IN INT height) const
  1947. {
  1948. return IsVisible(Rect(x, y, width, height));
  1949. }
  1950. BOOL IsVisible(IN const Rect& rect) const
  1951. {
  1952. BOOL booln = TRUE;
  1953. SetStatus(DllExports::GdipIsVisibleRectI(nativeGraphics,
  1954. rect.X,
  1955. rect.Y,
  1956. rect.Width,
  1957. rect.Height,
  1958. &booln));
  1959. return booln;
  1960. }
  1961. BOOL IsVisible(IN REAL x,
  1962. IN REAL y) const
  1963. {
  1964. return IsVisible(PointF(x, y));
  1965. }
  1966. BOOL IsVisible(IN const PointF& point) const
  1967. {
  1968. BOOL booln = FALSE;
  1969. SetStatus(DllExports::GdipIsVisiblePoint(nativeGraphics,
  1970. point.X,
  1971. point.Y,
  1972. &booln));
  1973. return booln;
  1974. }
  1975. BOOL IsVisible(IN REAL x,
  1976. IN REAL y,
  1977. IN REAL width,
  1978. IN REAL height) const
  1979. {
  1980. return IsVisible(RectF(x, y, width, height));
  1981. }
  1982. BOOL IsVisible(IN const RectF& rect) const
  1983. {
  1984. BOOL booln = TRUE;
  1985. SetStatus(DllExports::GdipIsVisibleRect(nativeGraphics,
  1986. rect.X,
  1987. rect.Y,
  1988. rect.Width,
  1989. rect.Height,
  1990. &booln));
  1991. return booln;
  1992. }
  1993. GraphicsState Save() const
  1994. {
  1995. GraphicsState gstate;
  1996. SetStatus(DllExports::GdipSaveGraphics(nativeGraphics, &gstate));
  1997. return gstate;
  1998. }
  1999. Status Restore(IN GraphicsState gstate)
  2000. {
  2001. return SetStatus(DllExports::GdipRestoreGraphics(nativeGraphics,
  2002. gstate));
  2003. }
  2004. GraphicsContainer BeginContainer(IN const RectF &dstrect,
  2005. IN const RectF &srcrect,
  2006. IN Unit unit)
  2007. {
  2008. GraphicsContainer state;
  2009. SetStatus(DllExports::GdipBeginContainer(nativeGraphics, &dstrect,
  2010. &srcrect, unit, &state));
  2011. return state;
  2012. }
  2013. GraphicsContainer BeginContainer(IN const Rect &dstrect,
  2014. IN const Rect &srcrect,
  2015. IN Unit unit)
  2016. {
  2017. GraphicsContainer state;
  2018. SetStatus(DllExports::GdipBeginContainerI(nativeGraphics, &dstrect,
  2019. &srcrect, unit, &state));
  2020. return state;
  2021. }
  2022. GraphicsContainer BeginContainer()
  2023. {
  2024. GraphicsContainer state;
  2025. SetStatus(DllExports::GdipBeginContainer2(nativeGraphics, &state));
  2026. return state;
  2027. }
  2028. Status EndContainer(IN GraphicsContainer state)
  2029. {
  2030. return SetStatus(DllExports::GdipEndContainer(nativeGraphics, state));
  2031. }
  2032. // Only valid when recording metafiles.
  2033. Status AddMetafileComment(IN const BYTE * data,
  2034. IN UINT sizeData)
  2035. {
  2036. return SetStatus(DllExports::GdipComment(nativeGraphics, sizeData, data));
  2037. }
  2038. static HPALETTE GetHalftonePalette()
  2039. {
  2040. return DllExports::GdipCreateHalftonePalette();
  2041. }
  2042. Status GetLastStatus() const
  2043. {
  2044. Status lastStatus = lastResult;
  2045. lastResult = Ok;
  2046. return lastStatus;
  2047. }
  2048. private:
  2049. Graphics(const Graphics &);
  2050. Graphics& operator=(const Graphics &);
  2051. protected:
  2052. Graphics(GpGraphics* graphics)
  2053. {
  2054. lastResult = Ok;
  2055. SetNativeGraphics(graphics);
  2056. }
  2057. VOID SetNativeGraphics(GpGraphics *graphics)
  2058. {
  2059. this->nativeGraphics = graphics;
  2060. }
  2061. Status SetStatus(Status status) const
  2062. {
  2063. if (status != Ok)
  2064. return (lastResult = status);
  2065. else
  2066. return status;
  2067. }
  2068. GpGraphics* GetNativeGraphics() const
  2069. {
  2070. return this->nativeGraphics;
  2071. }
  2072. GpPen* GetNativePen(const Pen* pen)
  2073. {
  2074. return pen->nativePen;
  2075. }
  2076. protected:
  2077. GpGraphics* nativeGraphics;
  2078. mutable Status lastResult;
  2079. };
  2080. //----------------------------------------------------------------------------
  2081. // Implementation of GraphicsPath methods that use Graphics
  2082. //----------------------------------------------------------------------------
  2083. // The GetBounds rectangle may not be the tightest bounds.
  2084. inline Status
  2085. GraphicsPath::GetBounds(
  2086. OUT RectF* bounds,
  2087. IN const Matrix* matrix,
  2088. IN const Pen* pen) const
  2089. {
  2090. GpMatrix* nativeMatrix = NULL;
  2091. GpPen* nativePen = NULL;
  2092. if (matrix)
  2093. nativeMatrix = matrix->nativeMatrix;
  2094. if (pen)
  2095. nativePen = pen->nativePen;
  2096. return SetStatus(DllExports::GdipGetPathWorldBounds(nativePath, bounds,
  2097. nativeMatrix, nativePen));
  2098. }
  2099. inline Status
  2100. GraphicsPath::GetBounds(
  2101. OUT Rect* bounds,
  2102. IN const Matrix* matrix,
  2103. IN const Pen* pen
  2104. ) const
  2105. {
  2106. GpMatrix* nativeMatrix = NULL;
  2107. GpPen* nativePen = NULL;
  2108. if (matrix)
  2109. nativeMatrix = matrix->nativeMatrix;
  2110. if (pen)
  2111. nativePen = pen->nativePen;
  2112. return SetStatus(DllExports::GdipGetPathWorldBoundsI(nativePath, bounds,
  2113. nativeMatrix, nativePen));
  2114. }
  2115. inline BOOL
  2116. GraphicsPath::IsVisible(
  2117. IN REAL x,
  2118. IN REAL y,
  2119. IN const Graphics* g) const
  2120. {
  2121. BOOL booln = FALSE;
  2122. GpGraphics* nativeGraphics = NULL;
  2123. if (g)
  2124. nativeGraphics = g->nativeGraphics;
  2125. SetStatus(DllExports::GdipIsVisiblePathPoint(nativePath,
  2126. x, y, nativeGraphics,
  2127. &booln));
  2128. return booln;
  2129. }
  2130. inline BOOL
  2131. GraphicsPath::IsVisible(
  2132. IN INT x,
  2133. IN INT y,
  2134. IN const Graphics* g) const
  2135. {
  2136. BOOL booln = FALSE;
  2137. GpGraphics* nativeGraphics = NULL;
  2138. if (g)
  2139. nativeGraphics = g->nativeGraphics;
  2140. SetStatus(DllExports::GdipIsVisiblePathPointI(nativePath,
  2141. x, y, nativeGraphics,
  2142. &booln));
  2143. return booln;
  2144. }
  2145. inline BOOL
  2146. GraphicsPath::IsOutlineVisible(
  2147. IN REAL x,
  2148. IN REAL y,
  2149. IN const Pen* pen,
  2150. IN const Graphics* g) const
  2151. {
  2152. BOOL booln = FALSE;
  2153. GpGraphics* nativeGraphics = NULL;
  2154. GpPen* nativePen = NULL;
  2155. if(g)
  2156. nativeGraphics = g->nativeGraphics;
  2157. if(pen)
  2158. nativePen = pen->nativePen;
  2159. SetStatus(DllExports::GdipIsOutlineVisiblePathPoint(nativePath,
  2160. x, y, nativePen, nativeGraphics,
  2161. &booln));
  2162. return booln;
  2163. }
  2164. inline BOOL
  2165. GraphicsPath::IsOutlineVisible(
  2166. IN INT x,
  2167. IN INT y,
  2168. IN const Pen* pen,
  2169. IN const Graphics* g) const
  2170. {
  2171. BOOL booln = FALSE;
  2172. GpGraphics* nativeGraphics = NULL;
  2173. GpPen* nativePen = NULL;
  2174. if(g)
  2175. nativeGraphics = g->nativeGraphics;
  2176. if(pen)
  2177. nativePen = pen->nativePen;
  2178. SetStatus(DllExports::GdipIsOutlineVisiblePathPointI(nativePath,
  2179. x, y, nativePen, nativeGraphics,
  2180. &booln));
  2181. return booln;
  2182. }
  2183. #endif