Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13521 lines
286 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * flatapi.cpp
  8. *
  9. * Abstract:
  10. *
  11. * Flat GDI+ API wrappers
  12. *
  13. * Revision History:
  14. *
  15. * 12/13/1998 davidx
  16. * Created it.
  17. *
  18. \**************************************************************************/
  19. #include "precomp.hpp"
  20. #include "GdiplusFlat.h"
  21. #include "gpverp.h"
  22. #if DBG
  23. #include <mmsystem.h>
  24. #endif
  25. extern "C" {
  26. //--------------------------------------------------------------------------
  27. // CheckParameter(p)
  28. //
  29. // If p evaluates to FALSE, then we currently assert. In future,
  30. // we can simply return an invalid parameter status which throws
  31. // an exception.
  32. //
  33. // CheckObjectBusy(p)
  34. //
  35. // Not implemented. Bails out if object is currently being used.
  36. //
  37. //--------------------------------------------------------------------------
  38. //
  39. // !!!: Only include NULL & IsValid checks in checked builds?
  40. //
  41. // !!!: Instead of deleting object, call a Dispose() method, so far
  42. // only Bitmap supports this.
  43. //
  44. // !!!: Lock Matrix objects, what about color?
  45. //
  46. // !! Better error checking. For 'I' APIs which convert from Point to PointI,
  47. // etc. Verify count & point are valid first.
  48. //
  49. // !! Change ObjectLock to mutable memory and GetObjectLock() to a const member.
  50. //
  51. #define CheckParameter(cond) \
  52. if (! (cond)) \
  53. return InvalidParameter;
  54. #define CheckParameterValid(obj) \
  55. if (!(obj) || !((obj)->IsValid())) \
  56. return InvalidParameter;
  57. #define CheckOptionalParameterValid(obj) \
  58. if ((obj) && (!(obj)->IsValid())) \
  59. return InvalidParameter;
  60. #define CheckObjectBusy(obj) \
  61. GpLock lock##obj(obj->GetObjectLock()); \
  62. if (!(lock##obj).IsValid()) \
  63. return ObjectBusy;
  64. #define CheckOptionalObjectBusy(obj) \
  65. GpLock lock##obj(obj ? obj->GetObjectLock() : NULL); \
  66. if (obj && (!(lock##obj).IsValid())) \
  67. return ObjectBusy;
  68. // We should put an assert in here so that we stop in the debugger if anyone
  69. // does this.
  70. #define CheckObjectBusyForDelete(obj) \
  71. GpLock lock##obj(obj->GetObjectLock()); \
  72. if (!(lock##obj).IsValid()) \
  73. { \
  74. WARNING(("Silent memory leak deleting object %p.", obj)); \
  75. WARNING(("Object lock held by another thread."));\
  76. WARNING(("Incorrect synchronization by the calling application."));\
  77. return ObjectBusy; \
  78. } \
  79. lock##obj.MakePermanentLock();
  80. #define CheckColorParameter(color) \
  81. ;
  82. #define LazilyInitializeGdiplus
  83. #define CheckGdiplusInitialized \
  84. { GdiplusStartupCriticalSection critsec; \
  85. if (Globals::LibraryInitRefCount <= 0) \
  86. return GdiplusNotInitialized; \
  87. }
  88. #define CheckGdiplusInitialized_ReturnNULL \
  89. { GdiplusStartupCriticalSection critsec; \
  90. if (Globals::LibraryInitRefCount <= 0) \
  91. return NULL; \
  92. }
  93. #define MaskPixelFormat(pixel) (pixel & 0xFFFFFF)
  94. #if DBG
  95. // This class asserts that GDI+ is in an initialized state, to be used in
  96. // our entry-point functions in a debug build.
  97. //
  98. // We assert both at the start and the end of the call, and we make sure that
  99. // we don't hold the critical section for the duration of the API (else this
  100. // would serialize all our calls on debug builds.)
  101. class InitAsserter
  102. {
  103. public:
  104. InitAsserter() {
  105. GdiplusStartupCriticalSection critsec;
  106. ASSERTMSG(Globals::LibraryInitRefCount > 0, ("GDI+ API called before GdiplusStartup/after GdiplusShutdown."));
  107. }
  108. ~InitAsserter() {
  109. GdiplusStartupCriticalSection critsec;
  110. ASSERTMSG(Globals::LibraryInitRefCount > 0, ("GDI+ API called before GdiplusStartup/after GdiplusShutdown."));
  111. }
  112. };
  113. #endif
  114. #ifdef GP_ENABLE_MONITORS
  115. #ifdef GP_RELEASE_BUILD
  116. #define DEFINE_MONITOR(a)
  117. #else
  118. #define DEFINE_MONITOR(a) GpBlockMonitor blockMonitor(MONITOR(a));
  119. #endif
  120. #else
  121. #define DEFINE_MONITOR(a)
  122. #endif
  123. // Define this to do something on each API entry point.
  124. // This is a debugging aid for complex instruction streams (e.g. Office)
  125. // [agodfrey] Well, it just became more than a mere debugging aid...
  126. // [asecchia] Now it's definitely more than a debugging aid...
  127. // FPUStateSaver was being forgotten on many of our APIs so
  128. // it's now in here and therefore will be included in all of
  129. // our APIs (except Startup and Shutdown).
  130. #if DBG
  131. #define API_ENTRY(a) \
  132. DEFINE_MONITOR(a) \
  133. LazilyInitializeGdiplus; \
  134. VERBOSE(("GDI+ API " #a)); \
  135. InitAsserter __initAsserter; \
  136. FPUStateSaver fps;
  137. #define API_ENTRY_NO_INITCHECK(a) \
  138. DEFINE_MONITOR(a) \
  139. VERBOSE(("GDI+ API ", #a));
  140. #else
  141. #define API_ENTRY(a) \
  142. DEFINE_MONITOR(a) \
  143. LazilyInitializeGdiplus;\
  144. FPUStateSaver fps;
  145. #define API_ENTRY_NO_INITCHECK(a) \
  146. DEFINE_MONITOR(a)
  147. #endif
  148. GdiplusStartupOutput gStartupOutput = {
  149. NotificationStartup,
  150. NotificationShutdown
  151. };
  152. GpStatus WINAPI
  153. GdiplusStartup(
  154. OUT ULONG_PTR *token,
  155. const GdiplusStartupInput *input,
  156. OUT GdiplusStartupOutput *output)
  157. {
  158. API_ENTRY_NO_INITCHECK(GdiplusStartup);
  159. if ( (!token)
  160. || (!input)
  161. || (input->SuppressBackgroundThread && !output))
  162. {
  163. return InvalidParameter;
  164. }
  165. if (input->GdiplusVersion != 1)
  166. {
  167. return UnsupportedGdiplusVersion;
  168. }
  169. GdiplusStartupCriticalSection critsec;
  170. // Should never happen, because GdiplusShutdown won't decrement below zero.
  171. if (Globals::LibraryInitRefCount == 0)
  172. {
  173. // Note: We can't allocate anything before this point
  174. GpStatus ret = InternalGdiplusStartup(input);
  175. if (ret != Ok) return ret;
  176. Globals::LibraryInitToken = GenerateInitToken();
  177. }
  178. ASSERT(Globals::LibraryInitRefCount >= 0);
  179. *token = Globals::LibraryInitToken + Globals::LibraryInitRefCount;
  180. Globals::LibraryInitRefCount++;
  181. if (input->SuppressBackgroundThread)
  182. {
  183. *output = gStartupOutput;
  184. }
  185. return Ok;
  186. }
  187. VOID WINAPI
  188. GdiplusShutdown(
  189. ULONG_PTR token)
  190. {
  191. API_ENTRY_NO_INITCHECK(GdiplusShutdown);
  192. GdiplusStartupCriticalSection critsec;
  193. // Should never happen, because we won't decrement below zero.
  194. ASSERT(Globals::LibraryInitRefCount >= 0);
  195. if (Globals::LibraryInitRefCount == 0)
  196. {
  197. // Return - i.e. ignore the extra shutdown call
  198. RIP(("Too many calls to GdiplusShutdown"));
  199. return;
  200. }
  201. if (Globals::LibraryInitRefCount == 1)
  202. {
  203. // Shut down for real
  204. Globals::LibraryInitToken = 0;
  205. InternalGdiplusShutdown();
  206. // No allocation/deallocation can happen after this point
  207. }
  208. else if (token == Globals::LibraryInitToken)
  209. {
  210. // The first client to initialize is shutting down; we must clean up
  211. // after this one since it defines certain global behavior.
  212. Globals::UserDebugEventProc = NULL;
  213. }
  214. Globals::LibraryInitRefCount--;
  215. }
  216. GpStatus WINAPI
  217. GdiplusNotificationHook(
  218. OUT ULONG_PTR *token)
  219. {
  220. API_ENTRY(GdiplusNotificationHook);
  221. {
  222. GdiplusStartupCriticalSection critsec;
  223. // It's illegal to call this API if you're using a background thread.
  224. if (Globals::ThreadNotify)
  225. {
  226. return GenericError;
  227. }
  228. }
  229. return NotificationStartup(token);
  230. }
  231. VOID WINAPI
  232. GdiplusNotificationUnhook(
  233. ULONG_PTR token)
  234. {
  235. API_ENTRY(GdiplusNotificationUnhook);
  236. {
  237. GdiplusStartupCriticalSection critsec;
  238. // It's illegal to call this API if you're using a background thread.
  239. if (Globals::ThreadNotify)
  240. {
  241. return;
  242. }
  243. }
  244. NotificationShutdown(token);
  245. }
  246. GpStatus
  247. WINGDIPAPI
  248. GdipCreatePath(GpFillMode fillMode, GpPath **outPath)
  249. {
  250. API_ENTRY(GdipCreatePath);
  251. CheckGdiplusInitialized; // We do this in all our object creation API's
  252. CheckParameter(outPath);
  253. GpPath * path;
  254. path = (GpPath *) InterlockedExchangePointer((PVOID *) &Globals::PathLookAside, NULL);
  255. if(path != NULL)
  256. {
  257. path->GetObjectLock()->Reset();
  258. path->Reset(fillMode);
  259. }
  260. else
  261. {
  262. path = new (GpPathTag, TRUE) GpPath(fillMode);
  263. }
  264. if (CheckValid(path))
  265. {
  266. *outPath = path;
  267. return Ok;
  268. }
  269. else
  270. return OutOfMemory;
  271. }
  272. GpStatus
  273. WINGDIPAPI
  274. GdipCreatePath2(
  275. GDIPCONST GpPointF* points,
  276. GDIPCONST BYTE* types,
  277. INT count,
  278. GpFillMode fillMode,
  279. GpPath **path
  280. )
  281. {
  282. API_ENTRY(GdipCreatePath2);
  283. CheckGdiplusInitialized; // We do this in all our object creation API's
  284. CheckParameter(path && points && types);
  285. *path = new (GpPathTag, TRUE) GpPath(points, types, count, fillMode);
  286. if (CheckValid(*path))
  287. {
  288. return Ok;
  289. }
  290. else
  291. return OutOfMemory;
  292. }
  293. GpStatus
  294. WINGDIPAPI
  295. GdipCreatePath2I(
  296. GDIPCONST GpPoint* points,
  297. GDIPCONST BYTE* types,
  298. INT count,
  299. GpFillMode fillMode,
  300. GpPath **path
  301. )
  302. {
  303. API_ENTRY(GdipCreatePath2I);
  304. CheckGdiplusInitialized; // We do this in all our object creation API's
  305. CheckParameter(path && points && types);
  306. StackBuffer buffer;
  307. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  308. if(!pointsF) return OutOfMemory;
  309. for (INT i=0; i<count; i++)
  310. {
  311. pointsF[i].X = TOREAL(points[i].X);
  312. pointsF[i].Y = TOREAL(points[i].Y);
  313. }
  314. *path = new (GpPathTag, TRUE) GpPath(pointsF, types, count, fillMode);
  315. if (CheckValid(*path))
  316. {
  317. return Ok;
  318. }
  319. else
  320. return OutOfMemory;
  321. }
  322. GpStatus
  323. WINGDIPAPI
  324. GdipClonePath(
  325. GpPath* path,
  326. GpPath** clonepath
  327. )
  328. {
  329. API_ENTRY(GdipClonePath);
  330. CheckParameter(clonepath);
  331. CheckParameterValid(path);
  332. CheckObjectBusy(path);
  333. *clonepath = path->Clone();
  334. if (*clonepath)
  335. {
  336. // Make sure we tag this allocation as an API allocation
  337. GpTagMalloc(*clonepath, GpPathTag, TRUE);
  338. return Ok;
  339. }
  340. else
  341. return OutOfMemory;
  342. }
  343. GpStatus
  344. WINGDIPAPI
  345. GdipDeletePath(
  346. GpPath* path
  347. )
  348. {
  349. API_ENTRY(GdipDeletePath);
  350. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  351. // the object, even if it's not in a valid state.
  352. CheckParameter(path);
  353. CheckObjectBusyForDelete(path);
  354. path = (GpPath *) InterlockedExchangePointer((PVOID *) &Globals::PathLookAside, path);
  355. if(path != NULL)
  356. {
  357. delete path;
  358. }
  359. return Ok;
  360. }
  361. GpStatus
  362. WINGDIPAPI
  363. GdipResetPath(
  364. GpPath* path
  365. )
  366. {
  367. API_ENTRY(GdipResetPath);
  368. CheckParameterValid(path);
  369. CheckObjectBusy(path);
  370. return path->Reset();
  371. }
  372. GpStatus
  373. WINGDIPAPI
  374. GdipGetPointCount(
  375. GpPath* path,
  376. INT *count
  377. )
  378. {
  379. API_ENTRY(GdipGetPointCount);
  380. CheckParameter(count);
  381. CheckParameterValid(path);
  382. CheckObjectBusy(path);
  383. *count = path->GetPointCount();
  384. return Ok;
  385. }
  386. GpStatus
  387. WINGDIPAPI
  388. GdipGetPathTypes(
  389. GpPath* path,
  390. BYTE* types,
  391. INT count
  392. )
  393. {
  394. API_ENTRY(GdipGetPathTypes);
  395. CheckParameter(types && count > 0);
  396. CheckParameterValid(path);
  397. CheckObjectBusy(path);
  398. INT pathCount;
  399. pathCount = path->GetPointCount();
  400. if (pathCount > count)
  401. return InsufficientBuffer;
  402. if (pathCount < 0)
  403. return GenericError;
  404. GpMemcpy(types, path->GetPathTypes(), pathCount);
  405. return Ok;
  406. }
  407. GpStatus
  408. WINGDIPAPI
  409. GdipGetPathPoints(
  410. GpPath* path,
  411. GpPointF* points,
  412. INT count
  413. )
  414. {
  415. API_ENTRY(GdipGetPathPoints);
  416. // NOTE: Race condition between GetPointCount() & GetPathPoints()
  417. // we need a manually invokable lock here.
  418. CheckParameter(points && count > 0);
  419. CheckParameterValid(path);
  420. CheckObjectBusy(path);
  421. INT pathCount;
  422. pathCount = path->GetPointCount();
  423. if (pathCount > count)
  424. return InsufficientBuffer;
  425. if (pathCount < 0)
  426. return GenericError;
  427. GpMemcpy(points, path->GetPathPoints(), pathCount*sizeof(GpPointF));
  428. return Ok;
  429. }
  430. GpStatus
  431. WINGDIPAPI
  432. GdipGetPathPointsI(
  433. GpPath* path,
  434. GpPoint* points,
  435. INT count
  436. )
  437. {
  438. API_ENTRY(GdipGetPathPointsI);
  439. // NOTE: Race condition between GetPointCount() & GetPathPoints()
  440. // we need a manually invokable lock here.
  441. CheckParameter(points && count > 0);
  442. CheckParameterValid(path);
  443. CheckObjectBusy(path);
  444. INT pathCount;
  445. pathCount = path->GetPointCount();
  446. if (pathCount > count)
  447. return InsufficientBuffer;
  448. if (pathCount < 0)
  449. return GenericError;
  450. GDIPCONST GpPointF *pointsF = path->GetPathPoints();
  451. for (INT i=0; i<count; i++)
  452. {
  453. points[i].X = GpRound(pointsF[i].X);
  454. points[i].Y = GpRound(pointsF[i].Y);
  455. }
  456. return Ok;
  457. }
  458. GpStatus
  459. WINGDIPAPI
  460. GdipGetPathFillMode(
  461. GpPath *path,
  462. GpFillMode *fillmode
  463. )
  464. {
  465. API_ENTRY(GdipGetPathFillMode);
  466. CheckParameter(fillmode);
  467. CheckParameterValid(path);
  468. CheckObjectBusy(path);
  469. *fillmode = (GpFillMode)path->GetFillMode();
  470. return Ok;
  471. }
  472. GpStatus
  473. WINGDIPAPI
  474. GdipSetPathFillMode(
  475. GpPath *path,
  476. GpFillMode fillmode
  477. )
  478. {
  479. API_ENTRY(GdipSetPathFillMode);
  480. CheckParameterValid(path);
  481. CheckObjectBusy(path);
  482. path->SetFillMode(fillmode);
  483. return Ok;
  484. }
  485. GpStatus
  486. WINGDIPAPI
  487. GdipSetPathData(
  488. GpPath *path,
  489. GpPathData* pathData
  490. )
  491. {
  492. API_ENTRY(GdipSetPathData);
  493. CheckParameterValid(path);
  494. CheckObjectBusy(path);
  495. return path->SetPathData(pathData);
  496. }
  497. GpStatus
  498. WINGDIPAPI
  499. GdipGetPathData(
  500. GpPath *path,
  501. GpPathData* pathData
  502. )
  503. {
  504. API_ENTRY(GdipGetPathData);
  505. CheckParameterValid(path);
  506. CheckObjectBusy(path);
  507. return path->GetPathData(pathData);
  508. }
  509. GpStatus
  510. WINGDIPAPI
  511. GdipStartPathFigure(
  512. GpPath *path
  513. )
  514. {
  515. API_ENTRY(GdipStartPathFigure);
  516. CheckParameterValid(path);
  517. CheckObjectBusy(path);
  518. path->StartFigure();
  519. return Ok;
  520. }
  521. GpStatus
  522. WINGDIPAPI
  523. GdipClosePathFigure(
  524. GpPath *path
  525. )
  526. {
  527. API_ENTRY(GdipClosePathFigure);
  528. CheckParameterValid(path);
  529. CheckObjectBusy(path);
  530. return path->CloseFigure();
  531. }
  532. GpStatus
  533. WINGDIPAPI
  534. GdipClosePathFigures(
  535. GpPath *path
  536. )
  537. {
  538. API_ENTRY(GdipClosePathFigures);
  539. CheckParameterValid(path);
  540. CheckObjectBusy(path);
  541. return path->CloseFigures();
  542. }
  543. GpStatus
  544. WINGDIPAPI
  545. GdipSetPathMarker(
  546. GpPath *path
  547. )
  548. {
  549. API_ENTRY(GdipSetPathMarker);
  550. CheckParameterValid(path);
  551. CheckObjectBusy(path);
  552. return path->SetMarker();
  553. }
  554. GpStatus
  555. WINGDIPAPI
  556. GdipClearPathMarkers(
  557. GpPath *path
  558. )
  559. {
  560. API_ENTRY(GdipClearPathMarkers);
  561. CheckParameterValid(path);
  562. CheckObjectBusy(path);
  563. return path->ClearMarkers();
  564. }
  565. GpStatus
  566. WINGDIPAPI
  567. GdipReversePath(
  568. GpPath* path
  569. )
  570. {
  571. API_ENTRY(GdipReversePath);
  572. CheckParameterValid(path);
  573. CheckObjectBusy(path);
  574. return path->Reverse();
  575. }
  576. GpStatus
  577. WINGDIPAPI
  578. GdipGetPathLastPoint(
  579. GpPath* path,
  580. GpPointF* lastPoint
  581. )
  582. {
  583. API_ENTRY(GdipGetPathLastPoint);
  584. CheckParameter(lastPoint);
  585. CheckParameterValid(path);
  586. CheckObjectBusy(path);
  587. return path->GetLastPoint(lastPoint);
  588. }
  589. GpStatus
  590. WINGDIPAPI
  591. GdipAddPathLine(
  592. GpPath *path,
  593. REAL x1,
  594. REAL y1,
  595. REAL x2,
  596. REAL y2
  597. )
  598. {
  599. API_ENTRY(GdipAddPathLine);
  600. CheckParameterValid(path);
  601. CheckObjectBusy(path);
  602. return path->AddLine(x1, y1, x2, y2);
  603. }
  604. GpStatus
  605. WINGDIPAPI
  606. GdipAddPathLineI(
  607. GpPath *path,
  608. INT x1,
  609. INT y1,
  610. INT x2,
  611. INT y2
  612. )
  613. {
  614. API_ENTRY(GdipAddPathLineI);
  615. return GdipAddPathLine(path, TOREAL(x1), TOREAL(y1), TOREAL(x2), TOREAL(y2));
  616. }
  617. GpStatus
  618. WINGDIPAPI
  619. GdipAddPathLine2(
  620. GpPath *path,
  621. GDIPCONST GpPointF *points,
  622. INT count)
  623. {
  624. API_ENTRY(GdipAddPathLine2);
  625. CheckParameter(points && count > 0);
  626. CheckParameterValid(path);
  627. CheckObjectBusy(path);
  628. return path->AddLines(points, count);
  629. }
  630. GpStatus
  631. WINGDIPAPI
  632. GdipAddPathLine2I(
  633. GpPath *path,
  634. GDIPCONST GpPoint *points,
  635. INT count)
  636. {
  637. API_ENTRY(GdipAddPathLine2I);
  638. StackBuffer buffer;
  639. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  640. if(!pointsF) return OutOfMemory;
  641. for (INT i=0; i<count; i++)
  642. {
  643. pointsF[i].X = TOREAL(points[i].X);
  644. pointsF[i].Y = TOREAL(points[i].Y);
  645. }
  646. GpStatus status = GdipAddPathLine2(path, pointsF, count);
  647. return status;
  648. }
  649. GpStatus
  650. WINGDIPAPI
  651. GdipAddPathArc(
  652. GpPath *path,
  653. REAL x,
  654. REAL y,
  655. REAL width,
  656. REAL height,
  657. REAL startAngle,
  658. REAL sweepAngle
  659. )
  660. {
  661. API_ENTRY(GdipAddPathArc);
  662. CheckParameterValid(path);
  663. CheckObjectBusy(path);
  664. return path->AddArc(
  665. x,
  666. y,
  667. width,
  668. height,
  669. startAngle,
  670. sweepAngle
  671. );
  672. }
  673. GpStatus
  674. WINGDIPAPI
  675. GdipAddPathArcI(
  676. GpPath *path,
  677. INT x,
  678. INT y,
  679. INT width,
  680. INT height,
  681. REAL startAngle,
  682. REAL sweepAngle
  683. )
  684. {
  685. API_ENTRY(GdipAddPathArcI);
  686. return GdipAddPathArc(path,
  687. TOREAL(x),
  688. TOREAL(y),
  689. TOREAL(width),
  690. TOREAL(height),
  691. startAngle,
  692. sweepAngle);
  693. }
  694. GpStatus
  695. WINGDIPAPI
  696. GdipAddPathBezier(
  697. GpPath *path,
  698. REAL x1,
  699. REAL y1,
  700. REAL x2,
  701. REAL y2,
  702. REAL x3,
  703. REAL y3,
  704. REAL x4,
  705. REAL y4
  706. )
  707. {
  708. API_ENTRY(GdipAddPathBezier);
  709. CheckParameterValid(path);
  710. CheckObjectBusy(path);
  711. return path->AddBezier(x1,
  712. y1,
  713. x2,
  714. y2,
  715. x3,
  716. y3,
  717. x4,
  718. y4);
  719. }
  720. GpStatus
  721. WINGDIPAPI
  722. GdipAddPathBezierI(
  723. GpPath *path,
  724. INT x1,
  725. INT y1,
  726. INT x2,
  727. INT y2,
  728. INT x3,
  729. INT y3,
  730. INT x4,
  731. INT y4
  732. )
  733. {
  734. API_ENTRY(GdipAddPathBezierI);
  735. return GdipAddPathBezier(path,
  736. TOREAL(x1),
  737. TOREAL(y1),
  738. TOREAL(x2),
  739. TOREAL(y2),
  740. TOREAL(x3),
  741. TOREAL(y3),
  742. TOREAL(x4),
  743. TOREAL(y4));
  744. }
  745. GpStatus
  746. WINGDIPAPI
  747. GdipAddPathBeziers(
  748. GpPath *path,
  749. GDIPCONST GpPointF *points,
  750. INT count
  751. )
  752. {
  753. API_ENTRY(GdipAddPathBeziers);
  754. CheckParameter(points && count > 0);
  755. CheckParameterValid(path);
  756. CheckObjectBusy(path);
  757. return path->AddBeziers(points, count);
  758. }
  759. GpStatus
  760. WINGDIPAPI
  761. GdipAddPathBeziersI(
  762. GpPath *path,
  763. GDIPCONST GpPoint *points,
  764. INT count
  765. )
  766. {
  767. API_ENTRY(GdipAddPathBeziersI);
  768. StackBuffer buffer;
  769. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  770. if(!pointsF) return OutOfMemory;
  771. for (INT i=0; i<count; i++)
  772. {
  773. pointsF[i].X = TOREAL(points[i].X);
  774. pointsF[i].Y = TOREAL(points[i].Y);
  775. }
  776. GpStatus status = GdipAddPathBeziers(path, pointsF, count);
  777. return status;
  778. }
  779. GpStatus
  780. WINGDIPAPI
  781. GdipAddPathCurve(
  782. GpPath *path,
  783. GDIPCONST GpPointF *points,
  784. INT count
  785. )
  786. {
  787. API_ENTRY(GdipAddPathCurve);
  788. CheckParameter(points && count > 0);
  789. CheckParameterValid(path);
  790. CheckObjectBusy(path);
  791. return path->AddCurve(points, count);
  792. }
  793. GpStatus
  794. WINGDIPAPI
  795. GdipAddPathCurveI(
  796. GpPath *path,
  797. GDIPCONST GpPoint *points,
  798. INT count
  799. )
  800. {
  801. API_ENTRY(GdipAddPathCurveI);
  802. CheckParameter(points && count > 0);
  803. StackBuffer buffer;
  804. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  805. if(!pointsF) return OutOfMemory;
  806. for (INT i=0; i<count; i++)
  807. {
  808. pointsF[i].X = TOREAL(points[i].X);
  809. pointsF[i].Y = TOREAL(points[i].Y);
  810. }
  811. GpStatus status = GdipAddPathCurve(path, pointsF, count);
  812. return status;
  813. }
  814. GpStatus
  815. WINGDIPAPI
  816. GdipAddPathCurve2(
  817. GpPath *path,
  818. GDIPCONST GpPointF *points,
  819. INT count,
  820. REAL tension
  821. )
  822. {
  823. API_ENTRY(GdipAddPathCurve2);
  824. CheckParameter(points && count > 0);
  825. CheckParameterValid(path);
  826. CheckObjectBusy(path);
  827. INT offset = 0;
  828. INT numOfSegments = count - 1;
  829. return path->AddCurve(points, count, tension, offset, numOfSegments);
  830. }
  831. GpStatus
  832. WINGDIPAPI
  833. GdipAddPathCurve2I(
  834. GpPath *path,
  835. GDIPCONST GpPoint *points,
  836. INT count,
  837. REAL tension
  838. )
  839. {
  840. API_ENTRY(GdipAddPathCurve2I);
  841. CheckParameter(points && count > 0);
  842. StackBuffer buffer;
  843. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  844. if(!pointsF) return OutOfMemory;
  845. for (INT i=0; i<count; i++)
  846. {
  847. pointsF[i].X = TOREAL(points[i].X);
  848. pointsF[i].Y = TOREAL(points[i].Y);
  849. }
  850. GpStatus status = GdipAddPathCurve2(path, pointsF, count, tension);
  851. return status;
  852. }
  853. GpStatus
  854. WINGDIPAPI
  855. GdipAddPathCurve3(
  856. GpPath *path,
  857. GDIPCONST GpPointF *points,
  858. INT count,
  859. INT offset,
  860. INT numberOfSegments,
  861. REAL tension
  862. )
  863. {
  864. API_ENTRY(GdipAddPathCurve3);
  865. CheckParameter(points && count > 0);
  866. CheckParameterValid(path);
  867. CheckObjectBusy(path);
  868. return path->AddCurve(points, count, tension, offset, numberOfSegments);
  869. }
  870. GpStatus
  871. WINGDIPAPI
  872. GdipAddPathCurve3I(
  873. GpPath *path,
  874. GDIPCONST GpPoint *points,
  875. INT count,
  876. INT offset,
  877. INT numberOfSegments,
  878. REAL tension
  879. )
  880. {
  881. API_ENTRY(GdipAddPathCurve3I);
  882. StackBuffer buffer;
  883. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  884. if(!pointsF) return OutOfMemory;
  885. for (INT i=0; i<count; i++)
  886. {
  887. pointsF[i].X = TOREAL(points[i].X);
  888. pointsF[i].Y = TOREAL(points[i].Y);
  889. }
  890. GpStatus status = GdipAddPathCurve3(path, pointsF, count, offset, numberOfSegments, tension);
  891. return status;
  892. }
  893. GpStatus
  894. WINGDIPAPI
  895. GdipAddPathClosedCurve(
  896. GpPath *path,
  897. GDIPCONST GpPointF *points,
  898. INT count
  899. )
  900. {
  901. API_ENTRY(GdipAddPathClosedCurve);
  902. CheckParameter(points && count > 0);
  903. CheckParameterValid(path);
  904. CheckObjectBusy(path);
  905. return path->AddClosedCurve(points, count);
  906. }
  907. GpStatus
  908. WINGDIPAPI
  909. GdipAddPathClosedCurveI(
  910. GpPath *path,
  911. GDIPCONST GpPoint *points,
  912. INT count
  913. )
  914. {
  915. API_ENTRY(GdipAddPathClosedCurveI);
  916. StackBuffer buffer;
  917. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  918. if(!pointsF) return OutOfMemory;
  919. for (INT i=0; i<count; i++)
  920. {
  921. pointsF[i].X = TOREAL(points[i].X);
  922. pointsF[i].Y = TOREAL(points[i].Y);
  923. }
  924. GpStatus status = GdipAddPathClosedCurve(path, pointsF, count);
  925. return status;
  926. }
  927. GpStatus
  928. WINGDIPAPI
  929. GdipAddPathClosedCurve2(
  930. GpPath *path,
  931. GDIPCONST GpPointF *points,
  932. INT count,
  933. REAL tension
  934. )
  935. {
  936. API_ENTRY(GdipAddPathClosedCurve2);
  937. CheckParameter(points && count > 0);
  938. CheckParameterValid(path);
  939. CheckObjectBusy(path);
  940. return path->AddClosedCurve(points, count, tension);
  941. }
  942. GpStatus
  943. WINGDIPAPI
  944. GdipAddPathClosedCurve2I(
  945. GpPath *path,
  946. GDIPCONST GpPoint *points,
  947. INT count,
  948. REAL tension
  949. )
  950. {
  951. API_ENTRY(GdipAddPathClosedCurve2I);
  952. StackBuffer buffer;
  953. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  954. if(!pointsF) return OutOfMemory;
  955. for (INT i=0; i<count; i++)
  956. {
  957. pointsF[i].X = TOREAL(points[i].X);
  958. pointsF[i].Y = TOREAL(points[i].Y);
  959. }
  960. GpStatus status = GdipAddPathClosedCurve2(path, pointsF, count, tension);
  961. return status;
  962. }
  963. GpStatus
  964. WINGDIPAPI
  965. GdipAddPathRectangle(
  966. GpPath *path,
  967. REAL x,
  968. REAL y,
  969. REAL width,
  970. REAL height
  971. )
  972. {
  973. API_ENTRY(GdipAddPathRectangle);
  974. CheckParameterValid(path);
  975. CheckObjectBusy(path);
  976. GpRectF rect(x, y, width, height);
  977. return path->AddRect(rect);
  978. }
  979. GpStatus
  980. WINGDIPAPI
  981. GdipAddPathRectangleI(
  982. GpPath *path,
  983. INT x,
  984. INT y,
  985. INT width,
  986. INT height
  987. )
  988. {
  989. API_ENTRY(GdipAddPathRectangleI);
  990. return GdipAddPathRectangle(path, TOREAL(x), TOREAL(y), TOREAL(width), TOREAL(height));
  991. }
  992. GpStatus
  993. WINGDIPAPI
  994. GdipAddPathRectangles(
  995. GpPath *path,
  996. GDIPCONST GpRectF *rects,
  997. INT count
  998. )
  999. {
  1000. API_ENTRY(GdipAddPathRectangles);
  1001. CheckParameter(rects && count > 0);
  1002. CheckParameterValid(path);
  1003. CheckObjectBusy(path);
  1004. return path->AddRects(rects, count);
  1005. }
  1006. GpStatus
  1007. WINGDIPAPI
  1008. GdipAddPathRectanglesI(
  1009. GpPath *path,
  1010. GDIPCONST GpRect *rects,
  1011. INT count
  1012. )
  1013. {
  1014. API_ENTRY(GdipAddPathRectanglesI);
  1015. StackBuffer buffer;
  1016. GpRectF *rectsF = (GpRectF*) buffer.GetBuffer(count*sizeof(GpRectF));
  1017. if(!rectsF) return OutOfMemory;
  1018. for (INT i=0; i<count; i++)
  1019. {
  1020. rectsF[i].X = TOREAL(rects[i].X);
  1021. rectsF[i].Y = TOREAL(rects[i].Y);
  1022. rectsF[i].Width = TOREAL(rects[i].Width);
  1023. rectsF[i].Height = TOREAL(rects[i].Height);
  1024. }
  1025. GpStatus status = GdipAddPathRectangles(path, rectsF, count);
  1026. return status;
  1027. }
  1028. GpStatus
  1029. WINGDIPAPI
  1030. GdipAddPathEllipse(
  1031. GpPath* path,
  1032. REAL x,
  1033. REAL y,
  1034. REAL width,
  1035. REAL height
  1036. )
  1037. {
  1038. API_ENTRY(GdipAddPathEllipse);
  1039. // Idea: What about just putting "GpRectF rect" as the parameter,
  1040. // no copying, the stack image should match the structure
  1041. // avoiding an additional copy.
  1042. CheckParameterValid(path);
  1043. CheckObjectBusy(path);
  1044. GpRectF rect(x, y, width, height);
  1045. return path->AddEllipse(rect);
  1046. }
  1047. GpStatus
  1048. WINGDIPAPI
  1049. GdipAddPathEllipseI(
  1050. GpPath* path,
  1051. INT x,
  1052. INT y,
  1053. INT width,
  1054. INT height
  1055. )
  1056. {
  1057. API_ENTRY(GdipAddPathEllipseI);
  1058. return GdipAddPathEllipse(path, TOREAL(x), TOREAL(y), TOREAL(width), TOREAL(height));
  1059. }
  1060. GpStatus
  1061. WINGDIPAPI
  1062. GdipAddPathPie(
  1063. GpPath *path,
  1064. REAL x,
  1065. REAL y,
  1066. REAL width,
  1067. REAL height,
  1068. REAL startAngle,
  1069. REAL sweepAngle
  1070. )
  1071. {
  1072. API_ENTRY(GdipAddPathPie);
  1073. CheckParameterValid(path);
  1074. CheckObjectBusy(path);
  1075. return path->AddPie(x, y, width, height, startAngle, sweepAngle);
  1076. }
  1077. GpStatus
  1078. WINGDIPAPI
  1079. GdipAddPathPieI(
  1080. GpPath *path,
  1081. INT x,
  1082. INT y,
  1083. INT width,
  1084. INT height,
  1085. REAL startAngle,
  1086. REAL sweepAngle
  1087. )
  1088. {
  1089. API_ENTRY(GdipAddPathPieI);
  1090. return GdipAddPathPie(path,
  1091. TOREAL(x),
  1092. TOREAL(y),
  1093. TOREAL(width),
  1094. TOREAL(height),
  1095. startAngle,
  1096. sweepAngle);
  1097. }
  1098. GpStatus
  1099. WINGDIPAPI
  1100. GdipAddPathPolygon(
  1101. GpPath *path,
  1102. GDIPCONST GpPointF *points,
  1103. INT count
  1104. )
  1105. {
  1106. API_ENTRY(GdipAddPathPolygon);
  1107. CheckParameter(points && count > 0);
  1108. CheckParameterValid(path);
  1109. CheckObjectBusy(path);
  1110. return path->AddPolygon(points, count);
  1111. }
  1112. GpStatus
  1113. WINGDIPAPI
  1114. GdipAddPathPolygonI(
  1115. GpPath *path,
  1116. GDIPCONST GpPoint *points,
  1117. INT count
  1118. )
  1119. {
  1120. API_ENTRY(GdipAddPathPolygonI);
  1121. StackBuffer buffer;
  1122. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  1123. if(!pointsF) return OutOfMemory;
  1124. for (INT i=0; i<count; i++)
  1125. {
  1126. pointsF[i].X = TOREAL(points[i].X);
  1127. pointsF[i].Y = TOREAL(points[i].Y);
  1128. }
  1129. GpStatus status = GdipAddPathPolygon(path, pointsF, count);
  1130. return status;
  1131. }
  1132. GpStatus
  1133. WINGDIPAPI
  1134. GdipAddPathPath(
  1135. GpPath *path,
  1136. GDIPCONST GpPath* addingPath,
  1137. BOOL connect
  1138. )
  1139. {
  1140. API_ENTRY(GdipAddPathPath);
  1141. CheckParameterValid(path);
  1142. CheckObjectBusy(path);
  1143. return path->AddPath(addingPath, connect);
  1144. }
  1145. static inline
  1146. EmptyString(const WCHAR * string, INT length)
  1147. {
  1148. return (length == 0 || length == -1 && string[0] == 0);
  1149. }
  1150. static inline
  1151. void SetEmptyRectF(RectF * boundingBox)
  1152. {
  1153. boundingBox->X = boundingBox->Y = boundingBox->Width = boundingBox->Height = 0.0;
  1154. }
  1155. GpStatus
  1156. WINGDIPAPI
  1157. GdipAddPathString(
  1158. GpPath *path,
  1159. GDIPCONST WCHAR *string,
  1160. INT length,
  1161. GDIPCONST GpFontFamily *family,
  1162. INT style,
  1163. REAL emSize,
  1164. GDIPCONST RectF *layoutRect,
  1165. GDIPCONST GpStringFormat *format
  1166. )
  1167. {
  1168. API_ENTRY(GdipAddPathString);
  1169. CheckParameter(string && layoutRect);
  1170. CheckParameterValid(path);
  1171. CheckObjectBusy(path);
  1172. if (EmptyString(string, length))
  1173. {
  1174. return Ok;
  1175. }
  1176. GlobalTextLock lock;
  1177. CheckParameterValid(family);
  1178. CheckOptionalParameterValid(format);
  1179. return path->AddString(
  1180. string,
  1181. length,
  1182. family,
  1183. style,
  1184. emSize,
  1185. layoutRect,
  1186. format
  1187. );
  1188. }
  1189. GpStatus
  1190. WINGDIPAPI
  1191. GdipAddPathStringI(
  1192. GpPath *path,
  1193. GDIPCONST WCHAR *string,
  1194. INT length,
  1195. GDIPCONST GpFontFamily *family,
  1196. INT style,
  1197. REAL emSize,
  1198. GDIPCONST Rect *layoutRect,
  1199. GDIPCONST GpStringFormat *format
  1200. )
  1201. {
  1202. API_ENTRY(GdipAddPathStringI);
  1203. CheckParameter(layoutRect);
  1204. // Not necessary to check all paramaters - they are validated
  1205. // in the called function.
  1206. GpRectF rectf(TOREAL(layoutRect->X), TOREAL(layoutRect->Y),
  1207. TOREAL(layoutRect->Width), TOREAL(layoutRect->Height));
  1208. return GdipAddPathString(path, string, length, family, style, emSize,
  1209. &rectf, format);
  1210. }
  1211. GpStatus
  1212. WINGDIPAPI
  1213. GdipFlattenPath(
  1214. GpPath *path,
  1215. GpMatrix* matrix,
  1216. REAL flatness
  1217. )
  1218. {
  1219. API_ENTRY(GdipFlattenPath);
  1220. CheckParameterValid(path);
  1221. CheckObjectBusy(path);
  1222. CheckOptionalParameterValid(matrix);
  1223. CheckOptionalObjectBusy(matrix);
  1224. return path->Flatten(matrix, flatness);
  1225. }
  1226. GpStatus WINGDIPAPI
  1227. GdipWindingModeOutline(
  1228. GpPath *path,
  1229. GpMatrix *matrix,
  1230. REAL flatness
  1231. )
  1232. {
  1233. API_ENTRY(GdipWindingModeOutline);
  1234. CheckParameterValid(path);
  1235. CheckObjectBusy(path);
  1236. CheckOptionalParameterValid(matrix);
  1237. CheckOptionalObjectBusy(matrix);
  1238. return path->ComputeWindingModeOutline(matrix, flatness);
  1239. }
  1240. GpStatus
  1241. WINGDIPAPI
  1242. GdipWidenPath(
  1243. GpPath *path,
  1244. GpPen *pen,
  1245. GpMatrix *matrix,
  1246. REAL flatness
  1247. )
  1248. {
  1249. API_ENTRY(GdipWidenPath);
  1250. CheckParameterValid(path);
  1251. CheckParameterValid(pen);
  1252. CheckObjectBusy(path);
  1253. CheckObjectBusy(pen);
  1254. CheckOptionalParameterValid(matrix);
  1255. CheckOptionalObjectBusy(matrix);
  1256. return path->Widen(pen, matrix, flatness);
  1257. }
  1258. GpStatus
  1259. WINGDIPAPI
  1260. GdipWarpPath(
  1261. GpPath *path,
  1262. GpMatrix* matrix,
  1263. GDIPCONST GpPointF *points,
  1264. INT count,
  1265. REAL srcx,
  1266. REAL srcy,
  1267. REAL srcwidth,
  1268. REAL srcheight,
  1269. WarpMode warpMode,
  1270. REAL flatness
  1271. )
  1272. {
  1273. API_ENTRY(GdipWarpPath);
  1274. CheckParameterValid(path);
  1275. CheckObjectBusy(path);
  1276. CheckParameter(points && count > 0);
  1277. CheckOptionalParameterValid(matrix);
  1278. CheckOptionalObjectBusy(matrix);
  1279. GpRectF srcRect(srcx, srcy, srcwidth, srcheight);
  1280. // The flatness parameter is not implemented yet.
  1281. return path->WarpAndFlattenSelf(matrix, points, count, srcRect, warpMode);
  1282. }
  1283. GpStatus
  1284. WINGDIPAPI
  1285. GdipTransformPath(
  1286. GpPath *path,
  1287. GpMatrix *matrix
  1288. )
  1289. {
  1290. API_ENTRY(GdipTransformPath);
  1291. if(matrix == NULL)
  1292. return Ok; // No need to transform.
  1293. CheckParameterValid(path);
  1294. CheckParameterValid(matrix);
  1295. CheckObjectBusy(path);
  1296. CheckObjectBusy(matrix);
  1297. path->Transform(matrix);
  1298. return Ok;
  1299. }
  1300. GpStatus
  1301. WINGDIPAPI
  1302. GdipGetPathWorldBounds(
  1303. GpPath* path,
  1304. GpRectF* bounds,
  1305. GDIPCONST GpMatrix *matrix,
  1306. GDIPCONST GpPen *pen
  1307. )
  1308. {
  1309. API_ENTRY(GdipGetPathWorldBounds);
  1310. CheckParameterValid(path);
  1311. CheckObjectBusy(path);
  1312. CheckParameter(bounds);
  1313. CheckOptionalParameterValid(pen);
  1314. CheckOptionalParameterValid(matrix);
  1315. CheckOptionalObjectBusy(pen);
  1316. CheckOptionalObjectBusy(matrix);
  1317. // matrix and pen can be NULL.
  1318. // So don't use CheckParameter for matrix and pen.
  1319. GpStatus status = Ok;
  1320. if(pen == NULL)
  1321. status = path->GetBounds(bounds, const_cast<GpMatrix*>(matrix));
  1322. else
  1323. status = path->GetBounds(bounds,
  1324. const_cast<GpMatrix*>(matrix),
  1325. const_cast<GpPen*>(pen)->GetDevicePen());
  1326. return status;
  1327. }
  1328. GpStatus
  1329. WINGDIPAPI
  1330. GdipGetPathWorldBoundsI(
  1331. GpPath* path,
  1332. GpRect* bounds,
  1333. GDIPCONST GpMatrix *matrix,
  1334. GDIPCONST GpPen *pen)
  1335. {
  1336. API_ENTRY(GdipGetPathWorldBoundsI);
  1337. CheckParameterValid(path);
  1338. CheckObjectBusy(path);
  1339. CheckParameter(bounds);
  1340. CheckOptionalParameterValid(pen);
  1341. CheckOptionalParameterValid(matrix);
  1342. CheckOptionalObjectBusy(pen);
  1343. CheckOptionalObjectBusy(matrix);
  1344. // matrix and pen can be NULL.
  1345. // So don't use CheckParameter for matrix and pen.
  1346. GpStatus status = Ok;
  1347. if(pen == NULL)
  1348. status = path->GetBounds(bounds, const_cast<GpMatrix*>(matrix));
  1349. else
  1350. status = path->GetBounds(bounds,
  1351. const_cast<GpMatrix*>(matrix),
  1352. const_cast<GpPen*>(pen)->GetDevicePen());
  1353. return status;
  1354. }
  1355. GpStatus
  1356. WINGDIPAPI
  1357. GdipIsVisiblePathPoint(
  1358. GpPath* path,
  1359. REAL x,
  1360. REAL y,
  1361. GpGraphics *graphics,
  1362. BOOL *result
  1363. )
  1364. {
  1365. API_ENTRY(GdipIsVisiblePathPoint);
  1366. CheckParameter(result);
  1367. CheckParameterValid(path);
  1368. CheckObjectBusy(path);
  1369. GpPointF pt(x, y);
  1370. GpMatrix worldToDevice;
  1371. Status status = Ok;
  1372. if(graphics)
  1373. {
  1374. CheckParameterValid(graphics);
  1375. CheckObjectBusy(graphics);
  1376. graphics->GetWorldToDeviceTransform(&worldToDevice);
  1377. status = path->IsVisible(&pt, result, &worldToDevice);
  1378. }
  1379. else
  1380. status = path->IsVisible(&pt, result); // Use the default.
  1381. return status;
  1382. }
  1383. GpStatus
  1384. WINGDIPAPI
  1385. GdipIsVisiblePathPointI(
  1386. GpPath* path,
  1387. INT x,
  1388. INT y,
  1389. GpGraphics *graphics,
  1390. BOOL *result
  1391. )
  1392. {
  1393. API_ENTRY(GdipIsVisiblePathPointI);
  1394. return GdipIsVisiblePathPoint(path,
  1395. TOREAL(x),
  1396. TOREAL(y),
  1397. graphics,
  1398. result);
  1399. }
  1400. GpStatus
  1401. WINGDIPAPI
  1402. GdipIsOutlineVisiblePathPoint(
  1403. GpPath* path,
  1404. REAL x,
  1405. REAL y,
  1406. GpPen *pen,
  1407. GpGraphics *graphics,
  1408. BOOL *result
  1409. )
  1410. {
  1411. API_ENTRY(GdipIsOutlineVisiblePathPoint);
  1412. CheckParameter(result);
  1413. CheckParameterValid(path);
  1414. CheckObjectBusy(path);
  1415. CheckParameterValid(pen);
  1416. CheckObjectBusy(pen);
  1417. GpPointF pt(x, y);
  1418. GpMatrix worldToDevice;
  1419. Status status = Ok;
  1420. if(graphics)
  1421. {
  1422. CheckParameterValid(graphics);
  1423. CheckObjectBusy(graphics);
  1424. graphics->GetWorldToDeviceTransform(&worldToDevice);
  1425. REAL dpiX = graphics->GetDpiX();
  1426. REAL dpiY = graphics->GetDpiY();
  1427. status = path->IsOutlineVisible(&pt, result, pen,
  1428. &worldToDevice, dpiX, dpiY);
  1429. }
  1430. else
  1431. status = path->IsOutlineVisible(&pt, result, pen); // Use the default.
  1432. return status;
  1433. }
  1434. GpStatus
  1435. WINGDIPAPI
  1436. GdipIsOutlineVisiblePathPointI(
  1437. GpPath* path,
  1438. INT x,
  1439. INT y,
  1440. GpPen *pen,
  1441. GpGraphics *graphics,
  1442. BOOL *result
  1443. )
  1444. {
  1445. API_ENTRY(GdipIsOutlineVisiblePathPointI);
  1446. return GdipIsOutlineVisiblePathPoint(path,
  1447. TOREAL(x),
  1448. TOREAL(y),
  1449. pen,
  1450. graphics,
  1451. result);
  1452. }
  1453. GpStatus WINGDIPAPI
  1454. GdipCreatePathIter(
  1455. GpPathIterator **iterator,
  1456. GpPath* path
  1457. )
  1458. {
  1459. API_ENTRY(GdipCreatePathIter);
  1460. CheckGdiplusInitialized; // We do this in all our object creation API's
  1461. CheckParameter(iterator);
  1462. *iterator = new GpPathIterator(path);
  1463. if (CheckValid(*iterator))
  1464. return Ok;
  1465. else
  1466. return OutOfMemory;
  1467. }
  1468. GpStatus
  1469. WINGDIPAPI
  1470. GdipDeletePathIter(
  1471. GpPathIterator *iterator
  1472. )
  1473. {
  1474. API_ENTRY(GdipDeletePathIter);
  1475. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  1476. // the object, even if it's not in a valid state.
  1477. CheckParameter(iterator);
  1478. CheckObjectBusyForDelete(iterator);
  1479. delete iterator;
  1480. return Ok;
  1481. }
  1482. GpStatus WINGDIPAPI
  1483. GdipPathIterNextSubpath(
  1484. GpPathIterator* iterator,
  1485. INT* resultCount,
  1486. INT* startIndex,
  1487. INT* endIndex,
  1488. BOOL* isClosed)
  1489. {
  1490. API_ENTRY(GdipPathIterNextSubpath);
  1491. CheckParameterValid(iterator);
  1492. CheckObjectBusy(iterator);
  1493. CheckParameter(resultCount);
  1494. CheckParameter(startIndex);
  1495. CheckParameter(endIndex);
  1496. CheckParameter(isClosed);
  1497. *resultCount = iterator->NextSubpath(startIndex, endIndex, isClosed);
  1498. return Ok;
  1499. }
  1500. GpStatus WINGDIPAPI
  1501. GdipPathIterNextSubpathPath(
  1502. GpPathIterator* iterator,
  1503. INT* resultCount,
  1504. GpPath* path,
  1505. BOOL* isClosed)
  1506. {
  1507. API_ENTRY(GdipPathIterNextSubpathPath);
  1508. CheckParameterValid(iterator);
  1509. CheckObjectBusy(iterator);
  1510. CheckParameter(resultCount);
  1511. CheckParameter(isClosed);
  1512. *resultCount = iterator->NextSubpath(path, isClosed);
  1513. return Ok;
  1514. }
  1515. GpStatus WINGDIPAPI
  1516. GdipPathIterNextPathType(
  1517. GpPathIterator* iterator,
  1518. INT* resultCount,
  1519. BYTE* pathType,
  1520. INT* startIndex,
  1521. INT* endIndex
  1522. )
  1523. {
  1524. API_ENTRY(GdipPathIterNextPathType);
  1525. CheckParameterValid(iterator);
  1526. CheckObjectBusy(iterator);
  1527. CheckParameter(resultCount);
  1528. CheckParameter(pathType);
  1529. CheckParameter(startIndex);
  1530. CheckParameter(endIndex);
  1531. *resultCount = iterator->NextPathType(pathType, startIndex, endIndex);
  1532. return Ok;
  1533. }
  1534. GpStatus WINGDIPAPI
  1535. GdipPathIterNextMarker(
  1536. GpPathIterator* iterator,
  1537. INT* resultCount,
  1538. INT* startIndex,
  1539. INT* endIndex)
  1540. {
  1541. API_ENTRY(GdipPathIterNextMarker);
  1542. CheckParameterValid(iterator);
  1543. CheckObjectBusy(iterator);
  1544. CheckParameter(resultCount);
  1545. CheckParameter(startIndex);
  1546. CheckParameter(endIndex);
  1547. *resultCount = iterator->NextMarker(startIndex, endIndex);
  1548. return Ok;
  1549. }
  1550. GpStatus WINGDIPAPI
  1551. GdipPathIterNextMarkerPath(
  1552. GpPathIterator* iterator,
  1553. INT* resultCount,
  1554. GpPath* path)
  1555. {
  1556. API_ENTRY(GdipPathIterNextMarkerPath);
  1557. CheckParameterValid(iterator);
  1558. CheckObjectBusy(iterator);
  1559. CheckParameter(resultCount);
  1560. *resultCount = iterator->NextMarker(path);
  1561. return Ok;
  1562. }
  1563. GpStatus WINGDIPAPI
  1564. GdipPathIterGetCount(
  1565. GpPathIterator* iterator,
  1566. INT* count
  1567. )
  1568. {
  1569. API_ENTRY(GdipPathIterGetCount);
  1570. CheckParameterValid(iterator);
  1571. CheckObjectBusy(iterator);
  1572. CheckParameter(count);
  1573. *count = iterator->GetCount();
  1574. return Ok;
  1575. }
  1576. GpStatus WINGDIPAPI
  1577. GdipPathIterGetSubpathCount(
  1578. GpPathIterator* iterator,
  1579. INT* count
  1580. )
  1581. {
  1582. API_ENTRY(GdipPathIterGetSubpathCount);
  1583. CheckParameterValid(iterator);
  1584. CheckObjectBusy(iterator);
  1585. CheckParameter(count);
  1586. *count = iterator->GetSubpathCount();
  1587. return Ok;
  1588. }
  1589. GpStatus WINGDIPAPI
  1590. GdipPathIterIsValid(
  1591. GpPathIterator* iterator,
  1592. BOOL* valid
  1593. )
  1594. {
  1595. API_ENTRY(GdipPathIterIsValid);
  1596. CheckParameterValid(iterator);
  1597. CheckObjectBusy(iterator);
  1598. CheckParameter(valid);
  1599. *valid = iterator->IsValid();
  1600. return Ok;
  1601. }
  1602. GpStatus WINGDIPAPI
  1603. GdipPathIterHasCurve(
  1604. GpPathIterator* iterator,
  1605. BOOL* hasCurve
  1606. )
  1607. {
  1608. API_ENTRY(GdipPathIterHasCurve);
  1609. CheckParameterValid(iterator);
  1610. CheckObjectBusy(iterator);
  1611. CheckParameter(hasCurve);
  1612. *hasCurve = iterator->HasCurve();
  1613. return Ok;
  1614. }
  1615. GpStatus WINGDIPAPI
  1616. GdipPathIterRewind(
  1617. GpPathIterator* iterator
  1618. )
  1619. {
  1620. API_ENTRY(GdipPathIterRewind);
  1621. CheckParameterValid(iterator);
  1622. CheckObjectBusy(iterator);
  1623. iterator->Rewind();
  1624. return Ok;
  1625. }
  1626. GpStatus WINGDIPAPI
  1627. GdipPathIterEnumerate(
  1628. GpPathIterator* iterator,
  1629. INT* resultCount,
  1630. GpPointF *points,
  1631. BYTE *types,
  1632. INT count)
  1633. {
  1634. API_ENTRY(GdipPathIterEnumerate);
  1635. CheckParameterValid(iterator);
  1636. CheckObjectBusy(iterator);
  1637. CheckParameter(resultCount);
  1638. CheckParameter(points);
  1639. CheckParameter(types);
  1640. *resultCount = iterator->Enumerate(points, types, count);
  1641. return Ok;
  1642. }
  1643. GpStatus WINGDIPAPI
  1644. GdipPathIterCopyData(
  1645. GpPathIterator* iterator,
  1646. INT* resultCount,
  1647. GpPointF* points,
  1648. BYTE* types,
  1649. INT startIndex,
  1650. INT endIndex)
  1651. {
  1652. API_ENTRY(GdipPathIterCopyData);
  1653. CheckParameterValid(iterator);
  1654. CheckObjectBusy(iterator);
  1655. CheckParameter(resultCount);
  1656. CheckParameter(points);
  1657. CheckParameter(types);
  1658. *resultCount = iterator->CopyData(points, types, startIndex, endIndex);
  1659. return Ok;
  1660. }
  1661. GpStatus
  1662. WINGDIPAPI
  1663. GdipCreateMatrix(GpMatrix **matrix)
  1664. {
  1665. API_ENTRY(GdipCreateMatrix);
  1666. CheckGdiplusInitialized; // We do this in all our object creation API's
  1667. CheckParameter(matrix);
  1668. *matrix = new GpMatrix();
  1669. if (CheckValid(*matrix))
  1670. return Ok;
  1671. else
  1672. return OutOfMemory;
  1673. }
  1674. GpStatus
  1675. WINGDIPAPI
  1676. GdipCreateMatrix2(
  1677. REAL m11,
  1678. REAL m12,
  1679. REAL m21,
  1680. REAL m22,
  1681. REAL dx,
  1682. REAL dy,
  1683. GpMatrix ** outMatrix
  1684. )
  1685. {
  1686. API_ENTRY(GdipCreateMatrix2);
  1687. CheckGdiplusInitialized; // We do this in all our object creation API's
  1688. CheckParameter(outMatrix);
  1689. GpMatrix * matrix;
  1690. matrix = (GpMatrix *) InterlockedExchangePointer((PVOID *) &Globals::MatrixLookAside, NULL);
  1691. if(matrix == NULL)
  1692. {
  1693. matrix = new GpMatrix(m11, m12, m21, m22, dx, dy);
  1694. }
  1695. else
  1696. {
  1697. matrix->GetObjectLock()->Reset();
  1698. matrix->SetMatrix(m11, m12, m21, m22, dx, dy);
  1699. }
  1700. if (CheckValid(matrix))
  1701. {
  1702. *outMatrix = matrix;
  1703. return Ok;
  1704. }
  1705. else
  1706. {
  1707. return OutOfMemory;
  1708. }
  1709. }
  1710. GpStatus
  1711. WINGDIPAPI
  1712. GdipCreateMatrix3(
  1713. GDIPCONST GpRectF *rect,
  1714. GDIPCONST GpPointF *dstplg,
  1715. GpMatrix **matrix
  1716. )
  1717. {
  1718. API_ENTRY(GdipCreateMatrix3);
  1719. CheckGdiplusInitialized; // We do this in all our object creation API's
  1720. CheckParameter(matrix && rect && dstplg);
  1721. *matrix = new GpMatrix(dstplg, *rect);
  1722. if (CheckValid(*matrix))
  1723. return Ok;
  1724. else
  1725. return OutOfMemory;
  1726. }
  1727. GpStatus
  1728. WINGDIPAPI
  1729. GdipCreateMatrix3I(
  1730. GDIPCONST GpRect *rect,
  1731. GDIPCONST GpPoint *dstplg,
  1732. GpMatrix **matrix
  1733. )
  1734. {
  1735. API_ENTRY(GdipCreateMatrix3I);
  1736. CheckGdiplusInitialized; // We do this in all our object creation API's
  1737. GpRectF rectf(TOREAL(rect->X), TOREAL(rect->Y), TOREAL(rect->Width), TOREAL(rect->Height));
  1738. GpPointF dstplgf[3] = { GpPointF(TOREAL(dstplg[0].X), TOREAL(dstplg[0].Y)),
  1739. GpPointF(TOREAL(dstplg[1].X), TOREAL(dstplg[1].Y)),
  1740. GpPointF(TOREAL(dstplg[2].X), TOREAL(dstplg[2].Y)) };
  1741. return GdipCreateMatrix3(&rectf, dstplgf, matrix);
  1742. }
  1743. GpStatus
  1744. WINGDIPAPI
  1745. GdipCloneMatrix(
  1746. GpMatrix *matrix,
  1747. GpMatrix **clonematrix
  1748. )
  1749. {
  1750. API_ENTRY(GdipCloneMatrix);
  1751. CheckParameter(clonematrix);
  1752. CheckParameterValid(matrix);
  1753. CheckObjectBusy(matrix);
  1754. *clonematrix = matrix->Clone();
  1755. if (CheckValid(*clonematrix))
  1756. return Ok;
  1757. else
  1758. return OutOfMemory;
  1759. }
  1760. GpStatus
  1761. WINGDIPAPI
  1762. GdipDeleteMatrix(
  1763. GpMatrix *matrix
  1764. )
  1765. {
  1766. API_ENTRY(GdipDeleteMatrix);
  1767. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  1768. // the object, even if it's not in a valid state.
  1769. CheckParameter(matrix);
  1770. CheckObjectBusyForDelete(matrix);
  1771. if(matrix != NULL)
  1772. {
  1773. matrix = (GpMatrix *) InterlockedExchangePointer((PVOID *) &Globals::MatrixLookAside, (PVOID) matrix);
  1774. if(matrix != NULL)
  1775. {
  1776. delete matrix;
  1777. }
  1778. }
  1779. return Ok;
  1780. }
  1781. GpStatus
  1782. WINGDIPAPI
  1783. GdipSetMatrixElements(
  1784. GpMatrix *matrix,
  1785. REAL m11,
  1786. REAL m12,
  1787. REAL m21,
  1788. REAL m22,
  1789. REAL dx,
  1790. REAL dy
  1791. )
  1792. {
  1793. API_ENTRY(GdipSetMatrixElements);
  1794. CheckParameterValid(matrix);
  1795. CheckObjectBusy(matrix);
  1796. REAL m[6] = { m11, m12, m21, m22, dx, dy };
  1797. matrix->SetMatrix((REAL*) &m);
  1798. return Ok;
  1799. }
  1800. GpStatus
  1801. WINGDIPAPI
  1802. GdipMultiplyMatrix(
  1803. GpMatrix *matrix,
  1804. GpMatrix *matrix2,
  1805. GpMatrixOrder order
  1806. )
  1807. {
  1808. API_ENTRY(GdipMultiplyMatrix);
  1809. CheckParameterValid(matrix);
  1810. CheckObjectBusy(matrix);
  1811. CheckParameterValid(matrix2);
  1812. CheckObjectBusy(matrix2);
  1813. CheckParameter(MatrixOrderIsValid(order));
  1814. if (order == MatrixOrderPrepend)
  1815. matrix->Prepend(*matrix2);
  1816. else
  1817. matrix->Append(*matrix2);
  1818. return Ok;
  1819. }
  1820. GpStatus
  1821. WINGDIPAPI
  1822. GdipTranslateMatrix(
  1823. GpMatrix *matrix,
  1824. REAL offsetX,
  1825. REAL offsetY,
  1826. GpMatrixOrder order
  1827. )
  1828. {
  1829. API_ENTRY(GdipTranslateMatrix);
  1830. CheckParameterValid(matrix);
  1831. CheckObjectBusy(matrix);
  1832. CheckParameter(MatrixOrderIsValid(order));
  1833. matrix->Translate(offsetX, offsetY, order);
  1834. return Ok;
  1835. }
  1836. GpStatus
  1837. WINGDIPAPI
  1838. GdipScaleMatrix(
  1839. GpMatrix *matrix,
  1840. REAL scaleX,
  1841. REAL scaleY,
  1842. GpMatrixOrder order
  1843. )
  1844. {
  1845. API_ENTRY(GdipScaleMatrix);
  1846. CheckParameterValid(matrix);
  1847. CheckObjectBusy(matrix);
  1848. CheckParameter(MatrixOrderIsValid(order));
  1849. matrix->Scale(scaleX, scaleY, order);
  1850. return Ok;
  1851. }
  1852. GpStatus
  1853. WINGDIPAPI
  1854. GdipRotateMatrix(
  1855. GpMatrix *matrix,
  1856. REAL angle,
  1857. GpMatrixOrder order
  1858. )
  1859. {
  1860. API_ENTRY(GdipRotateMatrix);
  1861. CheckParameterValid(matrix);
  1862. CheckObjectBusy(matrix);
  1863. CheckParameter(MatrixOrderIsValid(order));
  1864. matrix->Rotate(angle, order);
  1865. return Ok;
  1866. }
  1867. GpStatus
  1868. WINGDIPAPI
  1869. GdipShearMatrix(
  1870. GpMatrix *matrix,
  1871. REAL shearX,
  1872. REAL shearY,
  1873. GpMatrixOrder order
  1874. )
  1875. {
  1876. API_ENTRY(GdipShearMatrix);
  1877. CheckParameterValid(matrix);
  1878. CheckObjectBusy(matrix);
  1879. CheckParameter(MatrixOrderIsValid(order));
  1880. matrix->Shear(shearX, shearY, order);
  1881. return Ok;
  1882. }
  1883. GpStatus
  1884. WINGDIPAPI
  1885. GdipInvertMatrix(GpMatrix *matrix)
  1886. {
  1887. API_ENTRY(GdipInvertMatrix);
  1888. CheckParameterValid(matrix);
  1889. CheckObjectBusy(matrix);
  1890. return matrix->Invert();
  1891. }
  1892. GpStatus
  1893. WINGDIPAPI
  1894. GdipTransformMatrixPoints(
  1895. GpMatrix *matrix,
  1896. GpPointF *pts,
  1897. INT count
  1898. )
  1899. {
  1900. API_ENTRY(GdipTransformMatrixPoints);
  1901. CheckParameter(pts && count > 0);
  1902. CheckParameterValid(matrix);
  1903. CheckObjectBusy(matrix);
  1904. matrix->Transform(pts, count);
  1905. return Ok;
  1906. }
  1907. GpStatus
  1908. WINGDIPAPI
  1909. GdipTransformMatrixPointsI(
  1910. GpMatrix *matrix,
  1911. GpPoint *points,
  1912. INT count
  1913. )
  1914. {
  1915. API_ENTRY(GdipTransformMatrixPointsI);
  1916. StackBuffer buffer;
  1917. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  1918. if(!pointsF) return OutOfMemory;
  1919. for (INT i=0; i<count; i++)
  1920. {
  1921. pointsF[i].X = TOREAL(points[i].X);
  1922. pointsF[i].Y = TOREAL(points[i].Y);
  1923. }
  1924. GpStatus status = GdipTransformMatrixPoints(matrix, pointsF, count);
  1925. // convert back, rounding is a problem...
  1926. if (status == Ok)
  1927. {
  1928. for (INT i=0; i<count; i++)
  1929. {
  1930. points[i].X = GpRound(pointsF[i].X);
  1931. points[i].Y = GpRound(pointsF[i].Y);
  1932. }
  1933. }
  1934. return status;
  1935. }
  1936. GpStatus
  1937. WINGDIPAPI
  1938. GdipVectorTransformMatrixPoints(
  1939. GpMatrix *matrix,
  1940. GpPointF *pointsF,
  1941. INT count
  1942. )
  1943. {
  1944. API_ENTRY(GdipVectorTransformMatrixPoints);
  1945. CheckParameter(pointsF && count > 0);
  1946. CheckParameterValid(matrix);
  1947. CheckObjectBusy(matrix);
  1948. matrix->VectorTransform(pointsF, count);
  1949. return Ok;
  1950. }
  1951. GpStatus
  1952. WINGDIPAPI
  1953. GdipVectorTransformMatrixPointsI(
  1954. GpMatrix *matrix,
  1955. GpPoint *points,
  1956. INT count
  1957. )
  1958. {
  1959. API_ENTRY(GdipVectorTransformMatrixPointsI);
  1960. CheckParameter(points && count > 0);
  1961. CheckParameterValid(matrix);
  1962. CheckObjectBusy(matrix);
  1963. StackBuffer buffer;
  1964. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  1965. if(!pointsF) return OutOfMemory;
  1966. for (INT i=0; i<count; i++)
  1967. {
  1968. pointsF[i].X = TOREAL(points[i].X);
  1969. pointsF[i].Y = TOREAL(points[i].Y);
  1970. }
  1971. matrix->VectorTransform(pointsF, count);
  1972. // convert back, rounding is a problem...
  1973. for (i=0; i<count; i++)
  1974. {
  1975. points[i].X = GpRound(pointsF[i].X);
  1976. points[i].Y = GpRound(pointsF[i].Y);
  1977. }
  1978. return Ok;
  1979. }
  1980. GpStatus
  1981. WINGDIPAPI
  1982. GdipGetMatrixElements(
  1983. GDIPCONST GpMatrix *matrix,
  1984. REAL *m
  1985. )
  1986. {
  1987. API_ENTRY(GdipGetMatrixElements);
  1988. CheckParameter(m);
  1989. CheckParameterValid(matrix);
  1990. CheckObjectBusy(matrix);
  1991. matrix->GetMatrix(m);
  1992. return Ok;
  1993. }
  1994. GpStatus
  1995. WINGDIPAPI
  1996. GdipIsMatrixInvertible(
  1997. GDIPCONST GpMatrix *matrix,
  1998. BOOL *result
  1999. )
  2000. {
  2001. API_ENTRY(GdipIsMatrixInvertible);
  2002. CheckParameter(result);
  2003. CheckParameterValid(matrix);
  2004. CheckObjectBusy(matrix);
  2005. *result = matrix->IsInvertible();
  2006. return Ok;
  2007. }
  2008. GpStatus
  2009. WINGDIPAPI
  2010. GdipIsMatrixIdentity(
  2011. GDIPCONST GpMatrix *matrix,
  2012. BOOL *result
  2013. )
  2014. {
  2015. API_ENTRY(GdipIsMatrixIdentity);
  2016. CheckParameter(result);
  2017. CheckParameterValid(matrix);
  2018. CheckObjectBusy(matrix);
  2019. *result = matrix->IsIdentity();
  2020. return Ok;
  2021. }
  2022. GpStatus
  2023. WINGDIPAPI
  2024. GdipIsMatrixEqual(
  2025. GDIPCONST GpMatrix *matrix,
  2026. GDIPCONST GpMatrix *matrix2,
  2027. BOOL *result
  2028. )
  2029. {
  2030. API_ENTRY(GdipIsMatrixEqual);
  2031. CheckParameter(result);
  2032. CheckParameterValid(matrix);
  2033. CheckObjectBusy(matrix);
  2034. if (matrix != matrix2)
  2035. {
  2036. CheckParameterValid(matrix2);
  2037. CheckObjectBusy(matrix2);
  2038. *result = matrix->IsEqual(matrix2);
  2039. }
  2040. else
  2041. {
  2042. *result = TRUE;
  2043. }
  2044. return Ok;
  2045. }
  2046. GpStatus
  2047. WINGDIPAPI
  2048. GdipCreateRegion(
  2049. GpRegion **region
  2050. )
  2051. {
  2052. API_ENTRY(GdipCreateRegion);
  2053. CheckGdiplusInitialized; // We do this in all our object creation API's
  2054. CheckParameter(region);
  2055. *region = new GpRegion();
  2056. if (CheckValid(*region))
  2057. return Ok;
  2058. else
  2059. return OutOfMemory;
  2060. }
  2061. GpStatus
  2062. WINGDIPAPI
  2063. GdipCreateRegionRect(
  2064. GDIPCONST GpRectF *rect,
  2065. GpRegion **region
  2066. )
  2067. {
  2068. API_ENTRY(GdipCreateRegionRect);
  2069. CheckGdiplusInitialized; // We do this in all our object creation API's
  2070. CheckParameter(region && rect);
  2071. *region = new GpRegion(rect);
  2072. if (CheckValid(*region))
  2073. return Ok;
  2074. else
  2075. return OutOfMemory;
  2076. }
  2077. GpStatus
  2078. WINGDIPAPI
  2079. GdipCreateRegionRectI(
  2080. GDIPCONST GpRect *rect,
  2081. GpRegion **region
  2082. )
  2083. {
  2084. API_ENTRY(GdipCreateRegionRectI);
  2085. CheckGdiplusInitialized; // We do this in all our object creation API's
  2086. GpRectF rectf(TOREAL(rect->X),
  2087. TOREAL(rect->Y),
  2088. TOREAL(rect->Width),
  2089. TOREAL(rect->Height));
  2090. return GdipCreateRegionRect(&rectf, region);
  2091. }
  2092. GpStatus
  2093. WINGDIPAPI
  2094. GdipCreateRegionPath(
  2095. GpPath *path,
  2096. GpRegion **region
  2097. )
  2098. {
  2099. API_ENTRY(GdipCreateRegionPath);
  2100. CheckGdiplusInitialized; // We do this in all our object creation API's
  2101. CheckParameter(region);
  2102. CheckParameterValid(path);
  2103. CheckObjectBusy(path);
  2104. *region = new GpRegion(path);
  2105. if (CheckValid(*region))
  2106. return Ok;
  2107. else
  2108. return OutOfMemory;
  2109. }
  2110. GpStatus
  2111. WINGDIPAPI
  2112. GdipCreateRegionRgnData(
  2113. GDIPCONST BYTE *regionData,
  2114. INT size,
  2115. GpRegion **region
  2116. )
  2117. {
  2118. API_ENTRY(GdipCreateRegionRgnData);
  2119. CheckGdiplusInitialized; // We do this in all our object creation API's
  2120. CheckParameter(regionData);
  2121. CheckParameter(region);
  2122. *region = new GpRegion(regionData, size);
  2123. if (CheckValid(*region))
  2124. return Ok;
  2125. else
  2126. return GenericError;
  2127. }
  2128. GpStatus
  2129. WINGDIPAPI
  2130. GdipCreateRegionHrgn(
  2131. HRGN hRgn,
  2132. GpRegion **region
  2133. )
  2134. {
  2135. API_ENTRY(GdipCreateRegionHrgn);
  2136. CheckGdiplusInitialized; // We do this in all our object creation API's
  2137. CheckParameter(region && hRgn && (GetObjectTypeInternal(hRgn) == OBJ_REGION));
  2138. *region = new GpRegion(hRgn);
  2139. if (CheckValid(*region))
  2140. return Ok;
  2141. else
  2142. return OutOfMemory;
  2143. }
  2144. GpStatus
  2145. WINGDIPAPI
  2146. GdipCloneRegion(
  2147. GpRegion *region,
  2148. GpRegion **cloneregion
  2149. )
  2150. {
  2151. API_ENTRY(GdipCloneRegion);
  2152. CheckParameter(cloneregion);
  2153. CheckParameterValid(region);
  2154. CheckObjectBusy(region);
  2155. *cloneregion = new GpRegion(region);
  2156. if (CheckValid(*cloneregion))
  2157. return Ok;
  2158. else
  2159. return OutOfMemory;
  2160. }
  2161. GpStatus
  2162. WINGDIPAPI
  2163. GdipDeleteRegion(
  2164. GpRegion *region
  2165. )
  2166. {
  2167. API_ENTRY(GdipDeleteRegion);
  2168. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  2169. // the object, even if it's not in a valid state.
  2170. CheckParameter(region);
  2171. CheckObjectBusyForDelete(region);
  2172. delete region;
  2173. return Ok;
  2174. }
  2175. GpStatus
  2176. WINGDIPAPI
  2177. GdipSetInfinite(
  2178. GpRegion *region
  2179. )
  2180. {
  2181. API_ENTRY(GdipSetInfinite);
  2182. CheckParameterValid(region);
  2183. CheckObjectBusy(region);
  2184. region->SetInfinite();
  2185. return Ok;
  2186. }
  2187. GpStatus
  2188. WINGDIPAPI
  2189. GdipSetEmpty(
  2190. GpRegion *region
  2191. )
  2192. {
  2193. API_ENTRY(GdipSetEmpty);
  2194. CheckParameterValid(region);
  2195. CheckObjectBusy(region);
  2196. region->SetEmpty();
  2197. return Ok;
  2198. }
  2199. GpStatus
  2200. WINGDIPAPI
  2201. GdipCombineRegionRect(
  2202. GpRegion * region,
  2203. GDIPCONST GpRectF * rect,
  2204. CombineMode combineMode
  2205. )
  2206. {
  2207. API_ENTRY(GdipCombineRegionRect);
  2208. CheckParameter(rect);
  2209. CheckParameterValid(region);
  2210. CheckObjectBusy(region);
  2211. CheckParameter(CombineModeIsValid(combineMode));
  2212. return region->Combine(rect, combineMode);
  2213. }
  2214. GpStatus
  2215. WINGDIPAPI
  2216. GdipCombineRegionRectI(
  2217. GpRegion * region,
  2218. GDIPCONST GpRect * rect,
  2219. CombineMode combineMode
  2220. )
  2221. {
  2222. API_ENTRY(GdipCombineRegionRectI);
  2223. GpRectF rectf(TOREAL(rect->X),
  2224. TOREAL(rect->Y),
  2225. TOREAL(rect->Width),
  2226. TOREAL(rect->Height));
  2227. return GdipCombineRegionRect(region, &rectf, combineMode);
  2228. }
  2229. GpStatus
  2230. WINGDIPAPI
  2231. GdipCombineRegionPath(
  2232. GpRegion * region,
  2233. GpPath * path,
  2234. CombineMode combineMode
  2235. )
  2236. {
  2237. API_ENTRY(GdipCombineRegionPath);
  2238. CheckParameterValid(region);
  2239. CheckParameterValid(path);
  2240. CheckObjectBusy(region);
  2241. CheckObjectBusy(path);
  2242. CheckParameter(CombineModeIsValid(combineMode));
  2243. return region->Combine(path, combineMode);
  2244. }
  2245. GpStatus
  2246. WINGDIPAPI
  2247. GdipCombineRegionRegion(
  2248. GpRegion * region,
  2249. GpRegion * region2,
  2250. CombineMode combineMode
  2251. )
  2252. {
  2253. API_ENTRY(GdipCombineRegionRegion);
  2254. CheckParameterValid(region);
  2255. CheckObjectBusy(region);
  2256. CheckParameterValid(region2);
  2257. CheckObjectBusy(region2);
  2258. CheckParameter(CombineModeIsValid(combineMode));
  2259. return region->Combine(region2, combineMode);
  2260. }
  2261. GpStatus
  2262. WINGDIPAPI
  2263. GdipTranslateRegion(
  2264. GpRegion *region,
  2265. REAL dx,
  2266. REAL dy
  2267. )
  2268. {
  2269. API_ENTRY(GdipTranslateRegion);
  2270. CheckParameter(region);
  2271. CheckParameterValid(region);
  2272. region->Offset(dx, dy);
  2273. return Ok;
  2274. }
  2275. GpStatus
  2276. WINGDIPAPI
  2277. GdipTranslateRegionI(
  2278. GpRegion *region,
  2279. INT dx,
  2280. INT dy
  2281. )
  2282. {
  2283. API_ENTRY(GdipTranslateRegionI);
  2284. return GdipTranslateRegion(region, TOREAL(dx), TOREAL(dy));
  2285. }
  2286. GpStatus
  2287. WINGDIPAPI
  2288. GdipTransformRegion(
  2289. GpRegion *region,
  2290. GpMatrix *matrix
  2291. )
  2292. {
  2293. API_ENTRY(GdipTransformRegion);
  2294. CheckParameterValid(matrix);
  2295. CheckObjectBusy(matrix);
  2296. CheckParameterValid(region);
  2297. CheckObjectBusy(region);
  2298. return region->Transform(matrix);
  2299. }
  2300. GpStatus
  2301. WINGDIPAPI
  2302. GdipGetRegionBounds(
  2303. GpRegion *region,
  2304. GpGraphics *graphics,
  2305. GpRectF *rect
  2306. )
  2307. {
  2308. API_ENTRY(GdipGetRegionBounds);
  2309. CheckParameter(rect);
  2310. CheckParameterValid(region);
  2311. CheckObjectBusy(region);
  2312. CheckParameterValid(graphics);
  2313. CheckObjectBusy(graphics);
  2314. return region->GetBounds(graphics, rect);
  2315. }
  2316. GpStatus
  2317. WINGDIPAPI
  2318. GdipGetRegionBoundsI(
  2319. GpRegion *region,
  2320. GpGraphics *graphics,
  2321. GpRect *rect
  2322. )
  2323. {
  2324. API_ENTRY(GdipGetRegionBoundsI);
  2325. CheckParameter(rect);
  2326. CheckParameterValid(region);
  2327. CheckObjectBusy(region);
  2328. CheckParameterValid(graphics);
  2329. CheckObjectBusy(graphics);
  2330. GpRectF rectF;
  2331. GpStatus status = region->GetBounds(graphics, &rectF);
  2332. if (status == Ok)
  2333. {
  2334. rect->X = GpRound(rectF.X);
  2335. rect->Y = GpRound(rectF.Y);
  2336. rect->Width = GpRound(rectF.Width);
  2337. rect->Height = GpRound(rectF.Height);
  2338. }
  2339. return status;
  2340. }
  2341. GpStatus
  2342. WINGDIPAPI
  2343. GdipGetRegionHRgn(
  2344. GpRegion *region,
  2345. GpGraphics *graphics, // can be NULL
  2346. HRGN *hRgn
  2347. )
  2348. {
  2349. API_ENTRY(GdipGetRegionHRgn);
  2350. CheckParameter(hRgn);
  2351. CheckParameterValid(region);
  2352. CheckObjectBusy(region);
  2353. if (graphics != NULL)
  2354. {
  2355. CheckParameterValid(graphics);
  2356. CheckObjectBusy(graphics);
  2357. return region->GetHRgn(graphics, hRgn);
  2358. }
  2359. return region->GetHRgn((GpGraphics*)NULL, hRgn);
  2360. }
  2361. GpStatus
  2362. WINGDIPAPI
  2363. GdipIsEmptyRegion(
  2364. GpRegion *region,
  2365. GpGraphics *graphics,
  2366. BOOL *result
  2367. )
  2368. {
  2369. API_ENTRY(GdipIsEmptyRegion);
  2370. CheckParameter(result);
  2371. CheckParameterValid(region);
  2372. CheckObjectBusy(region);
  2373. CheckParameterValid(graphics);
  2374. CheckObjectBusy(graphics);
  2375. GpMatrix worldToDevice;
  2376. Status status;
  2377. graphics->GetWorldToDeviceTransform(&worldToDevice);
  2378. status = region->IsEmpty(&worldToDevice, result);
  2379. return status;
  2380. }
  2381. GpStatus
  2382. WINGDIPAPI
  2383. GdipIsInfiniteRegion(
  2384. GpRegion *region,
  2385. GpGraphics *graphics,
  2386. BOOL *result
  2387. )
  2388. {
  2389. API_ENTRY(GdipIsInfiniteRegion);
  2390. CheckParameter(result);
  2391. CheckParameterValid(region);
  2392. CheckObjectBusy(region);
  2393. CheckParameterValid(graphics);
  2394. CheckObjectBusy(graphics);
  2395. GpMatrix worldToDevice;
  2396. Status status;
  2397. graphics->GetWorldToDeviceTransform(&worldToDevice);
  2398. status = region->IsInfinite(&worldToDevice, result);
  2399. return status;
  2400. }
  2401. GpStatus
  2402. WINGDIPAPI
  2403. GdipIsEqualRegion(
  2404. GpRegion *region,
  2405. GpRegion *region2,
  2406. GpGraphics *graphics,
  2407. BOOL *result
  2408. )
  2409. {
  2410. API_ENTRY(GdipIsEqualRegion);
  2411. CheckParameter(result);
  2412. CheckParameterValid(region);
  2413. CheckObjectBusy(region);
  2414. CheckParameterValid(graphics);
  2415. CheckObjectBusy(graphics);
  2416. Status status;
  2417. if (region != region2)
  2418. {
  2419. CheckParameterValid(region2);
  2420. CheckObjectBusy(region2);
  2421. GpMatrix worldToDevice;
  2422. graphics->GetWorldToDeviceTransform(&worldToDevice);
  2423. status = region->IsEqual(region2, &worldToDevice, result);
  2424. }
  2425. else
  2426. {
  2427. *result = TRUE;
  2428. status = Ok;
  2429. }
  2430. return status;
  2431. }
  2432. GpStatus
  2433. WINGDIPAPI
  2434. GdipGetRegionDataSize(
  2435. GpRegion * region,
  2436. UINT * bufferSize
  2437. )
  2438. {
  2439. API_ENTRY(GdipGetRegionDataSize);
  2440. CheckParameterValid(region);
  2441. CheckObjectBusy(region);
  2442. CheckParameter(bufferSize);
  2443. if ((*bufferSize = region->GetExternalDataSize()) > 0)
  2444. {
  2445. return Ok;
  2446. }
  2447. return GenericError;
  2448. }
  2449. GpStatus
  2450. WINGDIPAPI
  2451. GdipGetRegionData(
  2452. GpRegion * region,
  2453. BYTE * buffer,
  2454. UINT bufferSize,
  2455. UINT * sizeFilled
  2456. )
  2457. {
  2458. API_ENTRY(GdipGetRegionData);
  2459. CheckParameterValid(region);
  2460. CheckObjectBusy(region);
  2461. CheckParameter(buffer);
  2462. CheckParameter(bufferSize > 0);
  2463. UINT filled = bufferSize;
  2464. GpStatus status = region->GetExternalData(buffer, filled);
  2465. ASSERT((INT)filled <= bufferSize);
  2466. if (sizeFilled != NULL)
  2467. {
  2468. *sizeFilled = filled;
  2469. }
  2470. return status;
  2471. }
  2472. GpStatus
  2473. WINGDIPAPI
  2474. GdipIsVisibleRegionPoint(
  2475. GpRegion *region,
  2476. REAL x,
  2477. REAL y,
  2478. GpGraphics *graphics,
  2479. BOOL *result
  2480. )
  2481. {
  2482. API_ENTRY(GdipIsVisibleRegionPoint);
  2483. CheckParameter(result);
  2484. CheckParameterValid(region);
  2485. CheckObjectBusy(region);
  2486. Status status;
  2487. GpPointF pt(x, y);
  2488. GpMatrix worldToDevice;
  2489. if (graphics != NULL)
  2490. {
  2491. CheckParameterValid(graphics);
  2492. CheckObjectBusy(graphics);
  2493. graphics->GetWorldToDeviceTransform(&worldToDevice);
  2494. }
  2495. status = region->IsVisible(&pt, &worldToDevice, result);
  2496. return status;
  2497. }
  2498. GpStatus
  2499. WINGDIPAPI
  2500. GdipIsVisibleRegionPointI(
  2501. GpRegion *region,
  2502. INT x,
  2503. INT y,
  2504. GpGraphics *graphics,
  2505. BOOL *result
  2506. )
  2507. {
  2508. API_ENTRY(GdipIsVisibleRegionPointI);
  2509. return GdipIsVisibleRegionPoint(region, TOREAL(x), TOREAL(y), graphics, result);
  2510. }
  2511. GpStatus
  2512. WINGDIPAPI
  2513. GdipIsVisibleRegionRect(
  2514. GpRegion *region,
  2515. REAL x,
  2516. REAL y,
  2517. REAL width,
  2518. REAL height,
  2519. GpGraphics *graphics,
  2520. BOOL *result
  2521. )
  2522. {
  2523. API_ENTRY(GdipIsVisibleRegionRect);
  2524. CheckParameter(result);
  2525. CheckParameterValid(region);
  2526. CheckObjectBusy(region);
  2527. Status status;
  2528. GpRectF rect(x, y, width, height);
  2529. GpMatrix worldToDevice;
  2530. if (graphics != NULL)
  2531. {
  2532. CheckParameterValid(graphics);
  2533. CheckObjectBusy(graphics);
  2534. graphics->GetWorldToDeviceTransform(&worldToDevice);
  2535. }
  2536. status = region->IsVisible(&rect, &worldToDevice, result);
  2537. return status;
  2538. }
  2539. GpStatus
  2540. WINGDIPAPI
  2541. GdipIsVisibleRegionRectI(
  2542. GpRegion *region,
  2543. INT x,
  2544. INT y,
  2545. INT width,
  2546. INT height,
  2547. GpGraphics *graphics,
  2548. BOOL *result
  2549. )
  2550. {
  2551. API_ENTRY(GdipIsVisibleRegionRectI);
  2552. return GdipIsVisibleRegionRect(region,
  2553. TOREAL(x),
  2554. TOREAL(y),
  2555. TOREAL(width),
  2556. TOREAL(height),
  2557. graphics,
  2558. result);
  2559. }
  2560. GpStatus
  2561. WINGDIPAPI
  2562. GdipGetRegionScansCount(
  2563. GpRegion *region,
  2564. UINT *count,
  2565. GpMatrix *matrix
  2566. )
  2567. {
  2568. API_ENTRY(GdipGetRegionScansCount);
  2569. CheckParameterValid(region);
  2570. CheckObjectBusy(region);
  2571. CheckParameter(count);
  2572. CheckParameterValid(matrix);
  2573. CheckObjectBusy(matrix);
  2574. // !! Rewrite this API to be more efficient
  2575. return region->GetRegionScans((GpRect*)NULL,
  2576. (INT*)count,
  2577. matrix);
  2578. }
  2579. // If rects is NULL, return the count of rects in the region.
  2580. // Otherwise, assume rects is big enough to hold all the region rects
  2581. // and fill them in and return the number of rects filled in.
  2582. GpStatus
  2583. WINGDIPAPI
  2584. GdipGetRegionScans(
  2585. GpRegion *region,
  2586. GpRectF *rects, // NULL to just get the count
  2587. INT *count,
  2588. GpMatrix *matrix
  2589. )
  2590. {
  2591. API_ENTRY(GdipGetRegionScans);
  2592. CheckParameterValid(region);
  2593. CheckObjectBusy(region);
  2594. CheckParameter(count);
  2595. CheckParameterValid(matrix);
  2596. CheckObjectBusy(matrix);
  2597. // !! Rewrite this API to verify IN count is sufficient
  2598. return region->GetRegionScans(rects, count, matrix);
  2599. }
  2600. // If rects is NULL, return the count of rects in the region.
  2601. // Otherwise, assume rects is big enough to hold all the region rects
  2602. // and fill them in and return the number of rects filled in.
  2603. GpStatus
  2604. WINGDIPAPI
  2605. GdipGetRegionScansI(
  2606. GpRegion *region,
  2607. GpRect *rects, // NULL to just get the count
  2608. INT *count,
  2609. GpMatrix *matrix
  2610. )
  2611. {
  2612. API_ENTRY(GdipGetRegionScansI);
  2613. CheckParameterValid(region);
  2614. CheckObjectBusy(region);
  2615. CheckParameter(count);
  2616. CheckParameterValid(matrix);
  2617. CheckObjectBusy(matrix);
  2618. return region->GetRegionScans(rects, count, matrix);
  2619. }
  2620. GpStatus
  2621. WINGDIPAPI
  2622. GdipCloneBrush(
  2623. GpBrush *brush,
  2624. GpBrush **clonebrush
  2625. )
  2626. {
  2627. API_ENTRY(GdipCloneBrush);
  2628. CheckParameter(clonebrush);
  2629. CheckParameterValid(brush);
  2630. CheckObjectBusy(brush);
  2631. *clonebrush = brush->Clone();
  2632. if (CheckValid(*clonebrush))
  2633. return Ok;
  2634. else
  2635. return OutOfMemory;
  2636. }
  2637. GpStatus
  2638. WINGDIPAPI
  2639. GdipDeleteBrush(
  2640. GpBrush *brush
  2641. )
  2642. {
  2643. API_ENTRY(GdipDeleteBrush);
  2644. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  2645. // the object, even if it's not in a valid state.
  2646. CheckParameter(brush);
  2647. CheckObjectBusyForDelete(brush);
  2648. delete brush;
  2649. return Ok;
  2650. }
  2651. GpStatus
  2652. WINGDIPAPI
  2653. GdipGetBrushType(
  2654. GpBrush *brush,
  2655. GpBrushType *type
  2656. )
  2657. {
  2658. API_ENTRY(GdipGetBrushType);
  2659. CheckParameter(type);
  2660. CheckParameterValid(brush);
  2661. CheckObjectBusy(brush);
  2662. *type = brush->GetBrushType();
  2663. return Ok;
  2664. }
  2665. GpStatus
  2666. WINGDIPAPI
  2667. GdipCreateHatchBrush(
  2668. GpHatchStyle hatchstyle,
  2669. ARGB forecol,
  2670. ARGB backcol,
  2671. GpHatch **hatch
  2672. )
  2673. {
  2674. API_ENTRY(GdipCreateHatchBrush);
  2675. CheckGdiplusInitialized; // We do this in all our object creation API's
  2676. CheckParameter((hatchstyle >= HatchStyleMin) && (hatchstyle <= HatchStyleMax));
  2677. CheckParameter(hatch);
  2678. CheckColorParameter(forecol);
  2679. CheckColorParameter(backcol);
  2680. GpColor fore(forecol);
  2681. GpColor back(backcol);
  2682. *hatch = new GpHatch(hatchstyle, fore, back);
  2683. if (CheckValid(*hatch))
  2684. return Ok;
  2685. else
  2686. return OutOfMemory;
  2687. }
  2688. GpStatus
  2689. WINGDIPAPI
  2690. GdipGetHatchStyle(
  2691. GpHatch *brush,
  2692. GpHatchStyle *hatchStyle
  2693. )
  2694. {
  2695. API_ENTRY(GdipGetHatchStyle);
  2696. CheckParameter(hatchStyle);
  2697. CheckParameterValid(brush);
  2698. CheckObjectBusy(brush);
  2699. *hatchStyle = brush->GetHatchStyle();
  2700. return Ok;
  2701. }
  2702. GpStatus
  2703. WINGDIPAPI
  2704. GdipGetHatchForegroundColor(
  2705. GpHatch *brush,
  2706. ARGB *argb
  2707. )
  2708. {
  2709. API_ENTRY(GdipGetHatchForegroundColor);
  2710. CheckParameter(argb);
  2711. CheckParameterValid(brush);
  2712. CheckObjectBusy(brush);
  2713. GpColor foreColor;
  2714. GpStatus status = brush->GetForegroundColor((GpColor*)&foreColor);
  2715. *argb = foreColor.GetValue();
  2716. return status;
  2717. }
  2718. GpStatus
  2719. WINGDIPAPI
  2720. GdipGetHatchBackgroundColor(
  2721. GpHatch *brush,
  2722. ARGB *argb
  2723. )
  2724. {
  2725. API_ENTRY(GdipGetHatchBackgroundColor);
  2726. CheckParameter(argb);
  2727. CheckParameterValid(brush);
  2728. CheckObjectBusy(brush);
  2729. GpColor backColor;
  2730. GpStatus status = brush->GetBackgroundColor((GpColor*)&backColor);
  2731. *argb = backColor.GetValue();
  2732. return status;
  2733. }
  2734. GpStatus
  2735. WINGDIPAPI
  2736. GdipCreateTexture(
  2737. GpImage *image,
  2738. GpWrapMode wrapmode,
  2739. GpTexture **texture
  2740. )
  2741. {
  2742. API_ENTRY(GdipCreateTexture);
  2743. CheckGdiplusInitialized; // We do this in all our object creation API's
  2744. CheckParameter(texture);
  2745. CheckParameterValid(image);
  2746. CheckObjectBusy(image);
  2747. *texture = new GpTexture(image, wrapmode);
  2748. if (CheckValid(*texture))
  2749. return Ok;
  2750. else
  2751. return OutOfMemory;
  2752. }
  2753. GpStatus
  2754. WINGDIPAPI
  2755. GdipCreateTexture2(
  2756. GpImage *image,
  2757. GpWrapMode wrapmode,
  2758. REAL x,
  2759. REAL y,
  2760. REAL width,
  2761. REAL height,
  2762. GpTexture **texture
  2763. )
  2764. {
  2765. API_ENTRY(GdipCreateTexture2);
  2766. CheckGdiplusInitialized; // We do this in all our object creation API's
  2767. CheckParameter(texture);
  2768. CheckParameterValid(image);
  2769. CheckObjectBusy(image);
  2770. GpRectF rect(x, y, width, height);
  2771. *texture = new GpTexture(image, wrapmode, rect);
  2772. if (CheckValid(*texture))
  2773. return Ok;
  2774. else
  2775. return OutOfMemory;
  2776. }
  2777. GpStatus
  2778. WINGDIPAPI
  2779. GdipCreateTextureIA(
  2780. GpImage *image,
  2781. GDIPCONST GpImageAttributes *imageAttributes,
  2782. REAL x,
  2783. REAL y,
  2784. REAL width,
  2785. REAL height,
  2786. GpTexture **texture
  2787. )
  2788. {
  2789. API_ENTRY(GdipCreateTextureIA);
  2790. CheckGdiplusInitialized; // We do this in all our object creation API's
  2791. CheckParameter(texture);
  2792. CheckParameterValid(image);
  2793. CheckObjectBusy(image);
  2794. CheckOptionalParameterValid(imageAttributes);
  2795. CheckOptionalObjectBusy(imageAttributes);
  2796. GpRectF rect(x, y, width, height);
  2797. *texture = new GpTexture(image, rect, imageAttributes);
  2798. if (CheckValid(*texture))
  2799. return Ok;
  2800. else
  2801. return OutOfMemory;
  2802. }
  2803. GpStatus
  2804. WINGDIPAPI
  2805. GdipCreateTexture2I(
  2806. GpImage *image,
  2807. GpWrapMode wrapmode,
  2808. INT x,
  2809. INT y,
  2810. INT width,
  2811. INT height,
  2812. GpTexture **texture
  2813. )
  2814. {
  2815. API_ENTRY(GdipCreateTexture2I);
  2816. CheckGdiplusInitialized; // We do this in all our object creation API's
  2817. return GdipCreateTexture2(image,
  2818. wrapmode,
  2819. TOREAL(x),
  2820. TOREAL(y),
  2821. TOREAL(width),
  2822. TOREAL(height),
  2823. texture);
  2824. }
  2825. GpStatus
  2826. WINGDIPAPI
  2827. GdipCreateTextureIAI(
  2828. GpImage *image,
  2829. GDIPCONST GpImageAttributes *imageAttributes,
  2830. INT x,
  2831. INT y,
  2832. INT width,
  2833. INT height,
  2834. GpTexture **texture
  2835. )
  2836. {
  2837. return GdipCreateTextureIA(image,
  2838. imageAttributes,
  2839. TOREAL(x),
  2840. TOREAL(y),
  2841. TOREAL(width),
  2842. TOREAL(height),
  2843. texture);
  2844. }
  2845. GpStatus
  2846. WINGDIPAPI
  2847. GdipSetTextureTransform(
  2848. GpTexture *brush,
  2849. GDIPCONST GpMatrix *matrix
  2850. )
  2851. {
  2852. API_ENTRY(GdipSetTextureTransform);
  2853. CheckParameterValid(brush);
  2854. CheckObjectBusy(brush);
  2855. CheckParameterValid(matrix);
  2856. CheckObjectBusy(matrix);
  2857. return brush->SetTransform(*matrix);
  2858. }
  2859. GpStatus
  2860. WINGDIPAPI
  2861. GdipGetTextureTransform(
  2862. GpTexture *brush,
  2863. GpMatrix *matrix
  2864. )
  2865. {
  2866. API_ENTRY(GdipGetTextureTransform);
  2867. CheckParameterValid(brush);
  2868. CheckObjectBusy(brush);
  2869. CheckParameterValid(matrix);
  2870. CheckObjectBusy(matrix);
  2871. return brush->GetTransform(matrix);
  2872. }
  2873. GpStatus
  2874. WINGDIPAPI
  2875. GdipResetTextureTransform(
  2876. GpTexture* brush)
  2877. {
  2878. API_ENTRY(GdipResetTextureTransform);
  2879. CheckParameterValid(brush);
  2880. CheckObjectBusy(brush);
  2881. return brush->ResetTransform();
  2882. }
  2883. GpStatus
  2884. WINGDIPAPI
  2885. GdipMultiplyTextureTransform(
  2886. GpTexture* brush,
  2887. GDIPCONST GpMatrix *matrix,
  2888. GpMatrixOrder order)
  2889. {
  2890. API_ENTRY(GdipMultiplyTextureTransform);
  2891. if(matrix == NULL)
  2892. return Ok;
  2893. CheckParameterValid(brush);
  2894. CheckObjectBusy(brush);
  2895. CheckParameterValid(matrix);
  2896. CheckObjectBusy(matrix);
  2897. return brush->MultiplyTransform(*matrix, order);
  2898. }
  2899. GpStatus
  2900. WINGDIPAPI
  2901. GdipTranslateTextureTransform(
  2902. GpTexture* brush,
  2903. REAL dx,
  2904. REAL dy,
  2905. GpMatrixOrder order
  2906. )
  2907. {
  2908. API_ENTRY(GdipTranslateTextureTransform);
  2909. CheckParameterValid(brush);
  2910. CheckObjectBusy(brush);
  2911. CheckParameter(MatrixOrderIsValid(order));
  2912. return brush->TranslateTransform(dx, dy, order);
  2913. }
  2914. GpStatus
  2915. WINGDIPAPI
  2916. GdipScaleTextureTransform(
  2917. GpTexture* brush,
  2918. REAL sx,
  2919. REAL sy,
  2920. GpMatrixOrder order
  2921. )
  2922. {
  2923. API_ENTRY(GdipScaleTextureTransform);
  2924. CheckParameterValid(brush);
  2925. CheckObjectBusy(brush);
  2926. CheckParameter(MatrixOrderIsValid(order));
  2927. return brush->ScaleTransform(sx, sy, order);
  2928. }
  2929. GpStatus
  2930. WINGDIPAPI
  2931. GdipRotateTextureTransform(
  2932. GpTexture* brush,
  2933. REAL angle,
  2934. GpMatrixOrder order
  2935. )
  2936. {
  2937. API_ENTRY(GdipRotateTextureTransform);
  2938. CheckParameterValid(brush);
  2939. CheckObjectBusy(brush);
  2940. CheckParameter(MatrixOrderIsValid(order));
  2941. return brush->RotateTransform(angle, order);
  2942. }
  2943. GpStatus
  2944. WINGDIPAPI
  2945. GdipSetTextureWrapMode(
  2946. GpTexture *brush,
  2947. GpWrapMode wrapmode
  2948. )
  2949. {
  2950. API_ENTRY(GdipSetTextureWrapMode);
  2951. CheckParameterValid(brush);
  2952. CheckObjectBusy(brush);
  2953. brush->SetWrapMode(wrapmode);
  2954. return Ok;
  2955. }
  2956. GpStatus
  2957. WINGDIPAPI
  2958. GdipGetTextureWrapMode(
  2959. GpTexture *brush,
  2960. GpWrapMode *wrapmode
  2961. )
  2962. {
  2963. API_ENTRY(GdipGetTextureWrapMode);
  2964. CheckParameter(wrapmode);
  2965. CheckParameterValid(brush);
  2966. CheckObjectBusy(brush);
  2967. *wrapmode = (GpWrapMode)brush->GetWrapMode();
  2968. return Ok;
  2969. }
  2970. GpStatus
  2971. WINGDIPAPI
  2972. GdipGetTextureImage(
  2973. GpTexture *brush,
  2974. GpImage **image
  2975. )
  2976. {
  2977. API_ENTRY(GdipGetTextureImage);
  2978. // GetImage returns a pointer to the internal GpImage structure. Because
  2979. // we have to create a new Image wrapper around it and give it to the caller
  2980. // at the API level, we return a clone so they can throw it away without
  2981. // destroying our internal brush structure.
  2982. GpImage *imgtmp;
  2983. imgtmp = brush->GetImage();
  2984. *image = imgtmp->Clone();
  2985. return Ok;
  2986. }
  2987. GpStatus
  2988. WINGDIPAPI
  2989. GdipCreateSolidFill(
  2990. ARGB color,
  2991. GpSolidFill **solidfill
  2992. )
  2993. {
  2994. API_ENTRY(GdipCreateSolidFill);
  2995. CheckGdiplusInitialized; // We do this in all our object creation API's
  2996. CheckParameter(solidfill);
  2997. CheckColorParameter(color);
  2998. *solidfill = new GpSolidFill(GpColor(color));
  2999. if (CheckValid(*solidfill))
  3000. return Ok;
  3001. else
  3002. return OutOfMemory;
  3003. }
  3004. GpStatus
  3005. WINGDIPAPI
  3006. GdipSetSolidFillColor(
  3007. GpSolidFill *brush,
  3008. ARGB color
  3009. )
  3010. {
  3011. API_ENTRY(GdipSetSolidFillColor);
  3012. CheckColorParameter(color);
  3013. CheckParameterValid(brush);
  3014. CheckObjectBusy(brush);
  3015. brush->SetColor(GpColor(color));
  3016. return Ok;
  3017. }
  3018. GpStatus
  3019. WINGDIPAPI
  3020. GdipGetSolidFillColor(
  3021. GpSolidFill *brush,
  3022. ARGB *color
  3023. )
  3024. {
  3025. API_ENTRY(GdipGetSolidFillColor);
  3026. CheckParameter(color);
  3027. CheckParameterValid(brush);
  3028. CheckObjectBusy(brush);
  3029. *color = (brush->GetColor()).GetValue();
  3030. return Ok;
  3031. }
  3032. GpStatus
  3033. WINGDIPAPI
  3034. GdipCreateLineBrush(
  3035. GDIPCONST GpPointF* point1,
  3036. GDIPCONST GpPointF* point2,
  3037. ARGB color1,
  3038. ARGB color2,
  3039. GpWrapMode wrapmode,
  3040. GpLineGradient **linegrad
  3041. )
  3042. {
  3043. API_ENTRY(GdipCreateLineBrush);
  3044. CheckGdiplusInitialized; // We do this in all our object creation API's
  3045. CheckParameter(linegrad && point1 && point2);
  3046. CheckColorParameter(color1);
  3047. CheckColorParameter(color2);
  3048. if(wrapmode == WrapModeClamp)
  3049. {
  3050. return InvalidParameter;
  3051. }
  3052. GpColor c1(color1);
  3053. GpColor c2(color2);
  3054. *linegrad = new GpLineGradient(*point1, *point2, c1, c2, wrapmode);
  3055. if (CheckValid(*linegrad))
  3056. return Ok;
  3057. else
  3058. return OutOfMemory;
  3059. }
  3060. GpStatus
  3061. WINGDIPAPI
  3062. GdipCreateLineBrushI(
  3063. GDIPCONST GpPoint* point1,
  3064. GDIPCONST GpPoint* point2,
  3065. ARGB color1,
  3066. ARGB color2,
  3067. GpWrapMode wrapmode,
  3068. GpLineGradient **linegrad
  3069. )
  3070. {
  3071. API_ENTRY(GdipCreateLineBrushI);
  3072. CheckGdiplusInitialized; // We do this in all our object creation API's
  3073. CheckColorParameter(color1);
  3074. CheckColorParameter(color2);
  3075. CheckParameter(point1 && point2);
  3076. if(wrapmode == WrapModeClamp)
  3077. {
  3078. return InvalidParameter;
  3079. }
  3080. GpPointF point1F(TOREAL(point1->X), TOREAL(point1->Y));
  3081. GpPointF point2F(TOREAL(point2->X), TOREAL(point2->Y));
  3082. return GdipCreateLineBrush(&point1F,
  3083. &point2F,
  3084. color1,
  3085. color2,
  3086. wrapmode,
  3087. linegrad);
  3088. }
  3089. GpStatus
  3090. WINGDIPAPI
  3091. GdipCreateLineBrushFromRect(
  3092. GDIPCONST GpRectF* rect,
  3093. ARGB color1,
  3094. ARGB color2,
  3095. LinearGradientMode mode,
  3096. GpWrapMode wrapmode,
  3097. GpLineGradient **linegrad)
  3098. {
  3099. API_ENTRY(GdipCreateLineBrushFromRect);
  3100. CheckGdiplusInitialized; // We do this in all our object creation API's
  3101. CheckColorParameter(color1);
  3102. CheckColorParameter(color2);
  3103. CheckParameter(linegrad && rect);
  3104. if(wrapmode == WrapModeClamp)
  3105. {
  3106. return InvalidParameter;
  3107. }
  3108. GpColor c1(color1);
  3109. GpColor c2(color2);
  3110. *linegrad = new GpLineGradient(*rect, c1, c2, mode, wrapmode);
  3111. if (CheckValid(*linegrad))
  3112. return Ok;
  3113. else
  3114. return OutOfMemory;
  3115. }
  3116. GpStatus
  3117. WINGDIPAPI
  3118. GdipCreateLineBrushFromRectI(
  3119. GDIPCONST GpRect* rect,
  3120. ARGB color1,
  3121. ARGB color2,
  3122. LinearGradientMode mode,
  3123. GpWrapMode wrapmode,
  3124. GpLineGradient **linegrad)
  3125. {
  3126. API_ENTRY(GdipCreateLineBrushFromRectI);
  3127. CheckGdiplusInitialized; // We do this in all our object creation API's
  3128. CheckColorParameter(color1);
  3129. CheckColorParameter(color2);
  3130. CheckParameter(rect);
  3131. if(wrapmode == WrapModeClamp)
  3132. {
  3133. return InvalidParameter;
  3134. }
  3135. GpRectF rectF(TOREAL(rect->X),
  3136. TOREAL(rect->Y),
  3137. TOREAL(rect->Width),
  3138. TOREAL(rect->Height));
  3139. return GdipCreateLineBrushFromRect(&rectF,
  3140. color1,
  3141. color2,
  3142. mode,
  3143. wrapmode,
  3144. linegrad);
  3145. }
  3146. GpStatus
  3147. WINGDIPAPI
  3148. GdipCreateLineBrushFromRectWithAngle(
  3149. GDIPCONST GpRectF* rect,
  3150. ARGB color1,
  3151. ARGB color2,
  3152. REAL angle,
  3153. BOOL isAngleScalable,
  3154. GpWrapMode wrapmode,
  3155. GpLineGradient **linegrad)
  3156. {
  3157. API_ENTRY(GdipCreateLineBrushFromRectWithAngle);
  3158. CheckGdiplusInitialized; // We do this in all our object creation API's
  3159. CheckColorParameter(color1);
  3160. CheckColorParameter(color2);
  3161. CheckParameter(linegrad && rect);
  3162. if(wrapmode == WrapModeClamp)
  3163. {
  3164. return InvalidParameter;
  3165. }
  3166. GpColor c1(color1);
  3167. GpColor c2(color2);
  3168. *linegrad = new GpLineGradient(*rect, c1, c2, angle,
  3169. isAngleScalable, wrapmode);
  3170. if (CheckValid(*linegrad))
  3171. return Ok;
  3172. else
  3173. return OutOfMemory;
  3174. }
  3175. GpStatus
  3176. WINGDIPAPI
  3177. GdipCreateLineBrushFromRectWithAngleI(
  3178. GDIPCONST GpRect* rect,
  3179. ARGB color1,
  3180. ARGB color2,
  3181. REAL angle,
  3182. BOOL isAngleScalable,
  3183. GpWrapMode wrapmode,
  3184. GpLineGradient **linegrad)
  3185. {
  3186. API_ENTRY(GdipCreateLineBrushFromRectWithAngleI);
  3187. CheckGdiplusInitialized; // We do this in all our object creation API's
  3188. CheckColorParameter(color1);
  3189. CheckColorParameter(color2);
  3190. CheckParameter(rect);
  3191. if(wrapmode == WrapModeClamp)
  3192. {
  3193. return InvalidParameter;
  3194. }
  3195. GpRectF rectF(TOREAL(rect->X),
  3196. TOREAL(rect->Y),
  3197. TOREAL(rect->Width),
  3198. TOREAL(rect->Height));
  3199. return GdipCreateLineBrushFromRectWithAngle(&rectF,
  3200. color1,
  3201. color2,
  3202. angle,
  3203. isAngleScalable,
  3204. wrapmode,
  3205. linegrad);
  3206. }
  3207. GpStatus
  3208. WINGDIPAPI
  3209. GdipSetLineColors(
  3210. GpLineGradient *brush,
  3211. ARGB argb1,
  3212. ARGB argb2
  3213. )
  3214. {
  3215. API_ENTRY(GdipSetLineColors);
  3216. CheckColorParameter(argb1);
  3217. CheckColorParameter(argb2);
  3218. CheckParameterValid(brush);
  3219. CheckObjectBusy(brush);
  3220. GpColor c1(argb1);
  3221. GpColor c2(argb2);
  3222. brush->SetLineColors(c1, c2);
  3223. return Ok;
  3224. }
  3225. GpStatus
  3226. WINGDIPAPI
  3227. GdipGetLineColors(
  3228. GpLineGradient *brush,
  3229. ARGB *argb
  3230. )
  3231. {
  3232. API_ENTRY(GdipGetLineColors);
  3233. CheckParameter(argb);
  3234. CheckParameterValid(brush);
  3235. CheckObjectBusy(brush);
  3236. GpColor colors[2];
  3237. brush->GetLineColors(&colors[0]);
  3238. argb[0] = colors[0].GetValue();
  3239. argb[1] = colors[1].GetValue();
  3240. return Ok;
  3241. }
  3242. GpStatus
  3243. WINGDIPAPI
  3244. GdipGetLineRect(
  3245. GpLineGradient *brush,
  3246. GpRectF *rect
  3247. )
  3248. {
  3249. API_ENTRY(GdipGetLineRect);
  3250. CheckParameter(rect);
  3251. CheckParameterValid(brush);
  3252. CheckObjectBusy(brush);
  3253. brush->GetRect(*rect);
  3254. return Ok;
  3255. }
  3256. GpStatus
  3257. WINGDIPAPI
  3258. GdipGetLineRectI(
  3259. GpLineGradient *brush,
  3260. GpRect *rect
  3261. )
  3262. {
  3263. API_ENTRY(GdipGetLineRectI);
  3264. CheckParameter(rect);
  3265. GpRectF rectF;
  3266. GpStatus status = GdipGetLineRect(brush, &rectF);
  3267. if (status == Ok)
  3268. {
  3269. rect->X = GpRound(rectF.X);
  3270. rect->Y = GpRound(rectF.Y);
  3271. rect->Width = GpRound(rectF.Width);
  3272. rect->Height = GpRound(rectF.Height);
  3273. }
  3274. return status;
  3275. }
  3276. GpStatus
  3277. WINGDIPAPI
  3278. GdipSetLineGammaCorrection(
  3279. GpLineGradient *brush,
  3280. BOOL useGammaCorrection
  3281. )
  3282. {
  3283. CheckParameterValid(brush);
  3284. CheckObjectBusy(brush);
  3285. brush->SetGammaCorrection(useGammaCorrection);
  3286. return Ok;
  3287. }
  3288. GpStatus
  3289. WINGDIPAPI
  3290. GdipGetLineGammaCorrection(
  3291. GpLineGradient *brush,
  3292. BOOL *useGammaCorrection)
  3293. {
  3294. CheckParameter(useGammaCorrection);
  3295. CheckParameterValid(brush);
  3296. CheckObjectBusy(brush);
  3297. *useGammaCorrection = brush->GetGammaCorrection();
  3298. return Ok;
  3299. }
  3300. GpStatus
  3301. WINGDIPAPI
  3302. GdipGetLineBlendCount(
  3303. GpLineGradient *brush,
  3304. INT *count
  3305. )
  3306. {
  3307. API_ENTRY(GdipGetLineBlendCount);
  3308. CheckParameter(count);
  3309. CheckParameterValid(brush);
  3310. CheckObjectBusy(brush);
  3311. *count = brush->GetBlendCount();
  3312. return Ok;
  3313. }
  3314. GpStatus
  3315. WINGDIPAPI
  3316. GdipGetLineBlend(
  3317. GpLineGradient *brush,
  3318. REAL *blend,
  3319. REAL *positions,
  3320. INT count
  3321. )
  3322. {
  3323. API_ENTRY(GdipGetLineBlend);
  3324. CheckParameter(blend);
  3325. CheckParameter(positions);
  3326. CheckParameterValid(brush);
  3327. CheckObjectBusy(brush);
  3328. return brush->GetBlend(blend, positions, count);
  3329. }
  3330. GpStatus
  3331. WINGDIPAPI
  3332. GdipSetLineBlend(
  3333. GpLineGradient *brush,
  3334. GDIPCONST REAL *blend,
  3335. GDIPCONST REAL *positions,
  3336. INT count
  3337. )
  3338. {
  3339. API_ENTRY(GdipSetLineBlend);
  3340. CheckParameter(blend);
  3341. CheckParameter(positions);
  3342. CheckParameterValid(brush);
  3343. CheckObjectBusy(brush);
  3344. return brush->SetBlend(blend, positions, count);
  3345. }
  3346. GpStatus
  3347. WINGDIPAPI
  3348. GdipGetLinePresetBlendCount(
  3349. GpLineGradient *brush,
  3350. INT *count
  3351. )
  3352. {
  3353. API_ENTRY(GdipGetLinePresetBlendCount);
  3354. CheckParameter(count);
  3355. CheckParameterValid(brush);
  3356. CheckObjectBusy(brush);
  3357. *count = brush->GetPresetBlendCount();
  3358. return Ok;
  3359. }
  3360. GpStatus
  3361. WINGDIPAPI
  3362. GdipGetLinePresetBlend(
  3363. GpLineGradient *brush,
  3364. ARGB *blend,
  3365. REAL *blendPositions,
  3366. INT count
  3367. )
  3368. {
  3369. API_ENTRY(GdipGetLinePresetBlend);
  3370. CheckParameter(blend);
  3371. CheckParameter(blendPositions);
  3372. CheckParameterValid(brush);
  3373. CheckObjectBusy(brush);
  3374. if (count <= 0)
  3375. {
  3376. return InvalidParameter;
  3377. }
  3378. if (count < brush->GetPresetBlendCount())
  3379. {
  3380. return InsufficientBuffer;
  3381. }
  3382. StackBuffer buffer;
  3383. GpColor* gpcolors = (GpColor*) buffer.GetBuffer(count*sizeof(GpColor));
  3384. if(!gpcolors) return OutOfMemory;
  3385. if (gpcolors)
  3386. {
  3387. GpStatus status = brush->GetPresetBlend(gpcolors, blendPositions, count);
  3388. for(INT i = 0; i < count; i++)
  3389. {
  3390. blend[i] = gpcolors[i].GetValue();
  3391. }
  3392. return status;
  3393. }
  3394. else
  3395. return OutOfMemory;
  3396. }
  3397. GpStatus
  3398. WINGDIPAPI
  3399. GdipSetLinePresetBlend(
  3400. GpLineGradient *brush,
  3401. GDIPCONST ARGB *blend,
  3402. GDIPCONST REAL *blendPositions,
  3403. INT count
  3404. )
  3405. {
  3406. API_ENTRY(GdipSetLinePresetBlend);
  3407. CheckParameter(blend);
  3408. CheckParameter(blendPositions);
  3409. CheckParameterValid(brush);
  3410. CheckObjectBusy(brush);
  3411. CheckParameter(count > 0)
  3412. // blend positions must start at 0.0 and end at 1.0
  3413. if (REALABS(blendPositions[0]) > REAL_EPSILON ||
  3414. REALABS(1.0f - blendPositions[count-1]) > REAL_EPSILON)
  3415. {
  3416. return InvalidParameter;
  3417. }
  3418. StackBuffer buffer;
  3419. GpColor* gpcolors = (GpColor*) buffer.GetBuffer(count*sizeof(GpColor));
  3420. if(!gpcolors) return OutOfMemory;
  3421. if(gpcolors)
  3422. {
  3423. for(INT i = 0; i < count; i++)
  3424. {
  3425. gpcolors[i].SetColor(blend[i]);
  3426. }
  3427. GpStatus status = brush->SetPresetBlend(gpcolors, blendPositions, count);
  3428. return status;
  3429. }
  3430. else
  3431. return OutOfMemory;
  3432. }
  3433. GpStatus
  3434. WINGDIPAPI
  3435. GdipSetLineSigmaBlend(
  3436. GpLineGradient *brush,
  3437. REAL focus,
  3438. REAL scale
  3439. )
  3440. {
  3441. API_ENTRY(GdipSetLineSigmaBlend);
  3442. CheckParameterValid(brush);
  3443. CheckObjectBusy(brush);
  3444. return brush->SetSigmaBlend(focus, scale);
  3445. }
  3446. GpStatus
  3447. WINGDIPAPI
  3448. GdipSetLineLinearBlend(
  3449. GpLineGradient *brush,
  3450. REAL focus,
  3451. REAL scale
  3452. )
  3453. {
  3454. API_ENTRY(GdipSetLineLinearBlend);
  3455. CheckParameterValid(brush);
  3456. CheckObjectBusy(brush);
  3457. return brush->SetLinearBlend(focus, scale);
  3458. }
  3459. GpStatus
  3460. WINGDIPAPI
  3461. GdipSetLineWrapMode(
  3462. GpLineGradient *brush,
  3463. GpWrapMode wrapmode
  3464. )
  3465. {
  3466. API_ENTRY(GdipSetLineWrapMode);
  3467. CheckParameterValid(brush);
  3468. CheckObjectBusy(brush);
  3469. GpStatus status = Ok;
  3470. if(wrapmode != WrapModeClamp)
  3471. brush->SetWrapMode(wrapmode);
  3472. else
  3473. status = InvalidParameter;
  3474. return status;
  3475. }
  3476. GpStatus
  3477. WINGDIPAPI
  3478. GdipGetLineWrapMode(
  3479. GpLineGradient *brush,
  3480. GpWrapMode *wrapmode
  3481. )
  3482. {
  3483. API_ENTRY(GdipGetLineWrapMode);
  3484. CheckParameter(wrapmode);
  3485. CheckParameterValid(brush);
  3486. CheckObjectBusy(brush);
  3487. *wrapmode = (GpWrapMode)brush->GetWrapMode();
  3488. return Ok;
  3489. }
  3490. GpStatus
  3491. WINGDIPAPI
  3492. GdipSetLineTransform(
  3493. GpLineGradient *brush,
  3494. GDIPCONST GpMatrix *matrix
  3495. )
  3496. {
  3497. API_ENTRY(GdipSetLineTransform);
  3498. CheckParameterValid(brush);
  3499. CheckObjectBusy(brush);
  3500. CheckParameterValid(matrix);
  3501. CheckObjectBusy(matrix);
  3502. return brush->SetTransform(*matrix);
  3503. }
  3504. GpStatus
  3505. WINGDIPAPI
  3506. GdipGetLineTransform(
  3507. GpLineGradient *brush,
  3508. GpMatrix *matrix
  3509. )
  3510. {
  3511. API_ENTRY(GdipGetLineTransform);
  3512. CheckParameterValid(brush);
  3513. CheckObjectBusy(brush);
  3514. CheckParameterValid(matrix);
  3515. CheckObjectBusy(matrix);
  3516. return brush->GetTransform(matrix);
  3517. }
  3518. GpStatus
  3519. WINGDIPAPI
  3520. GdipResetLineTransform(
  3521. GpLineGradient* brush)
  3522. {
  3523. API_ENTRY(GdipResetLineTransform);
  3524. CheckParameterValid(brush);
  3525. CheckObjectBusy(brush);
  3526. return brush->ResetTransform();
  3527. }
  3528. GpStatus
  3529. WINGDIPAPI
  3530. GdipMultiplyLineTransform(
  3531. GpLineGradient* brush,
  3532. GDIPCONST GpMatrix *matrix,
  3533. GpMatrixOrder order)
  3534. {
  3535. API_ENTRY(GdipMultiplyLineTransform);
  3536. if(matrix == NULL)
  3537. return Ok;
  3538. CheckParameterValid(brush);
  3539. CheckObjectBusy(brush);
  3540. CheckParameterValid(matrix);
  3541. CheckObjectBusy(matrix);
  3542. return brush->MultiplyTransform(*matrix, order);
  3543. }
  3544. GpStatus
  3545. WINGDIPAPI
  3546. GdipTranslateLineTransform(
  3547. GpLineGradient* brush,
  3548. REAL dx,
  3549. REAL dy,
  3550. GpMatrixOrder order
  3551. )
  3552. {
  3553. API_ENTRY(GdipTranslateLineTransform);
  3554. CheckParameterValid(brush);
  3555. CheckObjectBusy(brush);
  3556. CheckParameter(MatrixOrderIsValid(order));
  3557. return brush->TranslateTransform(dx, dy, order);
  3558. }
  3559. GpStatus
  3560. WINGDIPAPI
  3561. GdipScaleLineTransform(
  3562. GpLineGradient* brush,
  3563. REAL sx,
  3564. REAL sy,
  3565. GpMatrixOrder order
  3566. )
  3567. {
  3568. API_ENTRY(GdipScaleLineTransform);
  3569. CheckParameterValid(brush);
  3570. CheckObjectBusy(brush);
  3571. CheckParameter(MatrixOrderIsValid(order));
  3572. return brush->ScaleTransform(sx, sy, order);
  3573. }
  3574. GpStatus
  3575. WINGDIPAPI
  3576. GdipRotateLineTransform(
  3577. GpLineGradient* brush,
  3578. REAL angle,
  3579. GpMatrixOrder order
  3580. )
  3581. {
  3582. API_ENTRY(GdipRotateLineTransform);
  3583. CheckParameterValid(brush);
  3584. CheckObjectBusy(brush);
  3585. CheckParameter(MatrixOrderIsValid(order));
  3586. return brush->RotateTransform(angle, order);
  3587. }
  3588. GpStatus
  3589. WINGDIPAPI
  3590. GdipCreatePathGradient(
  3591. GDIPCONST GpPointF* points,
  3592. INT count,
  3593. GpWrapMode wrapMode,
  3594. GpPathGradient **brush
  3595. )
  3596. {
  3597. API_ENTRY(GdipCreatePathGradient);
  3598. CheckGdiplusInitialized; // We do this in all our object creation API's
  3599. CheckParameter(brush);
  3600. *brush = new GpPathGradient(points, count, wrapMode);
  3601. if (CheckValid(*brush))
  3602. return Ok;
  3603. else
  3604. return OutOfMemory;
  3605. }
  3606. GpStatus
  3607. WINGDIPAPI
  3608. GdipCreatePathGradientI(
  3609. GDIPCONST GpPoint* points,
  3610. INT count,
  3611. GpWrapMode wrapMode,
  3612. GpPathGradient **brush
  3613. )
  3614. {
  3615. API_ENTRY(GdipCreatePathGradientI);
  3616. CheckGdiplusInitialized; // We do this in all our object creation API's
  3617. CheckParameter(points);
  3618. StackBuffer buffer;
  3619. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  3620. if(!pointsF) return OutOfMemory;
  3621. for (INT i=0; i<count; i++)
  3622. {
  3623. pointsF[i].X = TOREAL(points[i].X);
  3624. pointsF[i].Y = TOREAL(points[i].Y);
  3625. }
  3626. GpStatus status = GdipCreatePathGradient(pointsF, count, wrapMode, brush);
  3627. return status;
  3628. }
  3629. GpStatus
  3630. WINGDIPAPI
  3631. GdipCreatePathGradientFromPath(
  3632. GDIPCONST GpPath* path,
  3633. GpPathGradient **brush
  3634. )
  3635. {
  3636. API_ENTRY(GdipCreatePathGradientFromPath);
  3637. CheckGdiplusInitialized; // We do this in all our object creation API's
  3638. CheckParameter(brush);
  3639. *brush = new GpPathGradient(path);
  3640. if (CheckValid(*brush))
  3641. return Ok;
  3642. else
  3643. return OutOfMemory;
  3644. }
  3645. GpStatus
  3646. WINGDIPAPI
  3647. GdipGetPathGradientCenterColor(
  3648. GpPathGradient *brush,
  3649. ARGB* color
  3650. )
  3651. {
  3652. API_ENTRY(GdipGetPathGradientCenterColor);
  3653. CheckParameter(color);
  3654. CheckParameterValid(brush);
  3655. CheckObjectBusy(brush);
  3656. GpColor center;
  3657. brush->GetCenterColor(&center);
  3658. *color = center.GetValue();
  3659. return Ok;
  3660. }
  3661. GpStatus
  3662. WINGDIPAPI
  3663. GdipSetPathGradientCenterColor(
  3664. GpPathGradient *brush,
  3665. ARGB color
  3666. )
  3667. {
  3668. API_ENTRY(GdipSetPathGradientCenterColor);
  3669. CheckColorParameter(color);
  3670. CheckParameterValid(brush);
  3671. CheckObjectBusy(brush);
  3672. GpColor center(color);
  3673. brush->SetCenterColor(center);
  3674. return Ok;
  3675. }
  3676. GpStatus
  3677. WINGDIPAPI
  3678. GdipGetPathGradientSurroundColorsWithCount(
  3679. GpPathGradient *brush,
  3680. ARGB* colors,
  3681. INT* count
  3682. )
  3683. {
  3684. API_ENTRY(GdipGetPathGradientSurroundColorsWithCount);
  3685. CheckParameter(colors);
  3686. CheckParameterValid(brush);
  3687. CheckObjectBusy(brush);
  3688. INT count1 = brush->GetNumberOfPoints();
  3689. if(*count < count1 || count1 <= 0)
  3690. return InvalidParameter;
  3691. count1 = min(*count, count1);
  3692. ARGB lastValue, nextValue;
  3693. INT n = 1;
  3694. for(INT i = 0; i < count1; i++)
  3695. {
  3696. GpColor color;
  3697. brush->GetSurroundColor(&color, i);
  3698. nextValue = color.GetValue();
  3699. colors[i] = nextValue;
  3700. if(i > 0)
  3701. {
  3702. if(nextValue != lastValue)
  3703. n = i + 1;
  3704. }
  3705. lastValue = nextValue;
  3706. }
  3707. *count = n;
  3708. return Ok;
  3709. }
  3710. GpStatus
  3711. WINGDIPAPI
  3712. GdipSetPathGradientSurroundColorsWithCount(
  3713. GpPathGradient *brush,
  3714. GDIPCONST ARGB* colors,
  3715. INT* count
  3716. )
  3717. {
  3718. API_ENTRY(GdipSetPathGradientSurroundColorsWithCount);
  3719. CheckParameter(colors);
  3720. CheckParameterValid(brush);
  3721. CheckObjectBusy(brush);
  3722. INT count1 = brush->GetNumberOfPoints();
  3723. INT minCount = min(*count, count1);
  3724. if(*count > count1 || minCount < 1)
  3725. {
  3726. return InvalidParameter;
  3727. }
  3728. GpColor *gpColors = new GpColor[count1];
  3729. if(NULL == gpColors)
  3730. {
  3731. return OutOfMemory;
  3732. }
  3733. INT i;
  3734. for(i = 0; i < minCount; i++)
  3735. {
  3736. gpColors[i].SetColor(colors[i]);
  3737. }
  3738. if(minCount < count1)
  3739. {
  3740. for(i = minCount; i < count1; i++)
  3741. {
  3742. gpColors[i].SetColor(colors[minCount - 1]);
  3743. }
  3744. }
  3745. *count = minCount;
  3746. GpStatus status = brush->SetSurroundColors(gpColors);
  3747. delete[] gpColors;
  3748. return Ok;
  3749. }
  3750. GpStatus
  3751. WINGDIPAPI
  3752. GdipGetPathGradientPath(
  3753. GpPathGradient *brush,
  3754. GpPath *path
  3755. )
  3756. {
  3757. API_ENTRY(GdipGetPathGradientPath);
  3758. return NotImplemented;
  3759. }
  3760. GpStatus
  3761. WINGDIPAPI
  3762. GdipSetPathGradientPath(
  3763. GpPathGradient *brush,
  3764. GDIPCONST GpPath *path
  3765. )
  3766. {
  3767. API_ENTRY(GdipSetPathGradientPath);
  3768. return NotImplemented;
  3769. }
  3770. GpStatus
  3771. WINGDIPAPI
  3772. GdipGetPathGradientCenterPoint(
  3773. GpPathGradient *brush,
  3774. GpPointF* point
  3775. )
  3776. {
  3777. API_ENTRY(GdipGetPathGradientCenterPoint);
  3778. CheckParameter(point);
  3779. CheckParameterValid(brush);
  3780. CheckObjectBusy(brush);
  3781. return brush->GetCenterPoint(point);
  3782. }
  3783. GpStatus
  3784. WINGDIPAPI
  3785. GdipGetPathGradientCenterPointI(
  3786. GpPathGradient *brush,
  3787. GpPoint* point
  3788. )
  3789. {
  3790. API_ENTRY(GdipGetPathGradientCenterPointI);
  3791. CheckParameter(point);
  3792. GpPointF pointF;
  3793. GpStatus status = GdipGetPathGradientCenterPoint(brush, &pointF);
  3794. if (status == Ok)
  3795. {
  3796. point->X = GpRound(pointF.X);
  3797. point->Y = GpRound(pointF.Y);
  3798. }
  3799. return status;
  3800. }
  3801. GpStatus
  3802. WINGDIPAPI
  3803. GdipSetPathGradientCenterPoint(
  3804. GpPathGradient *brush,
  3805. GDIPCONST GpPointF* point
  3806. )
  3807. {
  3808. API_ENTRY(GdipSetPathGradientCenterPoint);
  3809. CheckParameter(point);
  3810. CheckParameterValid(brush);
  3811. CheckObjectBusy(brush);
  3812. return brush->SetCenterPoint(*point);
  3813. }
  3814. GpStatus
  3815. WINGDIPAPI
  3816. GdipSetPathGradientCenterPointI(
  3817. GpPathGradient *brush,
  3818. GDIPCONST GpPoint* point
  3819. )
  3820. {
  3821. API_ENTRY(GdipSetPathGradientCenterPointI);
  3822. CheckParameter(point);
  3823. GpPointF pointF(TOREAL(point->X), TOREAL(point->Y));
  3824. return GdipSetPathGradientCenterPoint(brush, &pointF);
  3825. }
  3826. GpStatus
  3827. WINGDIPAPI
  3828. GdipGetPathGradientPointCount(
  3829. GpPathGradient *brush,
  3830. INT* count)
  3831. {
  3832. API_ENTRY(GdipGetPathGradientPointCount);
  3833. CheckParameter(count);
  3834. CheckParameterValid(brush);
  3835. CheckObjectBusy(brush);
  3836. *count = brush->GetNumberOfPoints();
  3837. return Ok;
  3838. }
  3839. GpStatus
  3840. WINGDIPAPI
  3841. GdipGetPathGradientSurroundColorCount(
  3842. GpPathGradient *brush,
  3843. INT* count)
  3844. {
  3845. API_ENTRY(GdipGetPathGradientSurroundColorCount);
  3846. CheckParameter(count);
  3847. CheckParameterValid(brush);
  3848. CheckObjectBusy(brush);
  3849. *count = brush->GetNumberOfColors();
  3850. return Ok;
  3851. }
  3852. GpStatus
  3853. WINGDIPAPI
  3854. GdipGetPathGradientRect(
  3855. GpPathGradient *brush,
  3856. GpRectF *rect
  3857. )
  3858. {
  3859. API_ENTRY(GdipGetPathGradientRect);
  3860. CheckParameter(rect);
  3861. CheckParameterValid(brush);
  3862. CheckObjectBusy(brush);
  3863. brush->GetRect(*rect);
  3864. return Ok;
  3865. }
  3866. GpStatus
  3867. WINGDIPAPI
  3868. GdipGetPathGradientRectI(
  3869. GpPathGradient *brush,
  3870. GpRect *rect
  3871. )
  3872. {
  3873. API_ENTRY(GdipGetPathGradientRectI);
  3874. CheckParameter(rect);
  3875. GpRectF rectF;
  3876. GpStatus status = GdipGetPathGradientRect(brush, &rectF);
  3877. if (status == Ok)
  3878. {
  3879. rect->X = GpRound(rectF.X);
  3880. rect->Y = GpRound(rectF.Y);
  3881. rect->Width = GpRound(rectF.Width);
  3882. rect->Height = GpRound(rectF.Height);
  3883. }
  3884. return status;
  3885. }
  3886. GpStatus
  3887. WINGDIPAPI
  3888. GdipSetPathGradientGammaCorrection(
  3889. GpPathGradient *brush,
  3890. BOOL useGammaCorrection
  3891. )
  3892. {
  3893. API_ENTRY(GdipSetPathGradientGammaCorrection);
  3894. CheckParameterValid(brush);
  3895. CheckObjectBusy(brush);
  3896. brush->SetGammaCorrection(useGammaCorrection);
  3897. return Ok;
  3898. }
  3899. GpStatus
  3900. WINGDIPAPI
  3901. GdipGetPathGradientGammaCorrection(
  3902. GpPathGradient *brush,
  3903. BOOL *useGammaCorrection)
  3904. {
  3905. API_ENTRY(GdipGetPathGradientGammaCorrection);
  3906. CheckParameter(useGammaCorrection);
  3907. CheckParameterValid(brush);
  3908. CheckObjectBusy(brush);
  3909. *useGammaCorrection = brush->GetGammaCorrection();
  3910. return Ok;
  3911. }
  3912. GpStatus
  3913. WINGDIPAPI
  3914. GdipGetPathGradientBlendCount(
  3915. GpPathGradient *brush,
  3916. INT *count
  3917. )
  3918. {
  3919. API_ENTRY(GdipGetPathGradientBlendCount);
  3920. CheckParameter(count);
  3921. CheckParameterValid(brush);
  3922. CheckObjectBusy(brush);
  3923. *count = brush->GetBlendCount();
  3924. return Ok;
  3925. }
  3926. GpStatus
  3927. WINGDIPAPI
  3928. GdipGetPathGradientBlend(
  3929. GpPathGradient *brush,
  3930. REAL *blend,
  3931. REAL *positions,
  3932. INT count
  3933. )
  3934. {
  3935. API_ENTRY(GdipGetPathGradientBlend);
  3936. CheckParameter(blend);
  3937. CheckParameter(positions);
  3938. CheckParameterValid(brush);
  3939. CheckObjectBusy(brush);
  3940. return brush->GetBlend(blend, positions, count);
  3941. }
  3942. GpStatus
  3943. WINGDIPAPI
  3944. GdipSetPathGradientBlend(
  3945. GpPathGradient *brush,
  3946. GDIPCONST REAL *blend,
  3947. GDIPCONST REAL *positions,
  3948. INT count
  3949. )
  3950. {
  3951. API_ENTRY(GdipSetPathGradientBlend);
  3952. CheckParameter(blend);
  3953. CheckParameter(positions);
  3954. CheckParameterValid(brush);
  3955. CheckObjectBusy(brush);
  3956. return brush->SetBlend(blend, positions, count);
  3957. }
  3958. GpStatus
  3959. WINGDIPAPI
  3960. GdipGetPathGradientPresetBlendCount(
  3961. GpPathGradient *brush,
  3962. INT *count
  3963. )
  3964. {
  3965. API_ENTRY(GdipGetPathGradientPresetBlendCount);
  3966. CheckParameter(count);
  3967. CheckParameterValid(brush);
  3968. CheckObjectBusy(brush);
  3969. *count = brush->GetPresetBlendCount();
  3970. return Ok;
  3971. }
  3972. GpStatus
  3973. WINGDIPAPI
  3974. GdipGetPathGradientPresetBlend(
  3975. GpPathGradient *brush,
  3976. ARGB *blend,
  3977. REAL *blendPositions,
  3978. INT count
  3979. )
  3980. {
  3981. API_ENTRY(GdipGetPathGradientPresetBlend);
  3982. CheckParameter(blend);
  3983. CheckParameterValid(brush);
  3984. CheckObjectBusy(brush);
  3985. StackBuffer buffer;
  3986. GpColor* gpcolors = (GpColor*) buffer.GetBuffer(count*sizeof(GpColor));
  3987. if(!gpcolors) return OutOfMemory;
  3988. if (gpcolors)
  3989. {
  3990. GpStatus status = brush->GetPresetBlend(gpcolors, blendPositions, count);
  3991. for(INT i = 0; i < count; i++)
  3992. {
  3993. blend[i] = gpcolors[i].GetValue();
  3994. }
  3995. return status;
  3996. }
  3997. else
  3998. return OutOfMemory;
  3999. }
  4000. GpStatus
  4001. WINGDIPAPI
  4002. GdipSetPathGradientPresetBlend(
  4003. GpPathGradient *brush,
  4004. GDIPCONST ARGB *blend,
  4005. GDIPCONST REAL *blendPositions,
  4006. INT count
  4007. )
  4008. {
  4009. API_ENTRY(GdipSetPathGradientPresetBlend);
  4010. CheckParameter(blend);
  4011. CheckParameterValid(brush);
  4012. CheckObjectBusy(brush);
  4013. CheckParameter(count > 0);
  4014. // blend positions must start at 0.0 and end at 1.0
  4015. if (REALABS(blendPositions[0]) > REAL_EPSILON ||
  4016. REALABS(1.0f - blendPositions[count-1]) > REAL_EPSILON)
  4017. {
  4018. return InvalidParameter;
  4019. }
  4020. StackBuffer buffer;
  4021. GpColor* gpcolors = (GpColor*) buffer.GetBuffer(count*sizeof(GpColor));
  4022. if(!gpcolors) return OutOfMemory;
  4023. if(gpcolors)
  4024. {
  4025. for(INT i = 0; i < count; i++)
  4026. {
  4027. gpcolors[i].SetColor(blend[i]);
  4028. }
  4029. GpStatus status = brush->SetPresetBlend(gpcolors, blendPositions, count);
  4030. return status;
  4031. }
  4032. else
  4033. return OutOfMemory;
  4034. }
  4035. GpStatus
  4036. WINGDIPAPI
  4037. GdipSetPathGradientSigmaBlend(
  4038. GpPathGradient *brush,
  4039. REAL focus,
  4040. REAL scale
  4041. )
  4042. {
  4043. API_ENTRY(GdipSetPathGradientSigmaBlend);
  4044. CheckParameterValid(brush);
  4045. CheckObjectBusy(brush);
  4046. return brush->SetSigmaBlend(focus, scale);
  4047. }
  4048. GpStatus
  4049. WINGDIPAPI
  4050. GdipSetPathGradientLinearBlend(
  4051. GpPathGradient *brush,
  4052. REAL focus,
  4053. REAL scale
  4054. )
  4055. {
  4056. API_ENTRY(GdipSetPathGradientLinearBlend);
  4057. CheckParameterValid(brush);
  4058. CheckObjectBusy(brush);
  4059. return brush->SetLinearBlend(focus, scale);
  4060. }
  4061. GpStatus
  4062. WINGDIPAPI
  4063. GdipGetPathGradientWrapMode(
  4064. GpPathGradient *brush,
  4065. GpWrapMode *wrapmode
  4066. )
  4067. {
  4068. API_ENTRY(GdipGetPathGradientWrapMode);
  4069. CheckParameter(wrapmode);
  4070. CheckParameterValid(brush);
  4071. CheckObjectBusy(brush);
  4072. *wrapmode = (GpWrapMode)brush->GetWrapMode();
  4073. return Ok;
  4074. }
  4075. GpStatus
  4076. WINGDIPAPI
  4077. GdipSetPathGradientWrapMode(
  4078. GpPathGradient *brush,
  4079. GpWrapMode wrapmode
  4080. )
  4081. {
  4082. API_ENTRY(GdipSetPathGradientWrapMode);
  4083. CheckParameterValid(brush);
  4084. CheckObjectBusy(brush);
  4085. brush->SetWrapMode(wrapmode);
  4086. return Ok;
  4087. }
  4088. GpStatus
  4089. WINGDIPAPI
  4090. GdipGetPathGradientTransform(
  4091. GpPathGradient *brush,
  4092. GpMatrix *matrix
  4093. )
  4094. {
  4095. API_ENTRY(GdipGetPathGradientTransform);
  4096. CheckParameterValid(brush);
  4097. CheckObjectBusy(brush);
  4098. CheckParameterValid(matrix);
  4099. CheckObjectBusy(matrix);
  4100. return brush->GetTransform(matrix);
  4101. }
  4102. GpStatus
  4103. WINGDIPAPI
  4104. GdipSetPathGradientTransform(
  4105. GpPathGradient *brush,
  4106. GpMatrix *matrix
  4107. )
  4108. {
  4109. API_ENTRY(GdipSetPathGradientTransform);
  4110. CheckParameterValid(brush);
  4111. CheckObjectBusy(brush);
  4112. CheckParameterValid(matrix);
  4113. CheckObjectBusy(matrix);
  4114. return brush->SetTransform(*matrix);
  4115. }
  4116. GpStatus
  4117. WINGDIPAPI
  4118. GdipResetPathGradientTransform(
  4119. GpPathGradient* brush)
  4120. {
  4121. API_ENTRY(GdipResetPathGradientTransform);
  4122. CheckParameterValid(brush);
  4123. CheckObjectBusy(brush);
  4124. return brush->ResetTransform();
  4125. }
  4126. GpStatus
  4127. WINGDIPAPI
  4128. GdipMultiplyPathGradientTransform(
  4129. GpPathGradient* brush,
  4130. GDIPCONST GpMatrix *matrix,
  4131. GpMatrixOrder order)
  4132. {
  4133. API_ENTRY(GdipMultiplyPathGradientTransform);
  4134. if(matrix == NULL)
  4135. return Ok;
  4136. CheckParameterValid(brush);
  4137. CheckObjectBusy(brush);
  4138. CheckParameterValid(matrix);
  4139. CheckObjectBusy(matrix);
  4140. return brush->MultiplyTransform(*matrix, order);
  4141. }
  4142. GpStatus
  4143. WINGDIPAPI
  4144. GdipTranslatePathGradientTransform(
  4145. GpPathGradient* brush,
  4146. REAL dx,
  4147. REAL dy,
  4148. GpMatrixOrder order
  4149. )
  4150. {
  4151. API_ENTRY(GdipTranslatePathGradientTransform);
  4152. CheckParameterValid(brush);
  4153. CheckObjectBusy(brush);
  4154. CheckParameter(MatrixOrderIsValid(order));
  4155. return brush->TranslateTransform(dx, dy, order);
  4156. }
  4157. GpStatus
  4158. WINGDIPAPI
  4159. GdipScalePathGradientTransform(
  4160. GpPathGradient* brush,
  4161. REAL sx,
  4162. REAL sy,
  4163. GpMatrixOrder order
  4164. )
  4165. {
  4166. API_ENTRY(GdipScalePathGradientTransform);
  4167. CheckParameterValid(brush);
  4168. CheckObjectBusy(brush);
  4169. CheckParameter(MatrixOrderIsValid(order));
  4170. return brush->ScaleTransform(sx, sy, order);
  4171. }
  4172. GpStatus
  4173. WINGDIPAPI
  4174. GdipRotatePathGradientTransform(
  4175. GpPathGradient* brush,
  4176. REAL angle,
  4177. GpMatrixOrder order
  4178. )
  4179. {
  4180. API_ENTRY(GdipRotatePathGradientTransform);
  4181. CheckParameterValid(brush);
  4182. CheckObjectBusy(brush);
  4183. CheckParameter(MatrixOrderIsValid(order));
  4184. return brush->RotateTransform(angle, order);
  4185. }
  4186. GpStatus
  4187. WINGDIPAPI
  4188. GdipGetPathGradientFocusScales(
  4189. GpPathGradient *brush,
  4190. REAL* xScale,
  4191. REAL* yScale
  4192. )
  4193. {
  4194. API_ENTRY(GdipGetPathGradientFocusScales);
  4195. CheckParameterValid(brush);
  4196. CheckObjectBusy(brush);
  4197. CheckParameter(xScale);
  4198. CheckParameter(yScale);
  4199. return brush->GetFocusScales(xScale, yScale);
  4200. }
  4201. GpStatus
  4202. WINGDIPAPI
  4203. GdipSetPathGradientFocusScales(
  4204. GpPathGradient *brush,
  4205. REAL xScale,
  4206. REAL yScale
  4207. )
  4208. {
  4209. API_ENTRY(GdipSetPathGradientFocusScales);
  4210. CheckParameterValid(brush);
  4211. CheckObjectBusy(brush);
  4212. return brush->SetFocusScales(xScale, yScale);
  4213. }
  4214. GpStatus
  4215. WINGDIPAPI
  4216. GdipCreatePen1(
  4217. ARGB color,
  4218. REAL width,
  4219. GpUnit unit,
  4220. GpPen ** outPen
  4221. )
  4222. {
  4223. API_ENTRY(GdipCreatePen1);
  4224. CheckGdiplusInitialized; // We do this in all our object creation API's
  4225. CheckColorParameter(color);
  4226. CheckParameter(outPen);
  4227. // UnitDisplay is NOT valid; its only use is for Page Transforms
  4228. CheckParameter((unit >= UnitWorld) && (unit <= UnitMillimeter) && (unit != UnitDisplay));
  4229. GpPen * pen;
  4230. pen = (GpPen *) InterlockedExchangePointer((PVOID *) &Globals::PenLookAside, NULL);
  4231. if(pen == NULL)
  4232. {
  4233. pen = new GpPen(GpColor(color), width, unit);
  4234. }
  4235. else
  4236. {
  4237. pen->GetObjectLock()->Reset();
  4238. pen->Set(GpColor(color), width, unit);
  4239. }
  4240. if (CheckValid(pen))
  4241. {
  4242. *outPen = pen;
  4243. return Ok;
  4244. }
  4245. else
  4246. return OutOfMemory;
  4247. }
  4248. GpStatus
  4249. WINGDIPAPI
  4250. GdipCreatePen2(
  4251. GpBrush *brush,
  4252. REAL width,
  4253. GpUnit unit,
  4254. GpPen **pen
  4255. )
  4256. {
  4257. API_ENTRY(GdipCreatePen2);
  4258. CheckGdiplusInitialized; // We do this in all our object creation API's
  4259. CheckParameter(pen);
  4260. CheckParameterValid(brush);
  4261. CheckObjectBusy(brush);
  4262. // UnitDisplay is NOT valid; its only use is for Page Transforms
  4263. CheckParameter(
  4264. (unit >= UnitWorld) &&
  4265. (unit <= UnitMillimeter) &&
  4266. (unit != UnitDisplay)
  4267. );
  4268. *pen = new GpPen(brush, width, unit);
  4269. if (CheckValid(*pen))
  4270. return Ok;
  4271. else
  4272. return OutOfMemory;
  4273. }
  4274. GpStatus
  4275. WINGDIPAPI
  4276. GdipClonePen(
  4277. GpPen *pen,
  4278. GpPen **clonepen
  4279. )
  4280. {
  4281. API_ENTRY(GdipClonePen);
  4282. CheckParameter(clonepen);
  4283. CheckParameterValid(pen);
  4284. CheckObjectBusy(pen);
  4285. *clonepen = pen->Clone();
  4286. if (CheckValid(*clonepen))
  4287. return Ok;
  4288. else
  4289. return OutOfMemory;
  4290. }
  4291. GpStatus
  4292. WINGDIPAPI
  4293. GdipDeletePen(
  4294. GpPen *pen
  4295. )
  4296. {
  4297. API_ENTRY(GdipDeletePen);
  4298. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  4299. // the object, even if it's not in a valid state.
  4300. CheckParameter(pen);
  4301. CheckObjectBusyForDelete(pen);
  4302. // !!! [asecchia] only use the pen lookaside for solid pens.
  4303. // it turns out that if we use pens containing TextureBrushes, we require
  4304. // the stream to remain valid for the lifetime of the pen object in the
  4305. // lookaside.
  4306. if(pen->IsSolid())
  4307. {
  4308. pen = (GpPen *) InterlockedExchangePointer((PVOID *) &Globals::PenLookAside, pen);
  4309. }
  4310. if(pen != NULL)
  4311. {
  4312. delete pen;
  4313. }
  4314. return Ok;
  4315. }
  4316. GpStatus
  4317. WINGDIPAPI
  4318. GdipSetPenWidth(
  4319. GpPen *pen,
  4320. REAL width
  4321. )
  4322. {
  4323. API_ENTRY(GdipSetPenWidth);
  4324. CheckParameterValid(pen);
  4325. CheckObjectBusy(pen);
  4326. pen->SetWidth(width);
  4327. return Ok;
  4328. }
  4329. GpStatus
  4330. WINGDIPAPI
  4331. GdipGetPenWidth(
  4332. GpPen *pen,
  4333. REAL *width
  4334. )
  4335. {
  4336. API_ENTRY(GdipGetPenWidth);
  4337. CheckParameter(width);
  4338. CheckParameterValid(pen);
  4339. CheckObjectBusy(pen);
  4340. *width = pen->GetWidth();
  4341. return Ok;
  4342. }
  4343. GpStatus
  4344. WINGDIPAPI
  4345. GdipSetPenUnit(
  4346. GpPen *pen,
  4347. GpUnit unit
  4348. )
  4349. {
  4350. API_ENTRY(GdipSetPenUnit);
  4351. CheckParameterValid(pen);
  4352. CheckObjectBusy(pen);
  4353. // UnitDisplay is NOT valid; its only use is for Page Transforms
  4354. CheckParameter((unit >= UnitWorld) && (unit <= UnitMillimeter) && (unit != UnitDisplay));
  4355. pen->SetUnit(unit);
  4356. return Ok;
  4357. }
  4358. GpStatus
  4359. WINGDIPAPI
  4360. GdipGetPenUnit(
  4361. GpPen *pen,
  4362. GpUnit* unit
  4363. )
  4364. {
  4365. API_ENTRY(GdipGetPenUnit);
  4366. CheckParameter(unit);
  4367. CheckParameterValid(pen);
  4368. CheckObjectBusy(pen);
  4369. *unit = pen->GetUnit();
  4370. return Ok;
  4371. }
  4372. GpStatus
  4373. WINGDIPAPI
  4374. GdipSetPenLineCap197819(
  4375. GpPen *pen,
  4376. GpLineCap startCap,
  4377. GpLineCap endCap,
  4378. GpDashCap dashCap
  4379. )
  4380. {
  4381. API_ENTRY(GdipSetPenLineCap197819);
  4382. CheckParameterValid(pen);
  4383. CheckObjectBusy(pen);
  4384. pen->SetLineCap(startCap, endCap, dashCap);
  4385. return Ok;
  4386. }
  4387. GpStatus
  4388. WINGDIPAPI
  4389. GdipSetPenStartCap(
  4390. GpPen *pen,
  4391. GpLineCap startCap
  4392. )
  4393. {
  4394. API_ENTRY(GdipSetPenStartCap);
  4395. CheckParameterValid(pen);
  4396. CheckObjectBusy(pen);
  4397. pen->SetStartCap(startCap);
  4398. return Ok;
  4399. }
  4400. GpStatus
  4401. WINGDIPAPI
  4402. GdipSetPenEndCap(
  4403. GpPen *pen,
  4404. GpLineCap endCap
  4405. )
  4406. {
  4407. API_ENTRY(GdipSetPenEndCap);
  4408. CheckParameterValid(pen);
  4409. CheckObjectBusy(pen);
  4410. pen->SetEndCap(endCap);
  4411. return Ok;
  4412. }
  4413. GpStatus
  4414. WINGDIPAPI
  4415. GdipSetPenDashCap197819(
  4416. GpPen *pen,
  4417. GpDashCap dashCap
  4418. )
  4419. {
  4420. API_ENTRY(GdipSetPenDashCap197819);
  4421. CheckParameterValid(pen);
  4422. CheckObjectBusy(pen);
  4423. pen->SetDashCap(dashCap);
  4424. return Ok;
  4425. }
  4426. GpStatus
  4427. WINGDIPAPI
  4428. GdipGetPenStartCap(
  4429. GpPen *pen,
  4430. GpLineCap *startCap
  4431. )
  4432. {
  4433. API_ENTRY(GdipGetPenStartCap);
  4434. CheckParameter(startCap);
  4435. CheckParameterValid(pen);
  4436. CheckObjectBusy(pen);
  4437. *startCap = pen->GetStartCap();
  4438. return Ok;
  4439. }
  4440. GpStatus
  4441. WINGDIPAPI
  4442. GdipGetPenEndCap(
  4443. GpPen *pen,
  4444. GpLineCap *endCap
  4445. )
  4446. {
  4447. API_ENTRY(GdipGetPenEndCap);
  4448. CheckParameter(endCap);
  4449. CheckParameterValid(pen);
  4450. CheckObjectBusy(pen);
  4451. *endCap = pen->GetEndCap();
  4452. return Ok;
  4453. }
  4454. GpStatus
  4455. WINGDIPAPI
  4456. GdipGetPenDashCap197819(
  4457. GpPen *pen,
  4458. GpDashCap *dashCap
  4459. )
  4460. {
  4461. API_ENTRY(GdipGetPenDashCap197819);
  4462. CheckParameter(dashCap);
  4463. CheckParameterValid(pen);
  4464. CheckObjectBusy(pen);
  4465. *dashCap = pen->GetDashCap();
  4466. return Ok;
  4467. }
  4468. GpStatus
  4469. WINGDIPAPI
  4470. GdipSetPenLineJoin(
  4471. GpPen *pen,
  4472. GpLineJoin lineJoin
  4473. )
  4474. {
  4475. API_ENTRY(GdipSetPenLineJoin);
  4476. CheckParameterValid(pen);
  4477. CheckObjectBusy(pen);
  4478. pen->SetLineJoin(lineJoin);
  4479. return Ok;
  4480. }
  4481. GpStatus
  4482. WINGDIPAPI
  4483. GdipGetPenLineJoin(
  4484. GpPen *pen,
  4485. GpLineJoin *lineJoin
  4486. )
  4487. {
  4488. API_ENTRY(GdipGetPenLineJoin);
  4489. CheckParameter(lineJoin);
  4490. CheckParameterValid(pen);
  4491. CheckObjectBusy(pen);
  4492. *lineJoin = pen->GetLineJoin();
  4493. return Ok;
  4494. }
  4495. GpStatus
  4496. WINGDIPAPI
  4497. GdipSetPenCustomStartCap(
  4498. GpPen *pen,
  4499. GpCustomLineCap* customCap
  4500. )
  4501. {
  4502. API_ENTRY(GdipSetPenCustomStartCap);
  4503. CheckParameterValid(customCap);
  4504. CheckObjectBusy(customCap);
  4505. CheckParameterValid(pen);
  4506. CheckObjectBusy(pen);
  4507. return pen->SetCustomStartCap(customCap);
  4508. }
  4509. GpStatus
  4510. WINGDIPAPI
  4511. GdipGetPenCustomStartCap(
  4512. GpPen *pen,
  4513. GpCustomLineCap** customCap
  4514. )
  4515. {
  4516. API_ENTRY(GdipGetPenCustomStartCap);
  4517. CheckParameter(customCap);
  4518. CheckParameterValid(pen);
  4519. CheckObjectBusy(pen);
  4520. return pen->GetCustomStartCap(customCap);
  4521. }
  4522. GpStatus
  4523. WINGDIPAPI
  4524. GdipSetPenCustomEndCap(
  4525. GpPen *pen,
  4526. GpCustomLineCap* customCap
  4527. )
  4528. {
  4529. API_ENTRY(GdipSetPenCustomEndCap);
  4530. CheckParameterValid(customCap);
  4531. CheckObjectBusy(customCap);
  4532. CheckParameterValid(pen);
  4533. CheckObjectBusy(pen);
  4534. return pen->SetCustomEndCap(customCap);
  4535. }
  4536. GpStatus
  4537. WINGDIPAPI
  4538. GdipGetPenCustomEndCap(
  4539. GpPen *pen,
  4540. GpCustomLineCap** customCap
  4541. )
  4542. {
  4543. API_ENTRY(GdipGetPenCustomEndCap);
  4544. CheckParameter(customCap);
  4545. CheckParameterValid(pen);
  4546. CheckObjectBusy(pen);
  4547. return pen->GetCustomEndCap(customCap);
  4548. }
  4549. GpStatus
  4550. WINGDIPAPI
  4551. GdipSetPenMiterLimit(
  4552. GpPen *pen,
  4553. REAL miterLimit
  4554. )
  4555. {
  4556. API_ENTRY(GdipSetPenMiterLimit);
  4557. CheckParameterValid(pen);
  4558. CheckObjectBusy(pen);
  4559. pen->SetMiterLimit(miterLimit);
  4560. return Ok;
  4561. }
  4562. GpStatus
  4563. WINGDIPAPI
  4564. GdipGetPenMiterLimit(
  4565. GpPen *pen,
  4566. REAL *miterLimit
  4567. )
  4568. {
  4569. API_ENTRY(GdipGetPenMiterLimit);
  4570. CheckParameter(miterLimit);
  4571. CheckParameterValid(pen);
  4572. CheckObjectBusy(pen);
  4573. *miterLimit = pen->GetMiterLimit();
  4574. return Ok;
  4575. }
  4576. GpStatus
  4577. WINGDIPAPI
  4578. GdipSetPenMode(
  4579. GpPen *pen,
  4580. GpPenAlignment penMode
  4581. )
  4582. {
  4583. API_ENTRY(GdipSetPenMode);
  4584. CheckParameterValid(pen);
  4585. CheckObjectBusy(pen);
  4586. return pen->SetPenAlignment(penMode);
  4587. }
  4588. GpStatus
  4589. WINGDIPAPI
  4590. GdipGetPenMode(
  4591. GpPen *pen,
  4592. GpPenAlignment *penMode
  4593. )
  4594. {
  4595. API_ENTRY(GdipGetPenMode);
  4596. CheckParameter(penMode);
  4597. CheckParameterValid(pen);
  4598. CheckObjectBusy(pen);
  4599. *penMode = pen->GetPenAlignment();
  4600. return Ok;
  4601. }
  4602. GpStatus
  4603. WINGDIPAPI
  4604. GdipSetPenTransform(
  4605. GpPen *pen,
  4606. GpMatrix *matrix
  4607. )
  4608. {
  4609. API_ENTRY(GdipSetPenTransform);
  4610. CheckParameterValid(pen);
  4611. CheckObjectBusy(pen);
  4612. CheckParameterValid(matrix);
  4613. CheckObjectBusy(matrix);
  4614. return pen->SetTransform(*matrix);
  4615. }
  4616. GpStatus
  4617. WINGDIPAPI
  4618. GdipGetPenTransform(
  4619. GpPen *pen,
  4620. GpMatrix *matrix
  4621. )
  4622. {
  4623. API_ENTRY(GdipGetPenTransform);
  4624. CheckParameterValid(pen);
  4625. CheckObjectBusy(pen);
  4626. CheckParameterValid(matrix);
  4627. CheckObjectBusy(matrix);
  4628. return pen->GetTransform(matrix);
  4629. }
  4630. GpStatus
  4631. WINGDIPAPI
  4632. GdipResetPenTransform(
  4633. GpPen *pen)
  4634. {
  4635. API_ENTRY(GdipResetPenTransform);
  4636. CheckParameterValid(pen);
  4637. CheckObjectBusy(pen);
  4638. return pen->ResetTransform();
  4639. }
  4640. GpStatus
  4641. WINGDIPAPI
  4642. GdipMultiplyPenTransform(
  4643. GpPen *pen,
  4644. GDIPCONST GpMatrix *matrix,
  4645. GpMatrixOrder order)
  4646. {
  4647. API_ENTRY(GdipMultiplyPenTransform);
  4648. if(matrix == NULL)
  4649. return Ok;
  4650. CheckParameterValid(pen);
  4651. CheckObjectBusy(pen);
  4652. CheckParameterValid(matrix);
  4653. CheckObjectBusy(matrix);
  4654. return pen->MultiplyTransform(*matrix, order);
  4655. }
  4656. GpStatus
  4657. WINGDIPAPI
  4658. GdipTranslatePenTransform(
  4659. GpPen* pen,
  4660. REAL dx,
  4661. REAL dy,
  4662. GpMatrixOrder order
  4663. )
  4664. {
  4665. API_ENTRY(GdipTranslatePenTransform);
  4666. CheckParameterValid(pen);
  4667. CheckObjectBusy(pen);
  4668. CheckParameter(MatrixOrderIsValid(order));
  4669. return pen->TranslateTransform(dx, dy, order);
  4670. }
  4671. GpStatus
  4672. WINGDIPAPI
  4673. GdipScalePenTransform(
  4674. GpPen* pen,
  4675. REAL sx,
  4676. REAL sy,
  4677. GpMatrixOrder order
  4678. )
  4679. {
  4680. API_ENTRY(GdipScalePenTransform);
  4681. CheckParameterValid(pen);
  4682. CheckObjectBusy(pen);
  4683. CheckParameter(MatrixOrderIsValid(order));
  4684. return pen->ScaleTransform(sx, sy, order);
  4685. }
  4686. GpStatus
  4687. WINGDIPAPI
  4688. GdipRotatePenTransform(
  4689. GpPen* pen,
  4690. REAL angle,
  4691. GpMatrixOrder order
  4692. )
  4693. {
  4694. API_ENTRY(GdipRotatePenTransform);
  4695. CheckParameterValid(pen);
  4696. CheckObjectBusy(pen);
  4697. CheckParameter(MatrixOrderIsValid(order));
  4698. return pen->RotateTransform(angle, order);
  4699. }
  4700. GpStatus
  4701. WINGDIPAPI
  4702. GdipSetPenColor(
  4703. GpPen *pen,
  4704. ARGB argb
  4705. )
  4706. {
  4707. API_ENTRY(GdipSetPenColor);
  4708. CheckColorParameter(argb);
  4709. CheckParameterValid(pen);
  4710. CheckObjectBusy(pen);
  4711. GpColor color(argb);
  4712. return pen->SetColor(&color);
  4713. }
  4714. GpStatus
  4715. WINGDIPAPI
  4716. GdipGetPenColor(
  4717. GpPen *pen,
  4718. ARGB *argb
  4719. )
  4720. {
  4721. API_ENTRY(GdipGetPenColor);
  4722. CheckParameter(argb);
  4723. CheckParameterValid(pen);
  4724. CheckObjectBusy(pen);
  4725. ARGB temp;
  4726. Status status = pen->GetColor(&temp);
  4727. *argb = temp;
  4728. return status;
  4729. }
  4730. GpStatus
  4731. WINGDIPAPI
  4732. GdipSetPenBrushFill(
  4733. GpPen *pen,
  4734. GpBrush *brush
  4735. )
  4736. {
  4737. API_ENTRY(GdipSetPenBrushFill);
  4738. CheckParameterValid(pen);
  4739. CheckObjectBusy(pen);
  4740. CheckParameterValid(brush);
  4741. CheckObjectBusy(brush);
  4742. return pen->SetBrush(brush);
  4743. }
  4744. GpStatus
  4745. WINGDIPAPI
  4746. GdipGetPenBrushFill(
  4747. GpPen *pen,
  4748. GpBrush **brush
  4749. )
  4750. {
  4751. API_ENTRY(GdipGetPenBrushFill);
  4752. CheckParameterValid(pen);
  4753. CheckObjectBusy(pen);
  4754. CheckParameter(brush);
  4755. *brush = pen->GetClonedBrush();
  4756. return Ok;
  4757. }
  4758. GpStatus
  4759. WINGDIPAPI
  4760. GdipGetPenFillType(
  4761. GpPen *pen,
  4762. GpPenType* type
  4763. )
  4764. {
  4765. API_ENTRY(GdipGetPenFillType);
  4766. CheckParameterValid(pen);
  4767. CheckObjectBusy(pen);
  4768. CheckParameter(type);
  4769. *type = pen->GetPenType();
  4770. return Ok;
  4771. }
  4772. GpStatus
  4773. WINGDIPAPI
  4774. GdipGetPenDashStyle(
  4775. GpPen *pen,
  4776. GpDashStyle *dashstyle
  4777. )
  4778. {
  4779. API_ENTRY(GdipGetPenDashStyle);
  4780. CheckParameter(dashstyle);
  4781. CheckParameterValid(pen);
  4782. CheckObjectBusy(pen);
  4783. *dashstyle = (GpDashStyle)pen->GetDashStyle();
  4784. return Ok;
  4785. }
  4786. GpStatus
  4787. WINGDIPAPI
  4788. GdipSetPenDashStyle(
  4789. GpPen *pen,
  4790. GpDashStyle dashstyle
  4791. )
  4792. {
  4793. API_ENTRY(GdipSetPenDashStyle);
  4794. CheckParameterValid(pen);
  4795. CheckObjectBusy(pen);
  4796. pen->SetDashStyle(dashstyle);
  4797. return Ok;
  4798. }
  4799. GpStatus
  4800. WINGDIPAPI
  4801. GdipGetPenDashOffset(
  4802. GpPen *pen,
  4803. REAL *offset
  4804. )
  4805. {
  4806. API_ENTRY(GdipGetPenDashOffset);
  4807. CheckParameter(offset);
  4808. CheckParameterValid(pen);
  4809. CheckObjectBusy(pen);
  4810. *offset = pen->GetDashOffset();
  4811. return Ok;
  4812. }
  4813. GpStatus
  4814. WINGDIPAPI
  4815. GdipSetPenDashOffset(
  4816. GpPen *pen,
  4817. REAL offset
  4818. )
  4819. {
  4820. API_ENTRY(GdipSetPenDashOffset);
  4821. CheckParameterValid(pen);
  4822. CheckObjectBusy(pen);
  4823. pen->SetDashOffset(offset);
  4824. return Ok;
  4825. }
  4826. GpStatus
  4827. WINGDIPAPI
  4828. GdipGetPenDashCount(
  4829. GpPen *pen,
  4830. INT *count
  4831. )
  4832. {
  4833. API_ENTRY(GdipGetPenDashCount);
  4834. CheckParameter(count);
  4835. CheckParameterValid(pen);
  4836. CheckObjectBusy(pen);
  4837. *count = pen->GetDashCount();
  4838. return Ok;
  4839. }
  4840. GpStatus
  4841. WINGDIPAPI
  4842. GdipSetPenDashArray(
  4843. GpPen *pen,
  4844. GDIPCONST REAL *dash,
  4845. INT count
  4846. )
  4847. {
  4848. API_ENTRY(GdipSetPenDashArray);
  4849. CheckParameter(dash);
  4850. CheckParameterValid(pen);
  4851. CheckObjectBusy(pen);
  4852. return pen->SetDashArray(dash, count);
  4853. }
  4854. GpStatus
  4855. WINGDIPAPI
  4856. GdipGetPenDashArray(
  4857. GpPen *pen,
  4858. REAL *dash,
  4859. INT count
  4860. )
  4861. {
  4862. API_ENTRY(GdipGetPenDashArray);
  4863. CheckParameter(dash);
  4864. CheckParameterValid(pen);
  4865. CheckObjectBusy(pen);
  4866. return pen->GetDashArray(dash, count);
  4867. }
  4868. GpStatus
  4869. WINGDIPAPI
  4870. GdipGetPenCompoundCount(
  4871. GpPen *pen,
  4872. INT *count
  4873. )
  4874. {
  4875. API_ENTRY(GdipGetPenCompoundCount);
  4876. CheckParameter(count);
  4877. CheckParameterValid(pen);
  4878. CheckObjectBusy(pen);
  4879. *count = pen->GetCompoundCount();
  4880. return Ok;
  4881. }
  4882. GpStatus
  4883. WINGDIPAPI
  4884. GdipSetPenCompoundArray(
  4885. GpPen *pen,
  4886. GDIPCONST REAL *compoundArray,
  4887. INT count
  4888. )
  4889. {
  4890. API_ENTRY(GdipSetPenCompoundArray);
  4891. CheckParameter(compoundArray);
  4892. CheckParameterValid(pen);
  4893. CheckObjectBusy(pen);
  4894. return pen->SetCompoundArray(compoundArray, count);
  4895. }
  4896. GpStatus
  4897. WINGDIPAPI
  4898. GdipGetPenCompoundArray(
  4899. GpPen *pen,
  4900. REAL *compoundArray,
  4901. INT count
  4902. )
  4903. {
  4904. API_ENTRY(GdipGetPenCompoundArray);
  4905. CheckParameter(compoundArray);
  4906. CheckParameterValid(pen);
  4907. CheckObjectBusy(pen);
  4908. return pen->GetCompoundArray(compoundArray, count);
  4909. }
  4910. GpStatus
  4911. WINGDIPAPI
  4912. GdipCreateCustomLineCap(
  4913. GpPath* fillPath,
  4914. GpPath* strokePath,
  4915. GpLineCap baseCap,
  4916. REAL baseInset,
  4917. GpCustomLineCap **customCap
  4918. )
  4919. {
  4920. API_ENTRY(GdipCreateCustomLineCap);
  4921. CheckGdiplusInitialized; // We do this in all our object creation API's
  4922. // fillPath or strokePath can be NULL.
  4923. CheckParameter(customCap);
  4924. CheckParameter((fillPath != NULL) || (strokePath != NULL));
  4925. CheckOptionalParameterValid(fillPath);
  4926. CheckOptionalObjectBusy(fillPath);
  4927. CheckOptionalParameterValid(strokePath);
  4928. CheckOptionalObjectBusy(strokePath);
  4929. *customCap = new GpCustomLineCap(fillPath, strokePath, baseCap, baseInset);
  4930. if (*customCap)
  4931. {
  4932. if((*customCap)->IsValid())
  4933. {
  4934. return Ok;
  4935. }
  4936. // This failed to create correctly. Retrieve the failure code.
  4937. GpStatus status = (*customCap)->GetCreationStatus();
  4938. delete *customCap;
  4939. *customCap = NULL;
  4940. return status;
  4941. }
  4942. else
  4943. {
  4944. return OutOfMemory;
  4945. }
  4946. }
  4947. GpStatus
  4948. WINGDIPAPI
  4949. GdipCloneCustomLineCap(
  4950. GpCustomLineCap *customCap,
  4951. GpCustomLineCap **newCustomCap
  4952. )
  4953. {
  4954. API_ENTRY(GdipCloneCustomLineCap);
  4955. CheckParameterValid(customCap);
  4956. CheckObjectBusy(customCap);
  4957. *newCustomCap = customCap->Clone();
  4958. if (*newCustomCap)
  4959. {
  4960. if((*newCustomCap)->IsValid())
  4961. {
  4962. return Ok;
  4963. }
  4964. // This failed to create correctly. Retrieve the failure code.
  4965. GpStatus status = (*newCustomCap)->GetCreationStatus();
  4966. delete *newCustomCap;
  4967. *newCustomCap = NULL;
  4968. return status;
  4969. }
  4970. else
  4971. {
  4972. return OutOfMemory;
  4973. }
  4974. }
  4975. GpStatus
  4976. WINGDIPAPI
  4977. GdipGetCustomLineCapType(
  4978. GpCustomLineCap* customCap,
  4979. CustomLineCapType* type
  4980. )
  4981. {
  4982. API_ENTRY(GdipGetCustomLineCapType);
  4983. CheckParameter(type);
  4984. CheckParameterValid(customCap);
  4985. CheckObjectBusy(customCap);
  4986. *type = customCap->GetType();
  4987. return Ok;
  4988. }
  4989. GpStatus
  4990. WINGDIPAPI
  4991. GdipDeleteCustomLineCap(
  4992. GpCustomLineCap* customCap
  4993. )
  4994. {
  4995. API_ENTRY(GdipDeleteCustomLineCap);
  4996. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  4997. // the object, even if it's not in a valid state.
  4998. CheckParameter(customCap);
  4999. CheckObjectBusyForDelete(customCap);
  5000. delete customCap;
  5001. return Ok;
  5002. }
  5003. GpStatus
  5004. WINGDIPAPI
  5005. GdipSetCustomLineCapStrokeCaps(
  5006. GpCustomLineCap* customCap,
  5007. GpLineCap startCap,
  5008. GpLineCap endCap)
  5009. {
  5010. API_ENTRY(GdipSetCustomLineCapStrokeCaps);
  5011. CheckParameterValid(customCap);
  5012. CheckObjectBusy(customCap);
  5013. return customCap->SetStrokeCaps(startCap, endCap);
  5014. }
  5015. GpStatus
  5016. WINGDIPAPI
  5017. GdipGetCustomLineCapStrokeCaps(
  5018. GpCustomLineCap* customCap,
  5019. GpLineCap* startCap,
  5020. GpLineCap* endCap
  5021. )
  5022. {
  5023. API_ENTRY(GdipGetCustomLineCapStrokeCaps);
  5024. CheckParameterValid(customCap);
  5025. CheckObjectBusy(customCap);
  5026. CheckParameter(startCap);
  5027. CheckParameter(endCap);
  5028. return customCap->GetStrokeCaps(startCap, endCap);
  5029. }
  5030. GpStatus
  5031. WINGDIPAPI
  5032. GdipSetCustomLineCapStrokeJoin(
  5033. GpCustomLineCap* customCap,
  5034. GpLineJoin lineJoin
  5035. )
  5036. {
  5037. API_ENTRY(GdipSetCustomLineCapStrokeJoin);
  5038. CheckParameterValid(customCap);
  5039. CheckObjectBusy(customCap);
  5040. return customCap->SetStrokeJoin(lineJoin);
  5041. }
  5042. GpStatus
  5043. WINGDIPAPI
  5044. GdipGetCustomLineCapStrokeJoin(
  5045. GpCustomLineCap* customCap,
  5046. GpLineJoin* lineJoin
  5047. )
  5048. {
  5049. API_ENTRY(GdipGetCustomLineCapStrokeJoin);
  5050. CheckParameterValid(customCap);
  5051. CheckObjectBusy(customCap);
  5052. CheckParameter(lineJoin);
  5053. return customCap->GetStrokeJoin(lineJoin);
  5054. }
  5055. GpStatus
  5056. WINGDIPAPI
  5057. GdipSetCustomLineCapBaseCap(
  5058. GpCustomLineCap* customCap,
  5059. GpLineCap baseCap
  5060. )
  5061. {
  5062. API_ENTRY(GdipSetCustomLineCapBaseCap);
  5063. CheckParameterValid(customCap);
  5064. CheckObjectBusy(customCap);
  5065. return customCap->SetBaseCap(baseCap);
  5066. }
  5067. GpStatus
  5068. WINGDIPAPI
  5069. GdipGetCustomLineCapBaseCap(
  5070. GpCustomLineCap* customCap,
  5071. GpLineCap* baseCap
  5072. )
  5073. {
  5074. API_ENTRY(GdipGetCustomLineCapBaseCap);
  5075. CheckParameterValid(customCap);
  5076. CheckObjectBusy(customCap);
  5077. CheckParameter(baseCap);
  5078. return customCap->GetBaseCap(baseCap);
  5079. }
  5080. GpStatus
  5081. WINGDIPAPI
  5082. GdipSetCustomLineCapBaseInset(
  5083. GpCustomLineCap* customCap,
  5084. REAL inset
  5085. )
  5086. {
  5087. API_ENTRY(GdipSetCustomLineCapBaseInset);
  5088. CheckParameterValid(customCap);
  5089. CheckObjectBusy(customCap);
  5090. return customCap->SetBaseInset(inset);
  5091. }
  5092. GpStatus
  5093. WINGDIPAPI
  5094. GdipGetCustomLineCapBaseInset(
  5095. GpCustomLineCap* customCap,
  5096. REAL* inset
  5097. )
  5098. {
  5099. API_ENTRY(GdipGetCustomLineCapBaseInset);
  5100. CheckParameterValid(customCap);
  5101. CheckObjectBusy(customCap);
  5102. CheckParameter(inset);
  5103. return customCap->GetBaseInset(inset);
  5104. }
  5105. GpStatus
  5106. WINGDIPAPI
  5107. GdipSetCustomLineCapWidthScale(
  5108. GpCustomLineCap* customCap,
  5109. REAL widthScale
  5110. )
  5111. {
  5112. API_ENTRY(GdipSetCustomLineCapWidthScale);
  5113. CheckParameterValid(customCap);
  5114. CheckObjectBusy(customCap);
  5115. return customCap->SetWidthScale(widthScale);
  5116. }
  5117. GpStatus WINGDIPAPI
  5118. GdipGetCustomLineCapWidthScale(
  5119. GpCustomLineCap* customCap,
  5120. REAL* widthScale
  5121. )
  5122. {
  5123. API_ENTRY(GdipGetCustomLineCapWidthScale);
  5124. CheckParameterValid(customCap);
  5125. CheckObjectBusy(customCap);
  5126. CheckParameter(widthScale);
  5127. return customCap->GetWidthScale(widthScale);
  5128. }
  5129. GpStatus
  5130. WINGDIPAPI
  5131. GdipCreateAdjustableArrowCap(
  5132. REAL height,
  5133. REAL width,
  5134. BOOL isFilled,
  5135. GpAdjustableArrowCap **cap)
  5136. {
  5137. API_ENTRY(GdipCreateAdjustableArrowCap);
  5138. CheckGdiplusInitialized; // We do this in all our object creation API's
  5139. CheckParameter(cap);
  5140. *cap = new GpAdjustableArrowCap(height, width, isFilled);
  5141. if(*cap)
  5142. return Ok;
  5143. else
  5144. return OutOfMemory;
  5145. }
  5146. GpStatus
  5147. WINGDIPAPI
  5148. GdipSetAdjustableArrowCapHeight(
  5149. GpAdjustableArrowCap* cap,
  5150. REAL height
  5151. )
  5152. {
  5153. API_ENTRY(GdipSetAdjustableArrowCapHeight);
  5154. CheckParameterValid(cap);
  5155. CheckObjectBusy(cap);
  5156. return cap->SetHeight(height);
  5157. }
  5158. GpStatus
  5159. WINGDIPAPI
  5160. GdipGetAdjustableArrowCapHeight(
  5161. GpAdjustableArrowCap* cap,
  5162. REAL* height
  5163. )
  5164. {
  5165. API_ENTRY(GdipGetAdjustableArrowCapHeight);
  5166. CheckParameterValid(cap);
  5167. CheckObjectBusy(cap);
  5168. CheckParameter(height);
  5169. *height = cap->GetHeight();
  5170. return Ok;
  5171. }
  5172. GpStatus
  5173. WINGDIPAPI
  5174. GdipSetAdjustableArrowCapWidth(
  5175. GpAdjustableArrowCap* cap,
  5176. REAL width
  5177. )
  5178. {
  5179. API_ENTRY(GdipSetAdjustableArrowCapWidth);
  5180. CheckParameterValid(cap);
  5181. CheckObjectBusy(cap);
  5182. return cap->SetWidth(width);
  5183. }
  5184. GpStatus
  5185. WINGDIPAPI
  5186. GdipGetAdjustableArrowCapWidth(
  5187. GpAdjustableArrowCap* cap,
  5188. REAL* width
  5189. )
  5190. {
  5191. API_ENTRY(GdipGetAdjustableArrowCapWidth);
  5192. CheckParameterValid(cap);
  5193. CheckObjectBusy(cap);
  5194. CheckParameter(width);
  5195. *width = cap->GetWidth();
  5196. return Ok;
  5197. }
  5198. GpStatus
  5199. WINGDIPAPI
  5200. GdipSetAdjustableArrowCapMiddleInset(
  5201. GpAdjustableArrowCap* cap,
  5202. REAL middleInset
  5203. )
  5204. {
  5205. API_ENTRY(GdipSetAdjustableArrowCapMiddleInset);
  5206. CheckParameterValid(cap);
  5207. CheckObjectBusy(cap);
  5208. return cap->SetMiddleInset(middleInset);
  5209. }
  5210. GpStatus
  5211. WINGDIPAPI
  5212. GdipGetAdjustableArrowCapMiddleInset(
  5213. GpAdjustableArrowCap* cap,
  5214. REAL* middleInset
  5215. )
  5216. {
  5217. API_ENTRY(GdipGetAdjustableArrowCapMiddleInset);
  5218. CheckParameterValid(cap);
  5219. CheckObjectBusy(cap);
  5220. CheckParameter(middleInset);
  5221. *middleInset = cap->GetMiddleInset();
  5222. return Ok;
  5223. }
  5224. GpStatus
  5225. WINGDIPAPI
  5226. GdipSetAdjustableArrowCapFillState(
  5227. GpAdjustableArrowCap* cap,
  5228. BOOL fillState
  5229. )
  5230. {
  5231. API_ENTRY(GdipSetAdjustableArrowCapFillState);
  5232. CheckParameterValid(cap);
  5233. CheckObjectBusy(cap);
  5234. return cap->SetFillState(fillState);
  5235. }
  5236. GpStatus
  5237. WINGDIPAPI
  5238. GdipGetAdjustableArrowCapFillState(
  5239. GpAdjustableArrowCap* cap,
  5240. BOOL* fillState
  5241. )
  5242. {
  5243. API_ENTRY(GdipGetAdjustableArrowCapFillState);
  5244. CheckParameterValid(cap);
  5245. CheckObjectBusy(cap);
  5246. CheckParameter(fillState);
  5247. *fillState = cap->IsFilled();
  5248. return Ok;
  5249. }
  5250. GpStatus
  5251. WINGDIPAPI
  5252. GdipLoadImageFromStream(
  5253. IStream* stream,
  5254. GpImage **image
  5255. )
  5256. {
  5257. API_ENTRY(GdipLoadImageFromStream);
  5258. CheckParameter(image && stream);
  5259. *image = GpImage::LoadImage(stream);
  5260. // !!! Can't use CheckValid() since destructor is protected.
  5261. if (*image)
  5262. {
  5263. if ((*image)->IsValid())
  5264. {
  5265. (*image)->SetICMConvert(FALSE);
  5266. return Ok;
  5267. }
  5268. (*image)->Dispose();
  5269. *image = NULL;
  5270. return InvalidParameter;
  5271. }
  5272. return OutOfMemory;
  5273. }
  5274. GpStatus
  5275. WINGDIPAPI
  5276. GdipLoadImageFromFile(
  5277. GDIPCONST WCHAR* filename,
  5278. GpImage** image
  5279. )
  5280. {
  5281. API_ENTRY(GdipLoadImageFromFile);
  5282. CheckParameter(image && filename);
  5283. *image = GpImage::LoadImage(filename);
  5284. if (*image)
  5285. {
  5286. if ((*image)->IsValid())
  5287. {
  5288. (*image)->SetICMConvert(FALSE);
  5289. return Ok;
  5290. }
  5291. (*image)->Dispose();
  5292. *image = NULL;
  5293. return InvalidParameter;
  5294. }
  5295. return OutOfMemory;
  5296. }
  5297. GpStatus
  5298. WINGDIPAPI
  5299. GdipLoadImageFromStreamICM(
  5300. IStream* stream,
  5301. GpImage **image
  5302. )
  5303. {
  5304. API_ENTRY(GdipLoadImageFromStreamICM);
  5305. CheckParameter(image && stream);
  5306. *image = GpImage::LoadImage(stream);
  5307. // !!! Can't use CheckValid() since destructor is protected.
  5308. if (*image)
  5309. {
  5310. if ((*image)->IsValid())
  5311. {
  5312. (*image)->SetICMConvert(TRUE);
  5313. return Ok;
  5314. }
  5315. (*image)->Dispose();
  5316. *image = NULL;
  5317. return InvalidParameter;
  5318. }
  5319. return OutOfMemory;
  5320. }
  5321. GpStatus
  5322. WINGDIPAPI
  5323. GdipLoadImageFromFileICM(
  5324. GDIPCONST WCHAR* filename,
  5325. GpImage** image
  5326. )
  5327. {
  5328. API_ENTRY(GdipLoadImageFromFileICM);
  5329. CheckParameter(image && filename);
  5330. *image = GpImage::LoadImage(filename);
  5331. if (*image)
  5332. {
  5333. if ((*image)->IsValid())
  5334. {
  5335. (*image)->SetICMConvert(TRUE);
  5336. return Ok;
  5337. }
  5338. (*image)->Dispose();
  5339. *image = NULL;
  5340. return InvalidParameter;
  5341. }
  5342. return OutOfMemory;
  5343. }
  5344. GpStatus
  5345. WINGDIPAPI
  5346. GdipGetEncoderParameterListSize(
  5347. GpImage *image,
  5348. GDIPCONST CLSID *clsidEncoder,
  5349. UINT *size
  5350. )
  5351. {
  5352. API_ENTRY(GdipGetEncoderParameterListSize);
  5353. CheckParameter(image && clsidEncoder);
  5354. CheckObjectBusy(image);
  5355. return image->GetEncoderParameterListSize(const_cast<CLSID*>(clsidEncoder), size);
  5356. }
  5357. GpStatus
  5358. WINGDIPAPI
  5359. GdipGetEncoderParameterList(
  5360. GpImage *image,
  5361. GDIPCONST CLSID *clsidEncoder,
  5362. UINT size,
  5363. EncoderParameters *buffer
  5364. )
  5365. {
  5366. API_ENTRY(GdipGetEncoderParameterList);
  5367. CheckParameter(image && clsidEncoder);
  5368. CheckObjectBusy(image);
  5369. return image->GetEncoderParameterList(const_cast<CLSID*>(clsidEncoder), size, buffer);
  5370. }
  5371. GpStatus
  5372. WINGDIPAPI
  5373. GdipSaveImageToStream(
  5374. GpImage *image,
  5375. IStream* stream,
  5376. GDIPCONST CLSID* clsidEncoder,
  5377. GDIPCONST EncoderParameters* encoderParams
  5378. )
  5379. {
  5380. API_ENTRY(GdipSaveImageToStream);
  5381. CheckParameter(image && stream && clsidEncoder);
  5382. CheckObjectBusy(image);
  5383. return image->SaveToStream(stream,
  5384. const_cast<CLSID*>(clsidEncoder),
  5385. const_cast<EncoderParameters*>(encoderParams));
  5386. }
  5387. GpStatus
  5388. WINGDIPAPI
  5389. GdipSaveImageToFile(
  5390. GpImage *image,
  5391. GDIPCONST WCHAR* filename,
  5392. GDIPCONST CLSID* clsidEncoder,
  5393. GDIPCONST EncoderParameters* encoderParams
  5394. )
  5395. {
  5396. API_ENTRY(GdipSaveImageToFile);
  5397. CheckParameter(image && filename && clsidEncoder);
  5398. CheckObjectBusy(image);
  5399. return image->SaveToFile(filename,
  5400. const_cast<CLSID*>(clsidEncoder),
  5401. const_cast<EncoderParameters*>(encoderParams));
  5402. }
  5403. GpStatus
  5404. WINGDIPAPI
  5405. GdipSaveAdd(
  5406. GpImage *image,
  5407. GDIPCONST EncoderParameters* encoderParams
  5408. )
  5409. {
  5410. API_ENTRY(GdipSaveAdd);
  5411. CheckParameter(image && encoderParams);
  5412. CheckObjectBusy(image);
  5413. return image->SaveAdd(const_cast<EncoderParameters*>(encoderParams));
  5414. }
  5415. GpStatus
  5416. WINGDIPAPI
  5417. GdipSaveAddImage(
  5418. GpImage* image,
  5419. GpImage* newImage,
  5420. GDIPCONST EncoderParameters* encoderParams
  5421. )
  5422. {
  5423. API_ENTRY(GdipSaveAddImage);
  5424. CheckParameter(image && newImage && encoderParams);
  5425. CheckObjectBusy(image);
  5426. return image->SaveAdd(newImage, const_cast<EncoderParameters*>(encoderParams));
  5427. }
  5428. GpStatus
  5429. WINGDIPAPI
  5430. GdipImageGetFrameDimensionsCount(
  5431. GpImage* image,
  5432. UINT* count
  5433. )
  5434. {
  5435. API_ENTRY(GdipImageGetFrameDimensionsCount);
  5436. CheckParameter(image);
  5437. CheckObjectBusy(image);
  5438. return image->GetFrameDimensionsCount(count);
  5439. }
  5440. GpStatus
  5441. WINGDIPAPI
  5442. GdipImageGetFrameDimensionsList(
  5443. GpImage* image,
  5444. GUID* dimensionIDs,
  5445. UINT count
  5446. )
  5447. {
  5448. API_ENTRY(GdipImageGetFrameDimensionsList);
  5449. CheckParameter(image);
  5450. CheckObjectBusy(image);
  5451. return image->GetFrameDimensionsList(dimensionIDs, count);
  5452. }
  5453. GpStatus
  5454. WINGDIPAPI
  5455. GdipImageGetFrameCount(
  5456. GpImage* image,
  5457. GDIPCONST GUID* dimensionID,
  5458. UINT* count
  5459. )
  5460. {
  5461. API_ENTRY(GdipImageGetFrameCount);
  5462. CheckParameter(image);
  5463. CheckObjectBusy(image);
  5464. return image->GetFrameCount(dimensionID, count);
  5465. }
  5466. GpStatus
  5467. WINGDIPAPI
  5468. GdipImageSelectActiveFrame(
  5469. GpImage* image,
  5470. GDIPCONST GUID* dimensionID,
  5471. UINT frameIndex
  5472. )
  5473. {
  5474. API_ENTRY(GdipImageSelectActiveFrame);
  5475. CheckParameter(image);
  5476. CheckObjectBusy(image);
  5477. return image->SelectActiveFrame(dimensionID, frameIndex);
  5478. }
  5479. GpStatus
  5480. WINGDIPAPI
  5481. GdipImageRotateFlip(
  5482. GpImage* image,
  5483. RotateFlipType rfType
  5484. )
  5485. {
  5486. API_ENTRY(GdipImageRotateFlip);
  5487. CheckParameter(image);
  5488. CheckObjectBusy(image);
  5489. return image->RotateFlip(rfType);
  5490. }
  5491. GpStatus
  5492. WINGDIPAPI
  5493. GdipGetPropertyCount(
  5494. GpImage* image,
  5495. UINT* numOfProperty
  5496. )
  5497. {
  5498. API_ENTRY(GdipGetPropertyCount);
  5499. CheckParameter(image);
  5500. CheckObjectBusy(image);
  5501. return image->GetPropertyCount(numOfProperty);
  5502. }
  5503. GpStatus
  5504. WINGDIPAPI
  5505. GdipGetPropertyIdList(
  5506. GpImage* image,
  5507. UINT numOfProperty,
  5508. PROPID* list
  5509. )
  5510. {
  5511. API_ENTRY(GdipGetPropertyIdList);
  5512. CheckParameter(image);
  5513. CheckObjectBusy(image);
  5514. return image->GetPropertyIdList(numOfProperty, list);
  5515. }
  5516. GpStatus
  5517. WINGDIPAPI
  5518. GdipGetPropertyItemSize(
  5519. GpImage* image,
  5520. PROPID propId,
  5521. UINT* size
  5522. )
  5523. {
  5524. API_ENTRY(GdipGetPropertyItemSize);
  5525. CheckParameter(image);
  5526. CheckObjectBusy(image);
  5527. return image->GetPropertyItemSize(propId, size);
  5528. }
  5529. GpStatus
  5530. WINGDIPAPI
  5531. GdipGetPropertyItem(
  5532. GpImage* image,
  5533. PROPID propId,
  5534. UINT propSize,
  5535. PropertyItem* buffer
  5536. )
  5537. {
  5538. API_ENTRY(GdipGetPropertyItem);
  5539. CheckParameter(image);
  5540. CheckObjectBusy(image);
  5541. return image->GetPropertyItem(propId, propSize, buffer);
  5542. }
  5543. GpStatus
  5544. WINGDIPAPI
  5545. GdipGetPropertySize(
  5546. GpImage* image,
  5547. UINT* totalBufferSize,
  5548. UINT* numProperties
  5549. )
  5550. {
  5551. API_ENTRY(GdipGetPropertySize);
  5552. CheckParameter(image);
  5553. CheckObjectBusy(image);
  5554. return image->GetPropertySize(totalBufferSize, numProperties);
  5555. }
  5556. GpStatus
  5557. WINGDIPAPI
  5558. GdipGetAllPropertyItems(
  5559. GpImage* image,
  5560. UINT totalBufferSize,
  5561. UINT numProperties,
  5562. PropertyItem* allItems
  5563. )
  5564. {
  5565. API_ENTRY(GdipGetAllPropertyItems);
  5566. CheckParameter(image);
  5567. CheckObjectBusy(image);
  5568. return image->GetAllPropertyItems(totalBufferSize, numProperties, allItems);
  5569. }
  5570. GpStatus
  5571. WINGDIPAPI
  5572. GdipRemovePropertyItem(
  5573. GpImage* image,
  5574. PROPID propId
  5575. )
  5576. {
  5577. API_ENTRY(GdipRemovePropertyItem);
  5578. CheckParameter(image);
  5579. CheckObjectBusy(image);
  5580. return image->RemovePropertyItem(propId);
  5581. }
  5582. GpStatus
  5583. WINGDIPAPI
  5584. GdipSetPropertyItem(
  5585. GpImage* image,
  5586. GDIPCONST PropertyItem* item
  5587. )
  5588. {
  5589. API_ENTRY(GdipSetPropertyItem);
  5590. CheckParameter(image && item);
  5591. CheckObjectBusy(image);
  5592. return image->SetPropertyItem(const_cast<PropertyItem*>(item));
  5593. }
  5594. GpStatus
  5595. WINGDIPAPI
  5596. GdipCloneImage(
  5597. GpImage* image,
  5598. GpImage** cloneimage
  5599. )
  5600. {
  5601. API_ENTRY(GdipCloneImage);
  5602. CheckParameter(cloneimage);
  5603. CheckParameterValid(image);
  5604. CheckObjectBusy(image);
  5605. *cloneimage = image->Clone();
  5606. if (*cloneimage)
  5607. return Ok;
  5608. else
  5609. return OutOfMemory;
  5610. // !!!: There is no destructor to invoke. Leave it to Clone to
  5611. // verify correct creation.
  5612. }
  5613. GpStatus
  5614. WINGDIPAPI
  5615. GdipDisposeImage(
  5616. GpImage *image
  5617. )
  5618. {
  5619. API_ENTRY(GdipDisposeImage);
  5620. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  5621. // the object, even if it's not in a valid state.
  5622. CheckParameter(image);
  5623. if (image->GetImageType() == ImageTypeMetafile)
  5624. {
  5625. // If the user still has the graphics associated with the metafile,
  5626. // then we have to lock it, to prevent them from using it while
  5627. // we're busy deleting the metafile object. The metafile dispose
  5628. // method will set the graphics to invalid, so the only thing
  5629. // they can do with the graphics is to delete it after this call.
  5630. GpMetafile * metafile = (GpMetafile *)image;
  5631. GpGraphics * g = metafile->PrivateAPIForGettingMetafileGraphicsContext();
  5632. CheckOptionalObjectBusy(g);
  5633. CheckObjectBusyForDelete(metafile);
  5634. metafile->Dispose();
  5635. return Ok;
  5636. }
  5637. CheckObjectBusyForDelete(image);
  5638. image->Dispose();
  5639. return Ok;
  5640. }
  5641. GpStatus
  5642. WINGDIPAPI
  5643. GdipGetImageGraphicsContext(
  5644. GpImage *image,
  5645. GpGraphics **graphics
  5646. )
  5647. {
  5648. API_ENTRY(GdipGetImageGraphicsContext);
  5649. CheckParameter(graphics);
  5650. CheckParameterValid(image);
  5651. CheckObjectBusy(image);
  5652. *graphics = image->GetGraphicsContext();
  5653. if (CheckValid(*graphics))
  5654. return Ok;
  5655. else
  5656. return OutOfMemory;
  5657. }
  5658. GpStatus
  5659. WINGDIPAPI
  5660. GdipGetImageBounds(
  5661. GpImage *image,
  5662. GpRectF *srcRect,
  5663. GpPageUnit *srcUnit
  5664. )
  5665. {
  5666. API_ENTRY(GdipGetImageBounds);
  5667. CheckParameter(srcRect && srcUnit);
  5668. CheckParameterValid(image);
  5669. CheckObjectBusy(image);
  5670. return image->GetBounds(srcRect, srcUnit);
  5671. }
  5672. GpStatus
  5673. WINGDIPAPI
  5674. GdipGetImageDimension(
  5675. GpImage *image,
  5676. REAL *width,
  5677. REAL *height
  5678. )
  5679. {
  5680. API_ENTRY(GdipGetImageDimension);
  5681. CheckParameter(width && height);
  5682. CheckParameterValid(image);
  5683. CheckObjectBusy(image);
  5684. return image->GetPhysicalDimension(width, height);
  5685. }
  5686. GpStatus
  5687. WINGDIPAPI
  5688. GdipGetImageWidth(
  5689. GpImage *image,
  5690. UINT *width
  5691. )
  5692. {
  5693. API_ENTRY(GdipGetImageWidth);
  5694. CheckParameter(width);
  5695. CheckParameterValid(image);
  5696. CheckObjectBusy(image);
  5697. ImageInfo imageinfo;
  5698. GpStatus status = image->GetImageInfo(&imageinfo);
  5699. if (status == Ok)
  5700. {
  5701. *width = imageinfo.Width;
  5702. }
  5703. return status;
  5704. }
  5705. GpStatus
  5706. WINGDIPAPI
  5707. GdipGetImageHeight(
  5708. GpImage *image,
  5709. UINT *height
  5710. )
  5711. {
  5712. API_ENTRY(GdipGetImageHeight);
  5713. CheckParameter(height);
  5714. CheckParameterValid(image);
  5715. CheckObjectBusy(image);
  5716. ImageInfo imageinfo;
  5717. GpStatus status = image->GetImageInfo(&imageinfo);
  5718. if (status == Ok)
  5719. {
  5720. *height = imageinfo.Height;
  5721. }
  5722. return status;
  5723. }
  5724. GpStatus
  5725. WINGDIPAPI
  5726. GdipGetImageHorizontalResolution(
  5727. GpImage *image,
  5728. REAL *resolution
  5729. )
  5730. {
  5731. API_ENTRY(GdipGetImageHorizontalResolution);
  5732. CheckParameter(resolution);
  5733. CheckParameterValid(image);
  5734. CheckObjectBusy(image);
  5735. ImageInfo imageinfo;
  5736. GpStatus status = image->GetImageInfo(&imageinfo);
  5737. if (status == Ok)
  5738. {
  5739. *resolution = (REAL) imageinfo.Xdpi;
  5740. }
  5741. return status;
  5742. }
  5743. GpStatus
  5744. WINGDIPAPI
  5745. GdipGetImageVerticalResolution(
  5746. GpImage *image,
  5747. REAL *resolution
  5748. )
  5749. {
  5750. API_ENTRY(GdipGetImageVerticalResolution);
  5751. CheckParameter(resolution);
  5752. CheckParameterValid(image);
  5753. CheckObjectBusy(image);
  5754. ImageInfo imageinfo;
  5755. GpStatus status = image->GetImageInfo(&imageinfo);
  5756. if (status == Ok)
  5757. {
  5758. *resolution = (REAL) imageinfo.Ydpi;
  5759. }
  5760. return status;
  5761. }
  5762. GpStatus
  5763. WINGDIPAPI
  5764. GdipGetImageFlags(
  5765. GpImage *image,
  5766. UINT *flags
  5767. )
  5768. {
  5769. API_ENTRY(GdipGetImageFlags);
  5770. CheckParameter(flags);
  5771. CheckParameterValid(image);
  5772. CheckObjectBusy(image);
  5773. ImageInfo imageinfo;
  5774. GpStatus status = image->GetImageInfo(&imageinfo);
  5775. if (status == Ok)
  5776. {
  5777. *flags = imageinfo.Flags;
  5778. }
  5779. return status;
  5780. }
  5781. GpStatus
  5782. WINGDIPAPI
  5783. GdipGetImageRawFormat(
  5784. GpImage *image,
  5785. GUID *format
  5786. )
  5787. {
  5788. API_ENTRY(GdipGetImageRawFormat);
  5789. CheckParameter(format);
  5790. CheckParameterValid(image);
  5791. CheckObjectBusy(image);
  5792. ImageInfo imageinfo;
  5793. GpStatus status = image->GetImageInfo(&imageinfo);
  5794. if (status == Ok)
  5795. {
  5796. *format = imageinfo.RawDataFormat;
  5797. }
  5798. return status;
  5799. }
  5800. GpStatus
  5801. WINGDIPAPI
  5802. GdipGetImagePixelFormat(
  5803. GpImage *image,
  5804. PixelFormat *format
  5805. )
  5806. {
  5807. API_ENTRY(GdipGetImagePixelFormat);
  5808. CheckParameter(format);
  5809. CheckParameterValid(image);
  5810. CheckObjectBusy(image);
  5811. ImageInfo imageinfo;
  5812. GpStatus status = image->GetImageInfo(&imageinfo);
  5813. if (status == Ok)
  5814. {
  5815. //!!!need conversion to PixelFormat
  5816. *format = (PixelFormat) MaskPixelFormat(imageinfo.PixelFormat);
  5817. }
  5818. return status;
  5819. }
  5820. GpStatus WINGDIPAPI
  5821. GdipGetImagePalette(GpImage *image, ColorPalette *palette, INT size)
  5822. {
  5823. API_ENTRY(GdipGetImagePalette);
  5824. CheckParameter(palette);
  5825. CheckParameterValid(image);
  5826. CheckObjectBusy(image);
  5827. return image->GetPalette(palette, size);
  5828. }
  5829. GpStatus WINGDIPAPI
  5830. GdipSetImagePalette(GpImage *image, GDIPCONST ColorPalette *palette)
  5831. {
  5832. API_ENTRY(GdipSetImagePalette);
  5833. CheckParameter(palette);
  5834. CheckParameterValid(image);
  5835. CheckObjectBusy(image);
  5836. return image->SetPalette(const_cast<ColorPalette*>(palette));
  5837. }
  5838. GpStatus WINGDIPAPI
  5839. GdipGetImagePaletteSize(GpImage *image, INT *size)
  5840. {
  5841. API_ENTRY(GdipGetImagePaletteSize);
  5842. CheckParameter(size);
  5843. CheckParameterValid(image);
  5844. CheckObjectBusy(image);
  5845. *size = image->GetPaletteSize();
  5846. // Note: image->GetPaletteSize() will return zero if and only if there is
  5847. // something wrong in the whole pipeline, like a bad image, out of memory etc.
  5848. if (*size == 0)
  5849. {
  5850. return GenericError;
  5851. }
  5852. else
  5853. {
  5854. return Ok;
  5855. }
  5856. }
  5857. GpStatus
  5858. WINGDIPAPI
  5859. GdipGetImageType(
  5860. GpImage* image,
  5861. ImageType* type
  5862. )
  5863. {
  5864. API_ENTRY(GdipGetImageType);
  5865. CheckParameter(type);
  5866. CheckParameterValid(image);
  5867. CheckObjectBusy(image);
  5868. *type = (ImageType)image->GetImageType();
  5869. return Ok;
  5870. }
  5871. GpStatus
  5872. WINGDIPAPI
  5873. GdipGetImageThumbnail(
  5874. GpImage* image,
  5875. UINT thumbWidth,
  5876. UINT thumbHeight,
  5877. GpImage** thumbImage,
  5878. GetThumbnailImageAbort callback,
  5879. VOID * callbackData
  5880. )
  5881. {
  5882. API_ENTRY(GdipGetImageThumbnail);
  5883. CheckParameter(thumbImage);
  5884. CheckParameterValid(image);
  5885. CheckObjectBusy(image);
  5886. *thumbImage = image->GetThumbnail(thumbWidth, thumbHeight, callback, callbackData);
  5887. if (*thumbImage)
  5888. return Ok;
  5889. else
  5890. return OutOfMemory;
  5891. }
  5892. GpStatus
  5893. WINGDIPAPI
  5894. GdipImageForceValidation(GpImage* image)
  5895. {
  5896. API_ENTRY(GdipImageForceValidation);
  5897. CheckParameterValid(image);
  5898. CheckObjectBusy(image);
  5899. // Metafiles don't need a force decode
  5900. if (image->GetImageType() == ImageTypeBitmap)
  5901. return (static_cast<GpBitmap*>(image))->ForceValidation();
  5902. else
  5903. return Ok;
  5904. }
  5905. GpStatus
  5906. WINGDIPAPI
  5907. GdipCreateBitmapFromStream(
  5908. IStream* stream,
  5909. GpBitmap** bitmap
  5910. )
  5911. {
  5912. API_ENTRY(GdipCreateBitmapFromStream);
  5913. CheckGdiplusInitialized; // We do this in all our object creation API's
  5914. CheckParameter(bitmap && stream);
  5915. *bitmap = NULL;
  5916. // See if the stream is a metafile
  5917. GpMetafile* metafile = new GpMetafile(stream);
  5918. if (metafile != NULL)
  5919. {
  5920. if (metafile->IsValid())
  5921. {
  5922. // If it is a {EMF, WMF} file, then we get a raster version of it
  5923. // Note: GetBitmap() might return NULL if there is anything wrong
  5924. // with the Metafile
  5925. *bitmap = metafile->GetBitmap();
  5926. metafile->Dispose();
  5927. goto SkipRasterImage;
  5928. }
  5929. metafile->Dispose();
  5930. }
  5931. if ( NULL == *bitmap )
  5932. {
  5933. // it's not a valid metafile -- it must be a bitmap
  5934. *bitmap = new GpBitmap(stream);
  5935. }
  5936. SkipRasterImage:
  5937. // !!! Can't use CheckValid() since destructor is protected.
  5938. if (*bitmap)
  5939. {
  5940. if ((*bitmap)->IsValid())
  5941. {
  5942. (*bitmap)->SetICMConvert(FALSE);
  5943. return Ok;
  5944. }
  5945. else
  5946. {
  5947. (*bitmap)->Dispose();
  5948. *bitmap = NULL;
  5949. return InvalidParameter;
  5950. }
  5951. }
  5952. else
  5953. {
  5954. return OutOfMemory;
  5955. }
  5956. }
  5957. GpStatus
  5958. WINGDIPAPI
  5959. GdipCreateBitmapFromFile(
  5960. GDIPCONST WCHAR* filename,
  5961. GpBitmap** bitmap
  5962. )
  5963. {
  5964. API_ENTRY(GdipCreateBitmapFromFile);
  5965. CheckGdiplusInitialized; // We do this in all our object creation API's
  5966. CheckParameter(bitmap && filename);
  5967. *bitmap = NULL;
  5968. // Try a metafile first always
  5969. GpMetafile* metafile;
  5970. metafile = new GpMetafile(filename);
  5971. if (metafile)
  5972. {
  5973. if (metafile->IsValid())
  5974. {
  5975. *bitmap = metafile->GetBitmap();
  5976. metafile->Dispose();
  5977. goto SkipRasterImage;
  5978. }
  5979. metafile->Dispose();
  5980. }
  5981. // If it is not a metafile, then check if this is a raster image
  5982. if ( NULL == *bitmap )
  5983. {
  5984. *bitmap = new GpBitmap(filename);
  5985. }
  5986. // !!! Can't use CheckValid() since destructor is protected.
  5987. SkipRasterImage:
  5988. if (*bitmap)
  5989. {
  5990. if ((*bitmap)->IsValid())
  5991. {
  5992. (*bitmap)->SetICMConvert(FALSE);
  5993. return Ok;
  5994. }
  5995. else
  5996. {
  5997. (*bitmap)->Dispose();
  5998. *bitmap = NULL;
  5999. return InvalidParameter;
  6000. }
  6001. }
  6002. else
  6003. {
  6004. return OutOfMemory;
  6005. }
  6006. }
  6007. GpStatus
  6008. WINGDIPAPI
  6009. GdipCreateBitmapFromStreamICM(
  6010. IStream* stream,
  6011. GpBitmap** bitmap
  6012. )
  6013. {
  6014. API_ENTRY(GdipCreateBitmapFromStreamICM);
  6015. CheckGdiplusInitialized; // We do this in all our object creation API's
  6016. CheckParameter(bitmap && stream);
  6017. *bitmap = NULL;
  6018. // See if the stream is a metafile
  6019. GpMetafile* metafile = new GpMetafile(stream);
  6020. if (metafile != NULL)
  6021. {
  6022. if (metafile->IsValid())
  6023. {
  6024. *bitmap = metafile->GetBitmap();
  6025. metafile->Dispose();
  6026. goto SkipRasterImage;
  6027. }
  6028. metafile->Dispose();
  6029. }
  6030. if ( NULL == *bitmap )
  6031. {
  6032. // it's not a valid metafile -- it must be a bitmap
  6033. *bitmap = new GpBitmap(stream);
  6034. }
  6035. // !!! Can't use CheckValid() since destructor is protected.
  6036. SkipRasterImage:
  6037. if (*bitmap)
  6038. {
  6039. if ((*bitmap)->IsValid())
  6040. {
  6041. (*bitmap)->SetICMConvert(TRUE);
  6042. return Ok;
  6043. }
  6044. else
  6045. {
  6046. (*bitmap)->Dispose();
  6047. *bitmap = NULL;
  6048. return InvalidParameter;
  6049. }
  6050. }
  6051. else
  6052. {
  6053. return OutOfMemory;
  6054. }
  6055. }
  6056. GpStatus
  6057. WINGDIPAPI
  6058. GdipCreateBitmapFromFileICM(
  6059. GDIPCONST WCHAR* filename,
  6060. GpBitmap** bitmap
  6061. )
  6062. {
  6063. API_ENTRY(GdipCreateBitmapFromFileICM);
  6064. CheckGdiplusInitialized; // We do this in all our object creation API's
  6065. CheckParameter(bitmap && filename);
  6066. // copied from GpImage::LoadImage
  6067. *bitmap = NULL;
  6068. // Try a metafile first always
  6069. GpMetafile* metafile;
  6070. metafile = new GpMetafile(filename);
  6071. if (metafile)
  6072. {
  6073. if (metafile->IsValid())
  6074. {
  6075. *bitmap = metafile->GetBitmap();
  6076. metafile->Dispose();
  6077. goto SkipRasterImage;
  6078. }
  6079. metafile->Dispose();
  6080. }
  6081. // If it is not a metafile, then check if this is a raster image
  6082. if ( NULL == *bitmap )
  6083. {
  6084. *bitmap = new GpBitmap(filename);
  6085. }
  6086. // !!! Can't use CheckValid() since destructor is protected.
  6087. SkipRasterImage:
  6088. if (*bitmap)
  6089. {
  6090. if ((*bitmap)->IsValid())
  6091. {
  6092. (*bitmap)->SetICMConvert(TRUE);
  6093. return Ok;
  6094. }
  6095. else
  6096. {
  6097. (*bitmap)->Dispose();
  6098. *bitmap = NULL;
  6099. return InvalidParameter;
  6100. }
  6101. }
  6102. else
  6103. {
  6104. return OutOfMemory;
  6105. }
  6106. }
  6107. GpStatus
  6108. WINGDIPAPI
  6109. GdipCreateBitmapFromScan0(
  6110. INT width,
  6111. INT height,
  6112. INT stride,
  6113. PixelFormatID format,
  6114. BYTE* scan0,
  6115. GpBitmap** bitmap
  6116. )
  6117. {
  6118. API_ENTRY(GdipCreateBitmapFromScan0);
  6119. CheckGdiplusInitialized; // We do this in all our object creation API's
  6120. CheckParameter(bitmap);
  6121. format = MaskPixelFormat(format);
  6122. if (scan0 == NULL)
  6123. {
  6124. *bitmap = new GpBitmap(width, height, format);
  6125. }
  6126. else
  6127. {
  6128. CheckParameter(stride);
  6129. *bitmap = new GpBitmap(width, height, stride, format, scan0);
  6130. }
  6131. // !!! Can't use CheckValid() since destructor is protected.
  6132. if (*bitmap)
  6133. {
  6134. if ((*bitmap)->IsValid())
  6135. return Ok;
  6136. else
  6137. {
  6138. (*bitmap)->Dispose();
  6139. *bitmap = NULL;
  6140. return InvalidParameter;
  6141. }
  6142. }
  6143. else
  6144. {
  6145. return OutOfMemory;
  6146. }
  6147. }
  6148. GpStatus
  6149. WINGDIPAPI
  6150. GdipCreateBitmapFromGraphics(
  6151. INT width,
  6152. INT height,
  6153. GpGraphics* graphics,
  6154. GpBitmap** bitmap
  6155. )
  6156. {
  6157. API_ENTRY(GdipCreateBitmapFromGraphics);
  6158. CheckGdiplusInitialized; // We do this in all our object creation API's
  6159. CheckParameter(bitmap);
  6160. CheckParameterValid(graphics);
  6161. CheckObjectBusy(graphics);
  6162. //!!!TODO: temp use 32bpp argb
  6163. #ifdef NO_PREMULTIPLIED_ALPHA
  6164. *bitmap = new GpBitmap(width, height, PIXFMT_32BPP_ARGB, graphics);
  6165. #else
  6166. *bitmap = new GpBitmap(width, height, PIXFMT_32BPP_PARGB, graphics);
  6167. #endif
  6168. // !!! Can't use CheckValid() since destructor is protected.
  6169. if (*bitmap)
  6170. {
  6171. if ((*bitmap)->IsValid())
  6172. return Ok;
  6173. else
  6174. {
  6175. (*bitmap)->Dispose();
  6176. *bitmap = NULL;
  6177. return InvalidParameter;
  6178. }
  6179. }
  6180. else
  6181. {
  6182. return OutOfMemory;
  6183. }
  6184. }
  6185. GpStatus
  6186. WINGDIPAPI
  6187. GdipCreateBitmapFromDirectDrawSurface(
  6188. IDirectDrawSurface7 * surface,
  6189. GpBitmap** bitmap
  6190. )
  6191. {
  6192. API_ENTRY(GdipCreateBitmapFromDirectDrawSurface);
  6193. CheckGdiplusInitialized; // We do this in all our object creation API's
  6194. CheckParameter(bitmap);
  6195. CheckParameter(surface);
  6196. *bitmap = new GpBitmap(surface);
  6197. // !!! Can't use CheckValid() since destructor is protected.
  6198. if (*bitmap)
  6199. {
  6200. if ((*bitmap)->IsValid())
  6201. return Ok;
  6202. else
  6203. {
  6204. (*bitmap)->Dispose();
  6205. *bitmap = NULL;
  6206. return InvalidParameter;
  6207. }
  6208. }
  6209. return OutOfMemory;
  6210. }
  6211. GpStatus
  6212. WINGDIPAPI
  6213. GdipCreateBitmapFromGdiDib(
  6214. GDIPCONST BITMAPINFO* gdiBitmapInfo,
  6215. VOID* gdiBitmapData,
  6216. GpBitmap** bitmap
  6217. )
  6218. {
  6219. API_ENTRY(GdipCreateBitmapFromGdiDib);
  6220. CheckGdiplusInitialized; // We do this in all our object creation API's
  6221. CheckParameter(bitmap);
  6222. CheckParameter(gdiBitmapInfo);
  6223. CheckParameter(gdiBitmapData);
  6224. *bitmap = new GpBitmap(const_cast<BITMAPINFO*>(gdiBitmapInfo),
  6225. gdiBitmapData,
  6226. FALSE);
  6227. // !!! Can't use CheckValid() since destructor is protected.
  6228. if (*bitmap)
  6229. {
  6230. if ((*bitmap)->IsValid())
  6231. return Ok;
  6232. else
  6233. {
  6234. (*bitmap)->Dispose();
  6235. *bitmap = NULL;
  6236. return InvalidParameter;
  6237. }
  6238. }
  6239. else
  6240. {
  6241. return OutOfMemory;
  6242. }
  6243. }
  6244. GpStatus
  6245. WINGDIPAPI
  6246. GdipCreateBitmapFromHBITMAP(
  6247. HBITMAP hbm,
  6248. HPALETTE hpal,
  6249. GpBitmap** bitmap
  6250. )
  6251. {
  6252. API_ENTRY(GdipCreateBitmapFromHBITMAP);
  6253. CheckGdiplusInitialized; // We do this in all our object creation API's
  6254. CheckParameter(bitmap);
  6255. return GpBitmap::CreateFromHBITMAP(hbm, hpal, bitmap);
  6256. }
  6257. GpStatus
  6258. WINGDIPAPI
  6259. GdipCreateHBITMAPFromBitmap(
  6260. GpBitmap* bitmap,
  6261. HBITMAP* hbmReturn,
  6262. ARGB background
  6263. )
  6264. {
  6265. API_ENTRY(GdipCreateHBITMAPFromBitmap);
  6266. CheckGdiplusInitialized; // We do this in all our object creation API's
  6267. CheckColorParameter(background);
  6268. CheckParameter(hbmReturn);
  6269. CheckParameterValid(bitmap);
  6270. CheckObjectBusy(bitmap);
  6271. return bitmap->CreateHBITMAP(hbmReturn, background);
  6272. }
  6273. GpStatus
  6274. WINGDIPAPI
  6275. GdipCreateBitmapFromHICON(
  6276. HICON hicon,
  6277. GpBitmap** bitmap
  6278. )
  6279. {
  6280. API_ENTRY(GdipCreateBitmapFromHICON);
  6281. CheckGdiplusInitialized; // We do this in all our object creation API's
  6282. CheckParameter(bitmap);
  6283. return GpBitmap::CreateFromHICON(hicon, bitmap);
  6284. }
  6285. GpStatus
  6286. WINGDIPAPI
  6287. GdipCreateBitmapFromResource(HINSTANCE hInstance,
  6288. GDIPCONST WCHAR* lpBitmapName,
  6289. GpBitmap** bitmap)
  6290. {
  6291. API_ENTRY(GdipCreateBitmapFromResource);
  6292. CheckGdiplusInitialized; // We do this in all our object creation API's
  6293. CheckParameter(bitmap);
  6294. return GpBitmap::CreateFromResource(hInstance, const_cast<WCHAR*>(lpBitmapName), bitmap);
  6295. }
  6296. GpStatus
  6297. WINGDIPAPI
  6298. GdipCreateHICONFromBitmap(
  6299. GpBitmap* bitmap,
  6300. HICON* hiconReturn)
  6301. {
  6302. API_ENTRY(GdipCreateHICONFromBitmap);
  6303. CheckGdiplusInitialized; // We do this in all our object creation API's
  6304. CheckParameter(hiconReturn);
  6305. CheckParameterValid(bitmap);
  6306. CheckObjectBusy(bitmap);
  6307. return bitmap->CreateHICON(hiconReturn);
  6308. }
  6309. GpStatus
  6310. WINGDIPAPI
  6311. GdipCloneBitmapArea(
  6312. REAL x,
  6313. REAL y,
  6314. REAL width,
  6315. REAL height,
  6316. PixelFormatID format,
  6317. GpBitmap *srcBitmap,
  6318. GpBitmap **dstBitmap
  6319. )
  6320. {
  6321. API_ENTRY(GdipCloneBitmapArea);
  6322. format = MaskPixelFormat(format);
  6323. return GdipCloneBitmapAreaI(GpRound(x), GpRound(y),
  6324. GpRound(width), GpRound(height),
  6325. format, srcBitmap, dstBitmap);
  6326. }
  6327. GpStatus
  6328. WINGDIPAPI
  6329. GdipCloneBitmapAreaI(
  6330. INT x,
  6331. INT y,
  6332. INT width,
  6333. INT height,
  6334. PixelFormatID format,
  6335. GpBitmap *srcBitmap,
  6336. GpBitmap **dstBitmap
  6337. )
  6338. {
  6339. API_ENTRY(GdipCloneBitmapAreaI);
  6340. CheckParameter(dstBitmap);
  6341. CheckParameterValid(srcBitmap);
  6342. CheckObjectBusy(srcBitmap);
  6343. format = MaskPixelFormat(format);
  6344. GpRect rect(x, y, width, height);
  6345. *dstBitmap = srcBitmap->Clone(&rect, format);
  6346. if (*dstBitmap)
  6347. return Ok;
  6348. else
  6349. return OutOfMemory;
  6350. }
  6351. GpStatus
  6352. WINGDIPAPI
  6353. GdipBitmapLockBits(
  6354. GpBitmap* bitmap,
  6355. GDIPCONST GpRect* rect, // can be NULL
  6356. UINT flags,
  6357. PixelFormatID format,
  6358. BitmapData* lockedBitmapData
  6359. )
  6360. {
  6361. API_ENTRY(GdipBitmapLockBits);
  6362. CheckParameter(lockedBitmapData);
  6363. CheckParameterValid(bitmap);
  6364. CheckObjectBusy(bitmap);
  6365. format = MaskPixelFormat(format);
  6366. return bitmap->LockBits(rect, flags, format, lockedBitmapData);
  6367. }
  6368. GpStatus
  6369. WINGDIPAPI
  6370. GdipBitmapUnlockBits(
  6371. GpBitmap* bitmap,
  6372. BitmapData* lockedBitmapData
  6373. )
  6374. {
  6375. API_ENTRY(GdipBitmapUnlockBits);
  6376. CheckParameter(lockedBitmapData);
  6377. CheckParameterValid(bitmap);
  6378. CheckObjectBusy(bitmap);
  6379. return bitmap->UnlockBits(lockedBitmapData);
  6380. }
  6381. GpStatus
  6382. WINGDIPAPI
  6383. GdipBitmapGetPixel(
  6384. GpBitmap* bitmap,
  6385. INT x,
  6386. INT y,
  6387. ARGB *color
  6388. )
  6389. {
  6390. API_ENTRY(GdipBitmapGetPixel);
  6391. CheckParameter(color);
  6392. CheckParameterValid(bitmap);
  6393. CheckObjectBusy(bitmap);
  6394. ARGB temp;
  6395. Status status = bitmap->GetPixel(x, y, &temp);
  6396. *color = temp;
  6397. return status;
  6398. }
  6399. GpStatus
  6400. WINGDIPAPI
  6401. GdipBitmapSetPixel(
  6402. GpBitmap* bitmap,
  6403. INT x,
  6404. INT y,
  6405. ARGB color
  6406. )
  6407. {
  6408. API_ENTRY(GdipBitmapSetPixel);
  6409. CheckColorParameter(color);
  6410. CheckParameterValid(bitmap);
  6411. CheckObjectBusy(bitmap);
  6412. return bitmap->SetPixel(x, y, color);
  6413. }
  6414. GpStatus
  6415. WINGDIPAPI
  6416. GdipBitmapSetResolution(
  6417. GpBitmap* bitmap,
  6418. REAL xdpi,
  6419. REAL ydpi
  6420. )
  6421. {
  6422. API_ENTRY(GdipBitmapSetResolution);
  6423. CheckParameterValid(bitmap);
  6424. CheckObjectBusy(bitmap);
  6425. return bitmap->SetResolution(xdpi, ydpi);
  6426. }
  6427. GpStatus
  6428. WINGDIPAPI
  6429. GdipCreateImageAttributes(GpImageAttributes **imageattr)
  6430. {
  6431. API_ENTRY(GdipCreateImageAttributes);
  6432. CheckGdiplusInitialized; // We do this in all our object creation API's
  6433. CheckParameter(imageattr);
  6434. *imageattr = new GpImageAttributes();
  6435. if (*imageattr)
  6436. {
  6437. if ((*imageattr)->IsValid())
  6438. {
  6439. return Ok;
  6440. }
  6441. else
  6442. {
  6443. (*imageattr)->Dispose();
  6444. *imageattr = NULL;
  6445. return OutOfMemory;
  6446. }
  6447. }
  6448. else
  6449. {
  6450. return OutOfMemory;
  6451. }
  6452. }
  6453. GpStatus
  6454. WINGDIPAPI
  6455. GdipCloneImageAttributes(
  6456. GDIPCONST GpImageAttributes *imageattr,
  6457. GpImageAttributes **cloneImageAttr
  6458. )
  6459. {
  6460. API_ENTRY(GdipCloneImageAttributes);
  6461. CheckParameter(cloneImageAttr);
  6462. CheckParameterValid(imageattr);
  6463. CheckObjectBusy(imageattr);
  6464. *cloneImageAttr = imageattr->Clone();
  6465. if (*cloneImageAttr)
  6466. return Ok;
  6467. else
  6468. return OutOfMemory;
  6469. }
  6470. GpStatus
  6471. WINGDIPAPI
  6472. GdipDisposeImageAttributes(
  6473. GpImageAttributes *imageattr
  6474. )
  6475. {
  6476. API_ENTRY(GdipDisposeImageAttributes);
  6477. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  6478. // the object, even if it's not in a valid state.
  6479. CheckParameter(imageattr);
  6480. CheckObjectBusyForDelete(imageattr);
  6481. imageattr->Dispose();
  6482. return Ok;
  6483. }
  6484. GpStatus
  6485. WINGDIPAPI
  6486. GdipSetImageAttributesToIdentity(
  6487. GpImageAttributes *imageattr,
  6488. ColorAdjustType type
  6489. )
  6490. {
  6491. API_ENTRY(GdipSetImageAttributesToIdentity);
  6492. CheckParameterValid(imageattr);
  6493. CheckObjectBusy(imageattr);
  6494. CheckParameter(ColorAdjustTypeIsValid(type));
  6495. return imageattr->SetToIdentity(type);
  6496. }
  6497. GpStatus
  6498. WINGDIPAPI
  6499. GdipResetImageAttributes(
  6500. GpImageAttributes *imageattr,
  6501. ColorAdjustType type
  6502. )
  6503. {
  6504. API_ENTRY(GdipResetImageAttributes);
  6505. CheckParameterValid(imageattr);
  6506. CheckObjectBusy(imageattr);
  6507. CheckParameter(ColorAdjustTypeIsValid(type));
  6508. return imageattr->Reset(type);
  6509. }
  6510. GpStatus
  6511. WINGDIPAPI
  6512. GdipSetImageAttributesColorMatrix(
  6513. GpImageAttributes *imageattr,
  6514. ColorAdjustType type,
  6515. BOOL enableFlag,
  6516. GDIPCONST ColorMatrix* colorMatrix,
  6517. GDIPCONST ColorMatrix* grayMatrix,
  6518. ColorMatrixFlags flags
  6519. )
  6520. {
  6521. API_ENTRY(GdipSetImageAttributesColorMatrix);
  6522. CheckParameterValid(imageattr);
  6523. CheckObjectBusy(imageattr);
  6524. CheckParameter(ColorAdjustTypeIsValid(type));
  6525. // Note: GpImageAttributes::SetColorMatrix will validate
  6526. // colorMatrix since it may be valid to pass NULL
  6527. // (such as when enableFlag is FALSE).
  6528. return imageattr->SetColorMatrix(type,
  6529. enableFlag,
  6530. const_cast<ColorMatrix*>(colorMatrix),
  6531. const_cast<ColorMatrix*>(grayMatrix), flags);
  6532. }
  6533. GpStatus
  6534. WINGDIPAPI
  6535. GdipSetImageAttributesThreshold(
  6536. GpImageAttributes *imageattr,
  6537. ColorAdjustType type,
  6538. BOOL enableFlag,
  6539. REAL threshold
  6540. )
  6541. {
  6542. API_ENTRY(GdipSetImageAttributesThreshold);
  6543. CheckParameterValid(imageattr);
  6544. CheckObjectBusy(imageattr);
  6545. CheckParameter(ColorAdjustTypeIsValid(type));
  6546. return imageattr->SetThreshold(type, enableFlag, threshold);
  6547. }
  6548. GpStatus
  6549. WINGDIPAPI
  6550. GdipSetImageAttributesGamma(
  6551. GpImageAttributes *imageattr,
  6552. ColorAdjustType type,
  6553. BOOL enableFlag,
  6554. REAL gamma
  6555. )
  6556. {
  6557. API_ENTRY(GdipSetImageAttributesGamma);
  6558. CheckParameterValid(imageattr);
  6559. CheckObjectBusy(imageattr);
  6560. CheckParameter(ColorAdjustTypeIsValid(type));
  6561. return imageattr->SetGamma(type, enableFlag, gamma);
  6562. }
  6563. GpStatus
  6564. WINGDIPAPI
  6565. GdipSetImageAttributesNoOp(
  6566. GpImageAttributes *imageattr,
  6567. ColorAdjustType type,
  6568. BOOL enableFlag
  6569. )
  6570. {
  6571. API_ENTRY(GdipSetImageAttributesNoOp);
  6572. CheckParameterValid(imageattr);
  6573. CheckObjectBusy(imageattr);
  6574. CheckParameter(ColorAdjustTypeIsValid(type));
  6575. return imageattr->SetNoOp(type, enableFlag);
  6576. }
  6577. GpStatus
  6578. WINGDIPAPI
  6579. GdipSetImageAttributesColorKeys(
  6580. GpImageAttributes *imageattr,
  6581. ColorAdjustType type,
  6582. BOOL enableFlag,
  6583. ARGB argbLow,
  6584. ARGB argbHigh
  6585. )
  6586. {
  6587. API_ENTRY(GdipSetImageAttributesColorKeys);
  6588. CheckColorParameter(argbLow);
  6589. CheckColorParameter(argbHigh);
  6590. CheckParameterValid(imageattr);
  6591. CheckObjectBusy(imageattr);
  6592. CheckParameter(ColorAdjustTypeIsValid(type));
  6593. Color colorLow(argbLow);
  6594. Color colorHigh(argbHigh);
  6595. return imageattr->SetColorKeys(type, enableFlag, &colorLow, &colorHigh);
  6596. }
  6597. GpStatus
  6598. WINGDIPAPI
  6599. GdipSetImageAttributesOutputChannel(
  6600. GpImageAttributes *imageattr,
  6601. ColorAdjustType type,
  6602. BOOL enableFlag,
  6603. ColorChannelFlags channelFlags
  6604. )
  6605. {
  6606. API_ENTRY(GdipSetImageAttributesOutputChannel);
  6607. CheckParameterValid(imageattr);
  6608. CheckObjectBusy(imageattr);
  6609. CheckParameter(ColorAdjustTypeIsValid(type));
  6610. return imageattr->SetOutputChannel(type, enableFlag, channelFlags);
  6611. }
  6612. GpStatus
  6613. WINGDIPAPI
  6614. GdipSetImageAttributesOutputChannelColorProfile(
  6615. GpImageAttributes *imageattr,
  6616. ColorAdjustType type,
  6617. BOOL enableFlag,
  6618. GDIPCONST WCHAR *colorProfileFilename)
  6619. {
  6620. API_ENTRY(GdipSetImageAttributesOutputChannelColorProfile);
  6621. CheckParameterValid(imageattr);
  6622. CheckObjectBusy(imageattr);
  6623. CheckParameter(ColorAdjustTypeIsValid(type));
  6624. // Note: GpImageAttributes::SetOutputChannelProfile will validate
  6625. // colorProfileFilename since it may be valid to pass NULL
  6626. // (such as when enableFlag is FALSE).
  6627. return imageattr->SetOutputChannelProfile(type, enableFlag,
  6628. const_cast<WCHAR*>(colorProfileFilename));
  6629. }
  6630. GpStatus
  6631. WINGDIPAPI
  6632. GdipSetImageAttributesRemapTable(
  6633. GpImageAttributes *imageattr,
  6634. ColorAdjustType type,
  6635. BOOL enableFlag,
  6636. UINT mapSize,
  6637. GDIPCONST ColorMap *map
  6638. )
  6639. {
  6640. API_ENTRY(GdipSetImageAttributesRemapTable);
  6641. CheckParameterValid(imageattr);
  6642. CheckObjectBusy(imageattr);
  6643. CheckParameter(ColorAdjustTypeIsValid(type));
  6644. return imageattr->SetRemapTable(type, enableFlag, mapSize, const_cast<ColorMap*>(map));
  6645. }
  6646. GpStatus
  6647. WINGDIPAPI
  6648. GdipSetImageAttributesCachedBackground(
  6649. GpImageAttributes *imageattr,
  6650. BOOL enableFlag
  6651. )
  6652. {
  6653. API_ENTRY(GdipSetImageAttributesCachedBackground);
  6654. CheckParameterValid(imageattr);
  6655. CheckObjectBusy(imageattr);
  6656. return imageattr->SetCachedBackground(enableFlag);
  6657. }
  6658. GpStatus
  6659. WINGDIPAPI
  6660. GdipSetImageAttributesWrapMode(
  6661. GpImageAttributes *imageAttr,
  6662. WrapMode wrap,
  6663. ARGB argb,
  6664. BOOL clamp
  6665. )
  6666. {
  6667. API_ENTRY(GdipSetImageAttributesWrapMode);
  6668. CheckColorParameter(argb);
  6669. CheckParameterValid(imageAttr);
  6670. CheckObjectBusy(imageAttr);
  6671. return imageAttr->SetWrapMode(wrap, argb, clamp);
  6672. }
  6673. GpStatus WINGDIPAPI
  6674. GdipGetImageAttributesAdjustedPalette(
  6675. GpImageAttributes *imageAttr,
  6676. ColorPalette * colorPalette,
  6677. ColorAdjustType colorAdjustType
  6678. )
  6679. {
  6680. API_ENTRY(GdipGetImageAttributesAdjustedPalette);
  6681. CheckParameterValid(imageAttr);
  6682. CheckObjectBusy(imageAttr);
  6683. CheckParameter((colorPalette != NULL) && (colorPalette->Count > 0));
  6684. CheckParameter((colorAdjustType >= ColorAdjustTypeBitmap) &&
  6685. (colorAdjustType < ColorAdjustTypeCount));
  6686. imageAttr->GetAdjustedPalette(colorPalette, colorAdjustType);
  6687. return Ok;
  6688. }
  6689. GpStatus
  6690. WINGDIPAPI
  6691. GdipCreateFromHDC(
  6692. HDC hdc,
  6693. GpGraphics** graphics
  6694. )
  6695. {
  6696. API_ENTRY(GdipCreateFromHDC);
  6697. CheckGdiplusInitialized; // We do this in all our object creation API's
  6698. CheckParameter(graphics);
  6699. *graphics = GpGraphics::GetFromHdc(hdc);
  6700. if (CheckValid(*graphics))
  6701. return Ok;
  6702. else
  6703. return OutOfMemory;
  6704. }
  6705. GpStatus
  6706. WINGDIPAPI
  6707. GdipCreateFromHDC2(
  6708. HDC hdc,
  6709. HANDLE hdevice,
  6710. GpGraphics** graphics
  6711. )
  6712. {
  6713. API_ENTRY(GdipCreateFromHDC2);
  6714. CheckGdiplusInitialized; // We do this in all our object creation API's
  6715. CheckParameter(graphics);
  6716. *graphics = GpGraphics::GetFromHdc(hdc, hdevice);
  6717. if (CheckValid(*graphics))
  6718. return Ok;
  6719. else
  6720. return OutOfMemory;
  6721. }
  6722. GpStatus
  6723. WINGDIPAPI
  6724. GdipCreateFromHWND(
  6725. HWND hwnd,
  6726. GpGraphics** graphics
  6727. )
  6728. {
  6729. API_ENTRY(GdipCreateFromHWND);
  6730. CheckGdiplusInitialized; // We do this in all our object creation API's
  6731. CheckParameter(graphics);
  6732. *graphics = GpGraphics::GetFromHwnd(hwnd);
  6733. if (CheckValid(*graphics))
  6734. return Ok;
  6735. else
  6736. return OutOfMemory;
  6737. }
  6738. GpStatus
  6739. WINGDIPAPI
  6740. GdipCreateFromHWNDICM(
  6741. HWND hwnd,
  6742. GpGraphics** graphics
  6743. )
  6744. {
  6745. API_ENTRY(GdipCreateFromHWNDICM);
  6746. CheckGdiplusInitialized; // We do this in all our object creation API's
  6747. CheckParameter(graphics);
  6748. *graphics = GpGraphics::GetFromHwnd(hwnd, IcmModeOn);
  6749. if (CheckValid(*graphics))
  6750. return Ok;
  6751. else
  6752. return OutOfMemory;
  6753. }
  6754. GpStatus
  6755. WINGDIPAPI
  6756. GdipDeleteGraphics(
  6757. GpGraphics* graphics
  6758. )
  6759. {
  6760. API_ENTRY(GdipDeleteGraphics);
  6761. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  6762. // the object, even if it's not in a valid state.
  6763. CheckParameter(graphics);
  6764. CheckObjectBusyForDelete(graphics);
  6765. delete graphics;
  6766. return Ok;
  6767. }
  6768. GpStatus
  6769. WINGDIPAPI
  6770. GdipFlush(
  6771. GpGraphics* graphics,
  6772. GpFlushIntention intention
  6773. )
  6774. {
  6775. API_ENTRY(GdipFlush);
  6776. CheckParameter(graphics);
  6777. CheckObjectBusy(graphics);
  6778. graphics->Flush(intention);
  6779. return Ok;
  6780. }
  6781. GpStatus
  6782. WINGDIPAPI
  6783. GdipSetRenderingOrigin(
  6784. GpGraphics* graphics,
  6785. INT x,
  6786. INT y
  6787. )
  6788. {
  6789. API_ENTRY(GdipSetRenderingOrigin);
  6790. CheckParameterValid(graphics);
  6791. CheckObjectBusy(graphics);
  6792. graphics->SetRenderingOrigin(x, y);
  6793. return Ok;
  6794. }
  6795. GpStatus
  6796. WINGDIPAPI
  6797. GdipGetRenderingOrigin(
  6798. GpGraphics *graphics,
  6799. INT *x,
  6800. INT *y
  6801. )
  6802. {
  6803. API_ENTRY(GdipGetRenderingOrigin);
  6804. CheckParameter(x);
  6805. CheckParameter(y);
  6806. CheckParameterValid(graphics);
  6807. CheckObjectBusy(graphics);
  6808. graphics->GetRenderingOrigin(x, y);
  6809. return Ok;
  6810. }
  6811. GpStatus
  6812. WINGDIPAPI
  6813. GdipSetCompositingMode(
  6814. GpGraphics* graphics,
  6815. CompositingMode newMode
  6816. )
  6817. {
  6818. API_ENTRY(GdipSetCompositingMode);
  6819. CheckParameterValid(graphics);
  6820. CheckObjectBusy(graphics);
  6821. graphics->SetCompositingMode(newMode);
  6822. return Ok;
  6823. }
  6824. GpStatus
  6825. WINGDIPAPI
  6826. GdipGetCompositingMode(
  6827. GpGraphics *graphics,
  6828. CompositingMode *mode
  6829. )
  6830. {
  6831. API_ENTRY(GdipGetCompositingMode);
  6832. CheckParameter(mode);
  6833. CheckParameterValid(graphics);
  6834. CheckObjectBusy(graphics);
  6835. *mode = graphics->GetCompositingMode();
  6836. return Ok;
  6837. }
  6838. GpStatus
  6839. WINGDIPAPI
  6840. GdipSetCompositingQuality(
  6841. GpGraphics* graphics,
  6842. CompositingQuality newQuality
  6843. )
  6844. {
  6845. API_ENTRY(GdipSetCompositingQuality);
  6846. CheckParameterValid(graphics);
  6847. CheckObjectBusy(graphics);
  6848. graphics->SetCompositingQuality(newQuality);
  6849. return Ok;
  6850. }
  6851. GpStatus
  6852. WINGDIPAPI
  6853. GdipGetCompositingQuality(
  6854. GpGraphics *graphics,
  6855. CompositingQuality *quality
  6856. )
  6857. {
  6858. API_ENTRY(GdipGetCompositingQuality);
  6859. CheckParameter(quality);
  6860. CheckParameterValid(graphics);
  6861. CheckObjectBusy(graphics);
  6862. *quality = graphics->GetCompositingQuality();
  6863. return Ok;
  6864. }
  6865. GpStatus
  6866. WINGDIPAPI
  6867. GdipSetSmoothingMode(
  6868. GpGraphics* graphics,
  6869. SmoothingMode smoothingMode
  6870. )
  6871. {
  6872. API_ENTRY(GdipSetSmoothingMode);
  6873. CheckParameterValid(graphics);
  6874. CheckObjectBusy(graphics);
  6875. // For now, have it so that a Rendering hint of 1
  6876. // means antialiasing ON and a Rendering Hint of 0
  6877. // means Off.
  6878. switch(smoothingMode)
  6879. {
  6880. case SmoothingModeDefault:
  6881. case SmoothingModeHighSpeed:
  6882. case SmoothingModeNone:
  6883. graphics->SetAntiAliasMode(FALSE);
  6884. break;
  6885. case SmoothingModeHighQuality:
  6886. case SmoothingModeAntiAlias:
  6887. graphics->SetAntiAliasMode(TRUE);
  6888. break;
  6889. default:
  6890. // unknown rendering mode
  6891. return InvalidParameter;
  6892. }
  6893. return Ok;
  6894. }
  6895. GpStatus
  6896. WINGDIPAPI
  6897. GdipGetSmoothingMode(
  6898. GpGraphics *graphics,
  6899. SmoothingMode *smoothingMode
  6900. )
  6901. {
  6902. API_ENTRY(GdipGetSmoothingMode);
  6903. CheckParameter(smoothingMode);
  6904. CheckParameterValid(graphics);
  6905. CheckObjectBusy(graphics);
  6906. BOOL aaOn = graphics->GetAntiAliasMode();
  6907. if (aaOn)
  6908. {
  6909. *smoothingMode = SmoothingModeAntiAlias;
  6910. }
  6911. else
  6912. {
  6913. *smoothingMode = SmoothingModeNone;
  6914. }
  6915. return Ok;
  6916. }
  6917. GpStatus
  6918. WINGDIPAPI
  6919. GdipSetPixelOffsetMode(
  6920. GpGraphics* graphics,
  6921. PixelOffsetMode newMode
  6922. )
  6923. {
  6924. API_ENTRY(GdipSetPixelOffsetMode);
  6925. CheckParameterValid(graphics);
  6926. CheckObjectBusy(graphics);
  6927. CheckParameter((newMode >= PixelOffsetModeDefault) &&
  6928. (newMode <= PixelOffsetModeHalf));
  6929. graphics->SetPixelOffsetMode(newMode);
  6930. return Ok;
  6931. }
  6932. GpStatus
  6933. WINGDIPAPI
  6934. GdipGetPixelOffsetMode(
  6935. GpGraphics *graphics,
  6936. PixelOffsetMode *pixelOffsetMode
  6937. )
  6938. {
  6939. API_ENTRY(GdipGetPixelOffsetMode);
  6940. CheckParameter(pixelOffsetMode);
  6941. CheckParameterValid(graphics);
  6942. CheckObjectBusy(graphics);
  6943. *pixelOffsetMode = graphics->GetPixelOffsetMode();
  6944. return Ok;
  6945. }
  6946. GpStatus
  6947. WINGDIPAPI
  6948. GdipSetTextRenderingHint(
  6949. GpGraphics* graphics,
  6950. TextRenderingHint newMode
  6951. )
  6952. {
  6953. API_ENTRY(GdipSetTextRenderingHint);
  6954. CheckParameterValid(graphics);
  6955. CheckObjectBusy(graphics);
  6956. // For now, have it so that a Rendering hint of 1
  6957. // means antialiasing ON and a Rendering Hint of 0
  6958. // means Off.
  6959. switch(newMode)
  6960. {
  6961. case TextRenderingHintSystemDefault:
  6962. case TextRenderingHintSingleBitPerPixelGridFit:
  6963. case TextRenderingHintSingleBitPerPixel:
  6964. case TextRenderingHintAntiAlias:
  6965. case TextRenderingHintAntiAliasGridFit:
  6966. case TextRenderingHintClearTypeGridFit:
  6967. graphics->SetTextRenderingHint(newMode);
  6968. break;
  6969. default:
  6970. // unknown rendering mode
  6971. return InvalidParameter;
  6972. }
  6973. return Ok;
  6974. }
  6975. GpStatus
  6976. WINGDIPAPI
  6977. GdipSetTextContrast(
  6978. GpGraphics* graphics,
  6979. UINT contrast
  6980. )
  6981. {
  6982. API_ENTRY(GdipSetTextContrast);
  6983. CheckParameterValid(graphics);
  6984. CheckObjectBusy(graphics);
  6985. return graphics->SetTextContrast(contrast);
  6986. }
  6987. GpStatus
  6988. WINGDIPAPI
  6989. GdipGetTextContrast(
  6990. GpGraphics* graphics,
  6991. UINT * contrast
  6992. )
  6993. {
  6994. API_ENTRY(GdipGetTextContrast);
  6995. CheckParameter(contrast);
  6996. CheckParameterValid(graphics);
  6997. CheckObjectBusy(graphics);
  6998. *contrast = graphics->GetTextContrast();
  6999. return Ok;
  7000. }
  7001. GpStatus
  7002. WINGDIPAPI
  7003. GdipGetTextRenderingHint(
  7004. GpGraphics *graphics,
  7005. TextRenderingHint *mode
  7006. )
  7007. {
  7008. API_ENTRY(GdipGetTextRenderingHint);
  7009. CheckParameter(mode);
  7010. CheckParameterValid(graphics);
  7011. CheckObjectBusy(graphics);
  7012. *mode = graphics->GetTextRenderingHint();
  7013. return Ok;
  7014. }
  7015. GpStatus
  7016. WINGDIPAPI
  7017. GdipSetInterpolationMode(
  7018. GpGraphics* graphics,
  7019. InterpolationMode interpolationMode
  7020. )
  7021. {
  7022. API_ENTRY(GdipSetInterpolationMode);
  7023. CheckParameterValid(graphics);
  7024. CheckObjectBusy(graphics);
  7025. CheckParameter((interpolationMode >= InterpolationModeDefault) &&
  7026. (interpolationMode <= InterpolationModeHighQualityBicubic));
  7027. if(Globals::ForceBilinear)
  7028. {
  7029. if(interpolationMode != InterpolationModeNearestNeighbor)
  7030. {
  7031. interpolationMode = InterpolationModeBilinear;
  7032. }
  7033. }
  7034. else
  7035. {
  7036. if(interpolationMode == InterpolationModeDefault ||
  7037. interpolationMode == InterpolationModeLowQuality)
  7038. {
  7039. interpolationMode = InterpolationModeBilinear;
  7040. }
  7041. else if(interpolationMode == InterpolationModeHighQuality)
  7042. {
  7043. interpolationMode = InterpolationModeHighQualityBicubic;
  7044. }
  7045. }
  7046. graphics->SetInterpolationMode(interpolationMode);
  7047. return Ok;
  7048. }
  7049. GpStatus
  7050. WINGDIPAPI
  7051. GdipGetInterpolationMode(
  7052. GpGraphics* graphics,
  7053. InterpolationMode *interpolationMode
  7054. )
  7055. {
  7056. API_ENTRY(GdipGetInterpolationMode);
  7057. CheckParameterValid(graphics);
  7058. CheckObjectBusy(graphics);
  7059. *interpolationMode = graphics->GetInterpolationMode();
  7060. return Ok;
  7061. }
  7062. GpStatus
  7063. WINGDIPAPI
  7064. GdipSetWorldTransform(
  7065. GpGraphics *graphics,
  7066. GpMatrix *matrix
  7067. )
  7068. {
  7069. API_ENTRY(GdipSetWorldTransform);
  7070. CheckParameterValid(graphics);
  7071. CheckObjectBusy(graphics);
  7072. CheckParameterValid(matrix);
  7073. CheckObjectBusy(matrix);
  7074. return graphics->SetWorldTransform(*matrix);
  7075. }
  7076. GpStatus
  7077. WINGDIPAPI
  7078. GdipResetWorldTransform(
  7079. GpGraphics *graphics
  7080. )
  7081. {
  7082. API_ENTRY(GdipResetWorldTransform);
  7083. CheckParameterValid(graphics);
  7084. CheckObjectBusy(graphics);
  7085. return graphics->ResetWorldTransform();
  7086. }
  7087. GpStatus
  7088. WINGDIPAPI
  7089. GdipMultiplyWorldTransform(
  7090. GpGraphics *graphics,
  7091. GDIPCONST GpMatrix *matrix,
  7092. GpMatrixOrder order
  7093. )
  7094. {
  7095. API_ENTRY(GdipMultiplyWorldTransform);
  7096. if(matrix == NULL)
  7097. return Ok;
  7098. CheckParameterValid(graphics);
  7099. CheckObjectBusy(graphics);
  7100. CheckParameterValid(matrix);
  7101. CheckObjectBusy(matrix);
  7102. CheckParameter(MatrixOrderIsValid(order));
  7103. return graphics->MultiplyWorldTransform(*matrix, order);
  7104. }
  7105. GpStatus
  7106. WINGDIPAPI
  7107. GdipTranslateWorldTransform(
  7108. GpGraphics *graphics,
  7109. REAL dx,
  7110. REAL dy,
  7111. GpMatrixOrder order
  7112. )
  7113. {
  7114. API_ENTRY(GdipTranslateWorldTransform);
  7115. CheckParameterValid(graphics);
  7116. CheckObjectBusy(graphics);
  7117. CheckParameter(MatrixOrderIsValid(order));
  7118. return graphics->TranslateWorldTransform(dx, dy, order);
  7119. }
  7120. GpStatus
  7121. WINGDIPAPI
  7122. GdipScaleWorldTransform(
  7123. GpGraphics *graphics,
  7124. REAL sx,
  7125. REAL sy,
  7126. GpMatrixOrder order
  7127. )
  7128. {
  7129. API_ENTRY(GdipScaleWorldTransform);
  7130. CheckParameterValid(graphics);
  7131. CheckObjectBusy(graphics);
  7132. CheckParameter(MatrixOrderIsValid(order));
  7133. return graphics->ScaleWorldTransform(sx, sy, order);
  7134. }
  7135. GpStatus
  7136. WINGDIPAPI
  7137. GdipRotateWorldTransform(
  7138. GpGraphics *graphics,
  7139. REAL angle,
  7140. GpMatrixOrder order
  7141. )
  7142. {
  7143. API_ENTRY(GdipRotateWorldTransform);
  7144. CheckParameterValid(graphics);
  7145. CheckObjectBusy(graphics);
  7146. CheckParameter(MatrixOrderIsValid(order));
  7147. return graphics->RotateWorldTransform(angle, order);
  7148. }
  7149. GpStatus
  7150. WINGDIPAPI
  7151. GdipGetWorldTransform(
  7152. GpGraphics *graphics,
  7153. GpMatrix *matrix
  7154. )
  7155. {
  7156. API_ENTRY(GdipGetWorldTransform);
  7157. CheckParameter(matrix);
  7158. CheckObjectBusy(matrix);
  7159. CheckParameterValid(graphics);
  7160. CheckObjectBusy(graphics);
  7161. graphics->GetWorldTransform(*matrix);
  7162. return Ok;
  7163. }
  7164. GpStatus
  7165. WINGDIPAPI
  7166. GdipResetPageTransform(
  7167. GpGraphics *graphics
  7168. )
  7169. {
  7170. API_ENTRY(GdipResetPageTransform);
  7171. CheckParameterValid(graphics);
  7172. CheckObjectBusy(graphics);
  7173. return graphics->ResetPageTransform();
  7174. }
  7175. GpStatus
  7176. WINGDIPAPI
  7177. GdipGetPageUnit(
  7178. GpGraphics* graphics,
  7179. GpPageUnit* unit
  7180. )
  7181. {
  7182. API_ENTRY(GdipGetPageUnit);
  7183. CheckParameter(unit);
  7184. CheckParameterValid(graphics);
  7185. CheckObjectBusy(graphics);
  7186. *unit = graphics->GetPageUnit();
  7187. return Ok;
  7188. }
  7189. GpStatus
  7190. WINGDIPAPI
  7191. GdipSetPageUnit(
  7192. GpGraphics* graphics,
  7193. GpPageUnit unit
  7194. )
  7195. {
  7196. API_ENTRY(GdipSetPageUnit);
  7197. CheckParameterValid(graphics);
  7198. CheckObjectBusy(graphics);
  7199. // PageUnit can't be world
  7200. CheckParameter((unit > UnitWorld) && (unit <= UnitMillimeter));
  7201. return graphics->SetPageUnit(unit);
  7202. }
  7203. GpStatus
  7204. WINGDIPAPI
  7205. GdipGetPageScale(
  7206. GpGraphics* graphics,
  7207. REAL* scale
  7208. )
  7209. {
  7210. API_ENTRY(GdipGetPageScale);
  7211. CheckParameter(scale);
  7212. CheckParameterValid(graphics);
  7213. CheckObjectBusy(graphics);
  7214. *scale = graphics->GetPageScale();
  7215. return Ok;
  7216. }
  7217. GpStatus
  7218. WINGDIPAPI
  7219. GdipSetPageScale(
  7220. GpGraphics* graphics,
  7221. REAL scale
  7222. )
  7223. {
  7224. API_ENTRY(GdipSetPageScale);
  7225. CheckParameterValid(graphics);
  7226. CheckObjectBusy(graphics);
  7227. return graphics->SetPageScale(scale);
  7228. }
  7229. GpStatus
  7230. WINGDIPAPI
  7231. GdipGetDpiX(
  7232. GpGraphics* graphics,
  7233. REAL* dpi
  7234. )
  7235. {
  7236. API_ENTRY(GdipGetDpiX);
  7237. CheckParameter(dpi);
  7238. CheckParameterValid(graphics);
  7239. CheckObjectBusy(graphics);
  7240. *dpi = graphics->GetDpiX();
  7241. return Ok;
  7242. }
  7243. GpStatus
  7244. WINGDIPAPI
  7245. GdipGetDpiY(
  7246. GpGraphics* graphics,
  7247. REAL* dpi
  7248. )
  7249. {
  7250. API_ENTRY(GdipGetDpiY);
  7251. CheckParameter(dpi);
  7252. CheckParameterValid(graphics);
  7253. CheckObjectBusy(graphics);
  7254. *dpi = graphics->GetDpiY();
  7255. return Ok;
  7256. }
  7257. GpStatus
  7258. WINGDIPAPI
  7259. GdipTransformPoints(
  7260. GpGraphics *graphics,
  7261. GpCoordinateSpace destSpace,
  7262. GpCoordinateSpace srcSpace,
  7263. GpPointF *points,
  7264. INT count
  7265. )
  7266. {
  7267. API_ENTRY(GdipTransformPoints);
  7268. CheckParameter(points && count > 0);
  7269. CheckParameterValid(graphics);
  7270. CheckObjectBusy(graphics);
  7271. return graphics->TransformPoints(points, count, srcSpace, destSpace);
  7272. }
  7273. GpStatus
  7274. WINGDIPAPI
  7275. GdipTransformPointsI(
  7276. GpGraphics *graphics,
  7277. GpCoordinateSpace destSpace,
  7278. GpCoordinateSpace srcSpace,
  7279. GpPoint *points,
  7280. INT count
  7281. )
  7282. {
  7283. API_ENTRY(GdipTransformPointsI);
  7284. CheckParameter(points && count > 0);
  7285. CheckParameterValid(graphics);
  7286. CheckObjectBusy(graphics);
  7287. INT i;
  7288. StackBuffer buffer;
  7289. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7290. if(!pointsF) return OutOfMemory;
  7291. for (i=0; i<count; i++)
  7292. {
  7293. pointsF[i].X = TOREAL(points[i].X);
  7294. pointsF[i].Y = TOREAL(points[i].Y);
  7295. }
  7296. GpStatus status = graphics->TransformPoints(pointsF, count, srcSpace, destSpace);
  7297. for (i=0; i<count; i++)
  7298. {
  7299. points[i].X = GpRound(pointsF[i].X);
  7300. points[i].Y = GpRound(pointsF[i].Y);
  7301. }
  7302. return status;
  7303. }
  7304. //------------------------------------------------------------------------
  7305. // GetNearestColor (for <= 8bpp surfaces)
  7306. //------------------------------------------------------------------------
  7307. GpStatus
  7308. WINGDIPAPI
  7309. GdipGetNearestColor(
  7310. GpGraphics *graphics,
  7311. ARGB *argb
  7312. )
  7313. {
  7314. API_ENTRY(GdipGetNearestColor);
  7315. CheckParameter(argb);
  7316. CheckColorParameter(*argb);
  7317. CheckParameterValid(graphics);
  7318. CheckObjectBusy(graphics);
  7319. ARGB temp = graphics->GetNearestColor(*argb);
  7320. *argb = temp;
  7321. return Ok;
  7322. }
  7323. // defined in Engine\render\Halftone.cpp
  7324. extern HPALETTE WINGDIPAPI GdipCreateHalftonePalette();
  7325. GpStatus
  7326. WINGDIPAPI
  7327. GdipDrawLine(
  7328. GpGraphics *graphics,
  7329. GpPen *pen,
  7330. REAL x1,
  7331. REAL y1,
  7332. REAL x2,
  7333. REAL y2
  7334. )
  7335. {
  7336. API_ENTRY(GdipDrawLine);
  7337. CheckParameterValid(graphics);
  7338. CheckObjectBusy(graphics);
  7339. CheckParameterValid(pen);
  7340. CheckObjectBusy(pen);
  7341. return graphics->DrawLine(pen, x1, y1, x2, y2);
  7342. }
  7343. GpStatus
  7344. WINGDIPAPI
  7345. GdipDrawLineI(
  7346. GpGraphics *graphics,
  7347. GpPen *pen,
  7348. INT x1,
  7349. INT y1,
  7350. INT x2,
  7351. INT y2
  7352. )
  7353. {
  7354. API_ENTRY(GdipDrawLineI);
  7355. return GdipDrawLine(graphics, pen, TOREAL(x1), TOREAL(y1), TOREAL(x2), TOREAL(y2));
  7356. }
  7357. GpStatus
  7358. WINGDIPAPI
  7359. GdipDrawLines(
  7360. GpGraphics *graphics,
  7361. GpPen *pen,
  7362. GDIPCONST GpPointF *points,
  7363. INT count
  7364. )
  7365. {
  7366. API_ENTRY(GdipDrawLines);
  7367. CheckParameter(points && count > 0);
  7368. CheckParameterValid(graphics);
  7369. CheckObjectBusy(graphics);
  7370. CheckParameterValid(pen);
  7371. CheckObjectBusy(pen);
  7372. return graphics->DrawLines(pen, points, count);
  7373. }
  7374. GpStatus
  7375. WINGDIPAPI
  7376. GdipDrawLinesI(
  7377. GpGraphics *graphics,
  7378. GpPen *pen,
  7379. GDIPCONST GpPoint *points,
  7380. INT count
  7381. )
  7382. {
  7383. API_ENTRY(GdipDrawLinesI);
  7384. StackBuffer buffer;
  7385. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7386. if(!pointsF) return OutOfMemory;
  7387. for (INT i=0; i<count; i++)
  7388. {
  7389. pointsF[i].X = TOREAL(points[i].X);
  7390. pointsF[i].Y = TOREAL(points[i].Y);
  7391. }
  7392. GpStatus status = GdipDrawLines(graphics, pen, pointsF, count);
  7393. return status;
  7394. }
  7395. GpStatus
  7396. WINGDIPAPI
  7397. GdipDrawArc(
  7398. GpGraphics *graphics,
  7399. GpPen *pen,
  7400. REAL x,
  7401. REAL y,
  7402. REAL width,
  7403. REAL height,
  7404. REAL startAngle,
  7405. REAL sweepAngle
  7406. )
  7407. {
  7408. API_ENTRY(GdipDrawArc);
  7409. CheckParameterValid(graphics);
  7410. CheckObjectBusy(graphics);
  7411. CheckParameterValid(pen);
  7412. CheckObjectBusy(pen);
  7413. return graphics->DrawArc(pen, x, y, width, height, startAngle, sweepAngle);
  7414. }
  7415. GpStatus
  7416. WINGDIPAPI
  7417. GdipDrawArcI(
  7418. GpGraphics *graphics,
  7419. GpPen *pen,
  7420. INT x,
  7421. INT y,
  7422. INT width,
  7423. INT height,
  7424. REAL startAngle,
  7425. REAL sweepAngle
  7426. )
  7427. {
  7428. API_ENTRY(GdipDrawArcI);
  7429. return GdipDrawArc(graphics, pen, TOREAL(x), TOREAL(y),
  7430. TOREAL(width), TOREAL(height), startAngle, sweepAngle);
  7431. }
  7432. GpStatus
  7433. WINGDIPAPI
  7434. GdipDrawBezier(
  7435. GpGraphics *graphics,
  7436. GpPen *pen,
  7437. REAL x1,
  7438. REAL y1,
  7439. REAL x2,
  7440. REAL y2,
  7441. REAL x3,
  7442. REAL y3,
  7443. REAL x4,
  7444. REAL y4
  7445. )
  7446. {
  7447. API_ENTRY(GdipDrawBezier);
  7448. CheckParameterValid(graphics);
  7449. CheckObjectBusy(graphics);
  7450. CheckParameterValid(pen);
  7451. CheckObjectBusy(pen);
  7452. return graphics->DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
  7453. }
  7454. GpStatus
  7455. WINGDIPAPI
  7456. GdipDrawBezierI(
  7457. GpGraphics *graphics,
  7458. GpPen *pen,
  7459. INT x1,
  7460. INT y1,
  7461. INT x2,
  7462. INT y2,
  7463. INT x3,
  7464. INT y3,
  7465. INT x4,
  7466. INT y4
  7467. )
  7468. {
  7469. API_ENTRY(GdipDrawBezierI);
  7470. return GdipDrawBezier(graphics, pen, TOREAL(x1), TOREAL(y1),
  7471. TOREAL(x2), TOREAL(y2), TOREAL(x3), TOREAL(y3),
  7472. TOREAL(x4), TOREAL(y4));
  7473. }
  7474. GpStatus
  7475. WINGDIPAPI
  7476. GdipDrawBeziers(
  7477. GpGraphics *graphics,
  7478. GpPen *pen,
  7479. GDIPCONST GpPointF *points,
  7480. INT count
  7481. )
  7482. {
  7483. API_ENTRY(GdipDrawBeziers);
  7484. CheckParameter(points && count > 0);
  7485. CheckParameterValid(graphics);
  7486. CheckObjectBusy(graphics);
  7487. CheckParameterValid(pen);
  7488. CheckObjectBusy(pen);
  7489. return graphics->DrawBeziers(pen, points, count);
  7490. }
  7491. GpStatus
  7492. WINGDIPAPI
  7493. GdipDrawBeziersI(
  7494. GpGraphics *graphics,
  7495. GpPen *pen,
  7496. GDIPCONST GpPoint *points,
  7497. INT count
  7498. )
  7499. {
  7500. API_ENTRY(GdipDrawBeziersI);
  7501. // Must check these parameters because we use them before calling into
  7502. // GdipDrawBeziers
  7503. CheckParameter(points && count > 0);
  7504. StackBuffer buffer;
  7505. GpPointF* pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7506. if(!pointsF) return OutOfMemory;
  7507. for (INT i=0; i<count; i++)
  7508. {
  7509. pointsF[i].X = TOREAL(points[i].X);
  7510. pointsF[i].Y = TOREAL(points[i].Y);
  7511. }
  7512. GpStatus status = GdipDrawBeziers(graphics, pen, pointsF, count);
  7513. return status;
  7514. }
  7515. GpStatus
  7516. WINGDIPAPI
  7517. GdipDrawRectangle(
  7518. GpGraphics *graphics,
  7519. GpPen *pen,
  7520. REAL x,
  7521. REAL y,
  7522. REAL width,
  7523. REAL height)
  7524. {
  7525. API_ENTRY(GdipDrawRectangle);
  7526. CheckParameterValid(graphics);
  7527. CheckObjectBusy(graphics);
  7528. CheckParameterValid(pen);
  7529. CheckObjectBusy(pen);
  7530. return graphics->DrawRect(pen, x, y, width, height);
  7531. }
  7532. GpStatus
  7533. WINGDIPAPI
  7534. GdipDrawRectangleI(
  7535. GpGraphics *graphics,
  7536. GpPen *pen,
  7537. INT x,
  7538. INT y,
  7539. INT width,
  7540. INT height)
  7541. {
  7542. API_ENTRY(GdipDrawRectangleI);
  7543. return GdipDrawRectangle(graphics, pen,
  7544. TOREAL(x), TOREAL(y),
  7545. TOREAL(width), TOREAL(height));
  7546. }
  7547. GpStatus
  7548. WINGDIPAPI
  7549. GdipDrawRectangles(
  7550. GpGraphics *graphics,
  7551. GpPen *pen,
  7552. GDIPCONST GpRectF *rects,
  7553. INT count
  7554. )
  7555. {
  7556. API_ENTRY(GdipDrawRectangles);
  7557. CheckParameter(rects && count > 0);
  7558. CheckParameterValid(graphics);
  7559. CheckObjectBusy(graphics);
  7560. CheckParameterValid(pen);
  7561. CheckObjectBusy(pen);
  7562. return graphics->DrawRects(pen, rects, count);
  7563. }
  7564. GpStatus
  7565. WINGDIPAPI
  7566. GdipDrawRectanglesI(
  7567. GpGraphics *graphics,
  7568. GpPen *pen,
  7569. GDIPCONST GpRect *rects,
  7570. INT count
  7571. )
  7572. {
  7573. API_ENTRY(GdipDrawRectanglesI);
  7574. CheckParameter(rects && count > 0);
  7575. StackBuffer buffer;
  7576. GpRectF *rectsF = (GpRectF*) buffer.GetBuffer(count*sizeof(GpRectF));
  7577. if(!rectsF) return OutOfMemory;
  7578. for (INT i=0; i<count; i++)
  7579. {
  7580. rectsF[i].X = TOREAL(rects[i].X);
  7581. rectsF[i].Y = TOREAL(rects[i].Y);
  7582. rectsF[i].Width = TOREAL(rects[i].Width);
  7583. rectsF[i].Height = TOREAL(rects[i].Height);
  7584. }
  7585. GpStatus status = GdipDrawRectangles(graphics, pen, rectsF, count);
  7586. return status;
  7587. }
  7588. GpStatus
  7589. WINGDIPAPI
  7590. GdipDrawEllipse(
  7591. GpGraphics *graphics,
  7592. GpPen *pen,
  7593. REAL x,
  7594. REAL y,
  7595. REAL width,
  7596. REAL height
  7597. )
  7598. {
  7599. API_ENTRY(GdipDrawEllipse);
  7600. CheckParameterValid(graphics);
  7601. CheckObjectBusy(graphics);
  7602. CheckParameterValid(pen);
  7603. CheckObjectBusy(pen);
  7604. return graphics->DrawEllipse(pen, x, y, width, height);
  7605. }
  7606. GpStatus
  7607. WINGDIPAPI
  7608. GdipDrawEllipseI(
  7609. GpGraphics *graphics,
  7610. GpPen *pen,
  7611. INT x,
  7612. INT y,
  7613. INT width,
  7614. INT height
  7615. )
  7616. {
  7617. API_ENTRY(GdipDrawEllipseI);
  7618. return GdipDrawEllipse(graphics, pen,
  7619. TOREAL(x), TOREAL(y),
  7620. TOREAL(width), TOREAL(height));
  7621. }
  7622. GpStatus
  7623. WINGDIPAPI
  7624. GdipDrawPie(
  7625. GpGraphics *graphics,
  7626. GpPen *pen,
  7627. REAL x,
  7628. REAL y,
  7629. REAL width,
  7630. REAL height,
  7631. REAL startAngle,
  7632. REAL sweepAngle
  7633. )
  7634. {
  7635. API_ENTRY(GdipDrawPie);
  7636. CheckParameterValid(graphics);
  7637. CheckObjectBusy(graphics);
  7638. CheckParameterValid(pen);
  7639. CheckObjectBusy(pen);
  7640. return graphics->DrawPie(pen, x, y, width, height, startAngle, sweepAngle);
  7641. }
  7642. GpStatus
  7643. WINGDIPAPI
  7644. GdipDrawPieI(
  7645. GpGraphics *graphics,
  7646. GpPen *pen,
  7647. INT x,
  7648. INT y,
  7649. INT width,
  7650. INT height,
  7651. REAL startAngle,
  7652. REAL sweepAngle
  7653. )
  7654. {
  7655. API_ENTRY(GdipDrawPieI);
  7656. return GdipDrawPie(graphics, pen,
  7657. TOREAL(x), TOREAL(y),
  7658. TOREAL(width), TOREAL(height),
  7659. startAngle, sweepAngle);
  7660. }
  7661. GpStatus
  7662. WINGDIPAPI
  7663. GdipDrawPolygon(
  7664. GpGraphics *graphics,
  7665. GpPen *pen,
  7666. GDIPCONST GpPointF *points,
  7667. INT count)
  7668. {
  7669. API_ENTRY(GdipDrawPolygon);
  7670. CheckParameter(points && count > 0);
  7671. CheckParameterValid(graphics);
  7672. CheckObjectBusy(graphics);
  7673. CheckParameterValid(pen);
  7674. CheckObjectBusy(pen);
  7675. return graphics->DrawPolygon(pen, points, count);
  7676. }
  7677. GpStatus
  7678. WINGDIPAPI
  7679. GdipDrawPolygonI(
  7680. GpGraphics *graphics,
  7681. GpPen *pen,
  7682. GDIPCONST GpPoint *points,
  7683. INT count)
  7684. {
  7685. API_ENTRY(GdipDrawPolygonI);
  7686. StackBuffer buffer;
  7687. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7688. if(!pointsF) return OutOfMemory;
  7689. for (INT i=0; i<count; i++)
  7690. {
  7691. pointsF[i].X = TOREAL(points[i].X);
  7692. pointsF[i].Y = TOREAL(points[i].Y);
  7693. }
  7694. GpStatus status = GdipDrawPolygon(graphics, pen, pointsF, count);
  7695. return status;
  7696. }
  7697. GpStatus
  7698. WINGDIPAPI
  7699. GdipDrawPath(
  7700. GpGraphics *graphics,
  7701. GpPen *pen,
  7702. GpPath *path)
  7703. {
  7704. API_ENTRY(GdipDrawPath);
  7705. CheckParameterValid(graphics);
  7706. CheckObjectBusy(graphics);
  7707. CheckParameterValid(pen);
  7708. CheckObjectBusy(pen);
  7709. CheckParameterValid(path);
  7710. CheckObjectBusy(path);
  7711. return graphics->DrawPath(pen, path);
  7712. }
  7713. GpStatus
  7714. WINGDIPAPI
  7715. GdipDrawCurve(
  7716. GpGraphics *graphics,
  7717. GpPen *pen,
  7718. GDIPCONST GpPointF *points,
  7719. INT count
  7720. )
  7721. {
  7722. API_ENTRY(GdipDrawCurve);
  7723. CheckParameter(points && count > 0);
  7724. CheckParameterValid(graphics);
  7725. CheckObjectBusy(graphics);
  7726. CheckParameterValid(pen);
  7727. CheckObjectBusy(pen);
  7728. return graphics->DrawCurve(pen, points, count);
  7729. }
  7730. GpStatus
  7731. WINGDIPAPI
  7732. GdipDrawCurveI(
  7733. GpGraphics *graphics,
  7734. GpPen *pen,
  7735. GDIPCONST GpPoint *points,
  7736. INT count
  7737. )
  7738. {
  7739. API_ENTRY(GdipDrawCurveI);
  7740. StackBuffer buffer;
  7741. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7742. if(!pointsF) return OutOfMemory;
  7743. for (INT i=0; i<count; i++)
  7744. {
  7745. pointsF[i].X = TOREAL(points[i].X);
  7746. pointsF[i].Y = TOREAL(points[i].Y);
  7747. }
  7748. GpStatus status = GdipDrawCurve(graphics, pen, pointsF, count);
  7749. return status;
  7750. }
  7751. GpStatus
  7752. WINGDIPAPI
  7753. GdipDrawCurve2(
  7754. GpGraphics *graphics,
  7755. GpPen *pen,
  7756. GDIPCONST GpPointF *points,
  7757. INT count,
  7758. REAL tension
  7759. )
  7760. {
  7761. API_ENTRY(GdipDrawCurve2);
  7762. CheckParameter(points && count > 0);
  7763. CheckParameterValid(graphics);
  7764. CheckObjectBusy(graphics);
  7765. CheckParameterValid(pen);
  7766. CheckObjectBusy(pen);
  7767. return graphics->DrawCurve(pen, points, count, tension, 0, count - 1);
  7768. }
  7769. GpStatus
  7770. WINGDIPAPI
  7771. GdipDrawCurve2I(
  7772. GpGraphics *graphics,
  7773. GpPen *pen,
  7774. GDIPCONST GpPoint *points,
  7775. INT count,
  7776. REAL tension
  7777. )
  7778. {
  7779. API_ENTRY(GdipDrawCurve2I);
  7780. StackBuffer buffer;
  7781. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7782. if(!pointsF) return OutOfMemory;
  7783. for (INT i=0; i<count; i++)
  7784. {
  7785. pointsF[i].X = TOREAL(points[i].X);
  7786. pointsF[i].Y = TOREAL(points[i].Y);
  7787. }
  7788. GpStatus status = GdipDrawCurve2(graphics, pen, pointsF, count, tension);
  7789. return status;
  7790. }
  7791. GpStatus
  7792. WINGDIPAPI
  7793. GdipDrawCurve3(
  7794. GpGraphics *graphics,
  7795. GpPen *pen,
  7796. GDIPCONST GpPointF *points,
  7797. INT count,
  7798. INT offset,
  7799. INT numberOfSegments,
  7800. REAL tension
  7801. )
  7802. {
  7803. API_ENTRY(GdipDrawCurve3);
  7804. CheckParameter(points && count > 0);
  7805. CheckParameterValid(graphics);
  7806. CheckObjectBusy(graphics);
  7807. CheckParameterValid(pen);
  7808. CheckObjectBusy(pen);
  7809. return graphics->DrawCurve(pen, points, count, tension,
  7810. offset, numberOfSegments);
  7811. }
  7812. GpStatus
  7813. WINGDIPAPI
  7814. GdipDrawCurve3I(
  7815. GpGraphics *graphics,
  7816. GpPen *pen,
  7817. GDIPCONST GpPoint *points,
  7818. INT count,
  7819. INT offset,
  7820. INT numberOfSegments,
  7821. REAL tension
  7822. )
  7823. {
  7824. API_ENTRY(GdipDrawCurve3I);
  7825. StackBuffer buffer;
  7826. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7827. if(!pointsF) return OutOfMemory;
  7828. for (INT i=0; i<count; i++)
  7829. {
  7830. pointsF[i].X = TOREAL(points[i].X);
  7831. pointsF[i].Y = TOREAL(points[i].Y);
  7832. }
  7833. GpStatus status = GdipDrawCurve3(graphics, pen, pointsF, count,
  7834. offset, numberOfSegments, tension);
  7835. return status;
  7836. }
  7837. GpStatus
  7838. WINGDIPAPI
  7839. GdipDrawClosedCurve(
  7840. GpGraphics *graphics,
  7841. GpPen *pen,
  7842. GDIPCONST GpPointF *points,
  7843. INT count)
  7844. {
  7845. API_ENTRY(GdipDrawClosedCurve);
  7846. CheckParameter(points && count > 0);
  7847. CheckParameterValid(graphics);
  7848. CheckObjectBusy(graphics);
  7849. CheckParameterValid(pen);
  7850. CheckObjectBusy(pen);
  7851. return graphics->DrawClosedCurve(pen, points, count);
  7852. }
  7853. GpStatus
  7854. WINGDIPAPI
  7855. GdipDrawClosedCurveI(
  7856. GpGraphics *graphics,
  7857. GpPen *pen,
  7858. GDIPCONST GpPoint *points,
  7859. INT count)
  7860. {
  7861. API_ENTRY(GdipDrawClosedCurveI);
  7862. StackBuffer buffer;
  7863. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7864. if(!pointsF) return OutOfMemory;
  7865. for (INT i=0; i<count; i++)
  7866. {
  7867. pointsF[i].X = TOREAL(points[i].X);
  7868. pointsF[i].Y = TOREAL(points[i].Y);
  7869. }
  7870. GpStatus status = GdipDrawClosedCurve(graphics, pen, pointsF, count);
  7871. return status;
  7872. }
  7873. GpStatus
  7874. WINGDIPAPI
  7875. GdipDrawClosedCurve2(
  7876. GpGraphics *graphics,
  7877. GpPen *pen,
  7878. GDIPCONST GpPointF *points,
  7879. INT count,
  7880. REAL tension)
  7881. {
  7882. API_ENTRY(GdipDrawClosedCurve2);
  7883. CheckParameter(points && count > 0);
  7884. CheckParameterValid(graphics);
  7885. CheckObjectBusy(graphics);
  7886. CheckParameterValid(pen);
  7887. CheckObjectBusy(pen);
  7888. return graphics->DrawClosedCurve(pen, points, count, tension);
  7889. }
  7890. GpStatus
  7891. WINGDIPAPI
  7892. GdipDrawClosedCurve2I(
  7893. GpGraphics *graphics,
  7894. GpPen *pen,
  7895. GDIPCONST GpPoint *points,
  7896. INT count,
  7897. REAL tension)
  7898. {
  7899. API_ENTRY(GdipDrawClosedCurve2I);
  7900. StackBuffer buffer;
  7901. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  7902. if(!pointsF) return OutOfMemory;
  7903. for (INT i=0; i<count; i++)
  7904. {
  7905. pointsF[i].X = TOREAL(points[i].X);
  7906. pointsF[i].Y = TOREAL(points[i].Y);
  7907. }
  7908. GpStatus status = GdipDrawClosedCurve2(graphics, pen, pointsF, count, tension);
  7909. return status;
  7910. }
  7911. GpStatus WINGDIPAPI
  7912. GdipGraphicsClear(
  7913. GpGraphics *graphics,
  7914. ARGB color)
  7915. {
  7916. API_ENTRY(GdipGraphicsClear);
  7917. CheckColorParameter(color);
  7918. CheckParameterValid(graphics);
  7919. CheckObjectBusy(graphics);
  7920. return graphics->Clear(GpColor(color));
  7921. }
  7922. GpStatus
  7923. WINGDIPAPI
  7924. GdipFillRectangle(
  7925. GpGraphics *graphics,
  7926. GpBrush *fill,
  7927. REAL x,
  7928. REAL y,
  7929. REAL width,
  7930. REAL height)
  7931. {
  7932. API_ENTRY(GdipFillRectangle);
  7933. CheckParameterValid(graphics);
  7934. CheckObjectBusy(graphics);
  7935. CheckParameterValid(fill);
  7936. CheckObjectBusy(fill);
  7937. return graphics->FillRect(fill, x, y, width, height);
  7938. }
  7939. GpStatus
  7940. WINGDIPAPI
  7941. GdipFillRectangleI(
  7942. GpGraphics *graphics,
  7943. GpBrush *fill,
  7944. INT x,
  7945. INT y,
  7946. INT width,
  7947. INT height)
  7948. {
  7949. API_ENTRY(GdipFillRectangleI);
  7950. return GdipFillRectangle(graphics, fill, TOREAL(x), TOREAL(y), TOREAL(width), TOREAL(height));
  7951. }
  7952. GpStatus
  7953. WINGDIPAPI
  7954. GdipFillRectangles(
  7955. GpGraphics *graphics,
  7956. GpBrush *fill,
  7957. GDIPCONST GpRectF *rects,
  7958. INT count)
  7959. {
  7960. API_ENTRY(GdipFillRectangles);
  7961. CheckParameter(rects && count > 0);
  7962. CheckParameterValid(graphics);
  7963. CheckObjectBusy(graphics);
  7964. CheckParameterValid(fill);
  7965. CheckObjectBusy(fill);
  7966. return graphics->FillRects(fill, rects, count);
  7967. }
  7968. GpStatus
  7969. WINGDIPAPI
  7970. GdipFillRectanglesI(
  7971. GpGraphics *graphics,
  7972. GpBrush *fill,
  7973. GDIPCONST GpRect *rects,
  7974. INT count)
  7975. {
  7976. API_ENTRY(GdipFillRectanglesI);
  7977. StackBuffer buffer;
  7978. GpRectF *rectsF = (GpRectF*) buffer.GetBuffer(count*sizeof(GpRectF));
  7979. if(!rectsF) return OutOfMemory;
  7980. for (INT i=0; i<count; i++)
  7981. {
  7982. rectsF[i].X = TOREAL(rects[i].X);
  7983. rectsF[i].Y = TOREAL(rects[i].Y);
  7984. rectsF[i].Width = TOREAL(rects[i].Width);
  7985. rectsF[i].Height = TOREAL(rects[i].Height);
  7986. }
  7987. GpStatus status = GdipFillRectangles(graphics, fill, rectsF, count);
  7988. return status;
  7989. }
  7990. GpStatus
  7991. WINGDIPAPI
  7992. GdipFillPolygon(
  7993. GpGraphics *graphics,
  7994. GpBrush *fill,
  7995. GDIPCONST GpPointF *points,
  7996. INT count,
  7997. GpFillMode fillMode
  7998. )
  7999. {
  8000. API_ENTRY(GdipFillPolygon);
  8001. CheckParameter(points && count > 0);
  8002. CheckParameterValid(graphics);
  8003. CheckObjectBusy(graphics);
  8004. CheckParameterValid(fill);
  8005. CheckObjectBusy(fill);
  8006. return graphics->FillPolygon(fill, points, count, fillMode);
  8007. }
  8008. GpStatus
  8009. WINGDIPAPI
  8010. GdipFillPolygonI(
  8011. GpGraphics *graphics,
  8012. GpBrush *fill,
  8013. GDIPCONST GpPoint *points,
  8014. INT count,
  8015. GpFillMode fillMode
  8016. )
  8017. {
  8018. API_ENTRY(GdipFillPolygonI);
  8019. StackBuffer buffer;
  8020. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8021. if(!pointsF) return OutOfMemory;
  8022. for (INT i=0; i<count; i++)
  8023. {
  8024. pointsF[i].X = TOREAL(points[i].X);
  8025. pointsF[i].Y = TOREAL(points[i].Y);
  8026. }
  8027. GpStatus status = GdipFillPolygon(graphics, fill, pointsF, count, fillMode);
  8028. return status;
  8029. }
  8030. GpStatus
  8031. WINGDIPAPI
  8032. GdipFillPolygon2(
  8033. GpGraphics *graphics,
  8034. GpBrush *fill,
  8035. GDIPCONST GpPointF *points,
  8036. INT count
  8037. )
  8038. {
  8039. API_ENTRY(GdipFillPolygon2);
  8040. CheckParameter(points && count > 0);
  8041. CheckParameterValid(graphics);
  8042. CheckObjectBusy(graphics);
  8043. CheckParameterValid(fill);
  8044. CheckObjectBusy(fill);
  8045. return graphics->FillPolygon(fill, points, count);
  8046. }
  8047. GpStatus
  8048. WINGDIPAPI
  8049. GdipFillPolygon2I(
  8050. GpGraphics *graphics,
  8051. GpBrush *fill,
  8052. GDIPCONST GpPoint *points,
  8053. INT count
  8054. )
  8055. {
  8056. API_ENTRY(GdipFillPolygon2I);
  8057. StackBuffer buffer;
  8058. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8059. if(!pointsF) return OutOfMemory;
  8060. for (INT i=0; i<count; i++)
  8061. {
  8062. pointsF[i].X = TOREAL(points[i].X);
  8063. pointsF[i].Y = TOREAL(points[i].Y);
  8064. }
  8065. GpStatus status = GdipFillPolygon2(graphics, fill, pointsF, count);
  8066. return status;
  8067. }
  8068. GpStatus
  8069. WINGDIPAPI
  8070. GdipFillEllipse(
  8071. GpGraphics *graphics,
  8072. GpBrush *fill,
  8073. REAL x,
  8074. REAL y,
  8075. REAL width,
  8076. REAL height
  8077. )
  8078. {
  8079. API_ENTRY(GdipFillEllipse);
  8080. CheckParameterValid(graphics);
  8081. CheckObjectBusy(graphics);
  8082. CheckParameterValid(fill);
  8083. CheckObjectBusy(fill);
  8084. return graphics->FillEllipse(fill, x, y, width, height);
  8085. }
  8086. GpStatus
  8087. WINGDIPAPI
  8088. GdipFillEllipseI(
  8089. GpGraphics *graphics,
  8090. GpBrush *fill,
  8091. INT x,
  8092. INT y,
  8093. INT width,
  8094. INT height
  8095. )
  8096. {
  8097. API_ENTRY(GdipFillEllipseI);
  8098. return GdipFillEllipse(graphics, fill, TOREAL(x), TOREAL(y),
  8099. TOREAL(width), TOREAL(height));
  8100. }
  8101. GpStatus
  8102. WINGDIPAPI
  8103. GdipFillPie(
  8104. GpGraphics *graphics,
  8105. GpBrush *fill,
  8106. REAL x,
  8107. REAL y,
  8108. REAL width,
  8109. REAL height,
  8110. REAL startAngle,
  8111. REAL sweepAngle
  8112. )
  8113. {
  8114. API_ENTRY(GdipFillPie);
  8115. CheckParameterValid(graphics);
  8116. CheckObjectBusy(graphics);
  8117. CheckParameterValid(fill);
  8118. CheckObjectBusy(fill);
  8119. return graphics->FillPie(fill, x, y, width, height, startAngle, sweepAngle);
  8120. }
  8121. GpStatus
  8122. WINGDIPAPI
  8123. GdipFillPieI(
  8124. GpGraphics *graphics,
  8125. GpBrush *fill,
  8126. INT x,
  8127. INT y,
  8128. INT width,
  8129. INT height,
  8130. REAL startAngle,
  8131. REAL sweepAngle
  8132. )
  8133. {
  8134. API_ENTRY(GdipFillPieI);
  8135. return GdipFillPie(graphics, fill, TOREAL(x), TOREAL(y),
  8136. TOREAL(width), TOREAL(height), startAngle, sweepAngle);
  8137. }
  8138. GpStatus
  8139. WINGDIPAPI
  8140. GdipFillPath(
  8141. GpGraphics *graphics,
  8142. GpBrush *fill,
  8143. GpPath *path
  8144. )
  8145. {
  8146. API_ENTRY(GdipFillPath);
  8147. CheckParameterValid(graphics);
  8148. CheckObjectBusy(graphics);
  8149. CheckParameterValid(fill);
  8150. CheckObjectBusy(fill);
  8151. CheckParameterValid(path);
  8152. CheckObjectBusy(path);
  8153. return graphics->FillPath(fill, path);
  8154. }
  8155. GpStatus
  8156. WINGDIPAPI
  8157. GdipFillClosedCurve(
  8158. GpGraphics *graphics,
  8159. GpBrush *fill,
  8160. GDIPCONST GpPointF *points,
  8161. INT count
  8162. )
  8163. {
  8164. API_ENTRY(GdipFillClosedCurve);
  8165. CheckParameter(points && count > 0);
  8166. CheckParameterValid(graphics);
  8167. CheckObjectBusy(graphics);
  8168. CheckParameterValid(fill);
  8169. CheckObjectBusy(fill);
  8170. return graphics->FillClosedCurve(fill, points, count);
  8171. }
  8172. GpStatus
  8173. WINGDIPAPI
  8174. GdipFillClosedCurveI(
  8175. GpGraphics *graphics,
  8176. GpBrush *fill,
  8177. GDIPCONST GpPoint *points,
  8178. INT count
  8179. )
  8180. {
  8181. API_ENTRY(GdipFillClosedCurveI);
  8182. StackBuffer buffer;
  8183. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8184. if(!pointsF) return OutOfMemory;
  8185. for (INT i=0; i<count; i++)
  8186. {
  8187. pointsF[i].X = TOREAL(points[i].X);
  8188. pointsF[i].Y = TOREAL(points[i].Y);
  8189. }
  8190. GpStatus status = GdipFillClosedCurve(graphics, fill, pointsF, count);
  8191. return status;
  8192. }
  8193. GpStatus
  8194. WINGDIPAPI
  8195. GdipFillClosedCurve2(
  8196. GpGraphics *graphics,
  8197. GpBrush *fill,
  8198. GDIPCONST GpPointF *points,
  8199. INT count,
  8200. REAL tension,
  8201. GpFillMode fillMode
  8202. )
  8203. {
  8204. API_ENTRY(GdipFillClosedCurve2);
  8205. CheckParameter(points && count > 0);
  8206. CheckParameterValid(graphics);
  8207. CheckObjectBusy(graphics);
  8208. CheckParameterValid(fill);
  8209. CheckObjectBusy(fill);
  8210. return graphics->FillClosedCurve(fill, points, count, tension, fillMode);
  8211. }
  8212. GpStatus
  8213. WINGDIPAPI
  8214. GdipFillClosedCurve2I(
  8215. GpGraphics *graphics,
  8216. GpBrush *fill,
  8217. GDIPCONST GpPoint *points,
  8218. INT count,
  8219. REAL tension,
  8220. GpFillMode fillMode
  8221. )
  8222. {
  8223. API_ENTRY(GdipFillClosedCurve2I);
  8224. StackBuffer buffer;
  8225. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8226. if(!pointsF) return OutOfMemory;
  8227. for (INT i=0; i<count; i++)
  8228. {
  8229. pointsF[i].X = TOREAL(points[i].X);
  8230. pointsF[i].Y = TOREAL(points[i].Y);
  8231. }
  8232. GpStatus status = GdipFillClosedCurve2(graphics, fill, pointsF, count, tension, fillMode);
  8233. return status;
  8234. }
  8235. GpStatus
  8236. WINGDIPAPI
  8237. GdipFillRegion(
  8238. GpGraphics *graphics,
  8239. GpBrush *fill,
  8240. GpRegion *region
  8241. )
  8242. {
  8243. API_ENTRY(GdipFillRegion);
  8244. CheckParameterValid(graphics);
  8245. CheckObjectBusy(graphics);
  8246. CheckParameterValid(fill);
  8247. CheckObjectBusy(fill);
  8248. CheckParameterValid(region);
  8249. CheckObjectBusy(region);
  8250. return graphics->FillRegion(fill, region);
  8251. }
  8252. GpStatus
  8253. WINGDIPAPI
  8254. GdipDrawString(
  8255. GpGraphics *graphics,
  8256. GDIPCONST WCHAR *string,
  8257. INT length,
  8258. GDIPCONST GpFont *font,
  8259. GDIPCONST RectF *layoutRect,
  8260. GDIPCONST GpStringFormat *stringFormat,
  8261. GDIPCONST GpBrush *brush
  8262. )
  8263. {
  8264. API_ENTRY(GdipDrawString);
  8265. CheckParameter(string && layoutRect);
  8266. CheckParameterValid(graphics);
  8267. CheckObjectBusy(graphics);
  8268. CheckParameterValid(brush);
  8269. CheckObjectBusy(brush);
  8270. if (EmptyString(string, length))
  8271. {
  8272. return Ok;
  8273. }
  8274. GlobalTextLock lock;
  8275. CheckParameterValid(font);
  8276. CheckOptionalParameterValid(stringFormat);
  8277. return graphics->DrawString(
  8278. string,
  8279. length,
  8280. font,
  8281. layoutRect,
  8282. stringFormat,
  8283. brush);
  8284. }
  8285. GpStatus
  8286. WINGDIPAPI
  8287. GdipMeasureString(
  8288. GpGraphics *graphics,
  8289. GDIPCONST WCHAR *string,
  8290. INT length,
  8291. GDIPCONST GpFont *font,
  8292. GDIPCONST RectF *layoutRect,
  8293. GDIPCONST GpStringFormat *stringFormat,
  8294. RectF *boundingBox,
  8295. INT *codepointsFitted, // Optional parameter
  8296. INT *linesFilled // Optional parameter
  8297. )
  8298. {
  8299. API_ENTRY(GdipMeasureString);
  8300. CheckParameter(string && layoutRect && boundingBox);
  8301. CheckParameterValid(graphics);
  8302. CheckObjectBusy(graphics);
  8303. if (EmptyString(string, length))
  8304. {
  8305. SetEmptyRectF(boundingBox);
  8306. if (codepointsFitted)
  8307. *codepointsFitted = 0;
  8308. if (linesFilled)
  8309. *linesFilled = 0;
  8310. return Ok;
  8311. }
  8312. GlobalTextLock lock;
  8313. CheckParameterValid(font);
  8314. CheckOptionalParameterValid(stringFormat);
  8315. return graphics->MeasureString(
  8316. string,
  8317. length,
  8318. font,
  8319. layoutRect,
  8320. stringFormat,
  8321. boundingBox,
  8322. codepointsFitted,
  8323. linesFilled
  8324. );
  8325. }
  8326. GpStatus
  8327. WINGDIPAPI
  8328. GdipMeasureCharacterRanges(
  8329. GpGraphics *graphics,
  8330. GDIPCONST WCHAR *string,
  8331. INT length,
  8332. GDIPCONST GpFont *font,
  8333. GDIPCONST RectF &layoutRect,
  8334. GDIPCONST GpStringFormat *stringFormat,
  8335. INT regionCount,
  8336. GpRegion **regions
  8337. )
  8338. {
  8339. API_ENTRY(GdipMeasureCharacterRanges);
  8340. CheckParameter(string && (&layoutRect));
  8341. CheckParameterValid(graphics);
  8342. CheckObjectBusy(graphics);
  8343. CheckParameterValid(font);
  8344. CheckOptionalParameterValid(stringFormat);
  8345. CheckParameter(regions);
  8346. if (EmptyString(string, length))
  8347. {
  8348. return InvalidParameter;
  8349. }
  8350. GlobalTextLock lock;
  8351. GpStatus status = graphics->MeasureCharacterRanges(
  8352. string,
  8353. length,
  8354. font,
  8355. layoutRect,
  8356. stringFormat,
  8357. regionCount,
  8358. regions
  8359. );
  8360. return status;
  8361. }
  8362. GpStatus
  8363. WINGDIPAPI
  8364. GdipDrawDriverString(
  8365. GpGraphics *graphics,
  8366. GDIPCONST UINT16 *text,
  8367. INT length,
  8368. GDIPCONST GpFont *font,
  8369. GDIPCONST GpBrush *brush,
  8370. GDIPCONST PointF *positions,
  8371. INT flags,
  8372. GDIPCONST GpMatrix *matrix
  8373. )
  8374. {
  8375. API_ENTRY(GdipDrawDriverString);
  8376. CheckParameterValid(graphics);
  8377. CheckObjectBusy(graphics);
  8378. CheckOptionalParameterValid(matrix);
  8379. CheckOptionalObjectBusy(matrix);
  8380. CheckParameterValid(brush);
  8381. CheckObjectBusy(brush);
  8382. CheckParameter(text && positions);
  8383. if (length == -1 && !(flags & DriverStringOptionsCmapLookup))
  8384. {
  8385. return InvalidParameter;
  8386. }
  8387. if (EmptyString(text, length))
  8388. {
  8389. return Ok;
  8390. }
  8391. GlobalTextLock lock;
  8392. CheckParameterValid(font);
  8393. return graphics->DrawDriverString(
  8394. text,
  8395. length,
  8396. font,
  8397. brush,
  8398. positions,
  8399. flags,
  8400. matrix
  8401. );
  8402. }
  8403. GpStatus
  8404. WINGDIPAPI
  8405. GdipMeasureDriverString(
  8406. GpGraphics *graphics,
  8407. GDIPCONST UINT16 *text,
  8408. INT length,
  8409. GDIPCONST GpFont *font,
  8410. GDIPCONST PointF *positions,
  8411. INT flags,
  8412. GDIPCONST GpMatrix *matrix,
  8413. RectF *boundingBox
  8414. )
  8415. {
  8416. API_ENTRY(GdipMeasureDriverString);
  8417. GpStatus status;
  8418. CheckParameterValid(graphics);
  8419. CheckObjectBusy(graphics);
  8420. CheckOptionalParameterValid(matrix);
  8421. CheckOptionalObjectBusy(matrix);
  8422. CheckParameter(text && positions && boundingBox);
  8423. if (length == -1 && !(flags & DriverStringOptionsCmapLookup))
  8424. {
  8425. return InvalidParameter;
  8426. }
  8427. if (EmptyString(text, length))
  8428. {
  8429. SetEmptyRectF(boundingBox);
  8430. return Ok;
  8431. }
  8432. GlobalTextLock lock;
  8433. CheckParameterValid(font);
  8434. return graphics->MeasureDriverString(
  8435. text,
  8436. length,
  8437. font,
  8438. positions,
  8439. flags,
  8440. matrix,
  8441. boundingBox
  8442. );
  8443. }
  8444. GpStatus
  8445. WINGDIPAPI
  8446. GdipGetFamilyName(
  8447. GDIPCONST GpFontFamily *family,
  8448. WCHAR name[LF_FACESIZE],
  8449. LANGID language
  8450. )
  8451. {
  8452. API_ENTRY(GdipGetFamilyName);
  8453. GlobalTextLock lock;
  8454. CheckParameterValid(family);
  8455. return family->GetFamilyName(name, language);
  8456. }
  8457. /// end font/text stuff - move to end
  8458. GpStatus
  8459. WINGDIPAPI
  8460. GdipDrawImage(
  8461. GpGraphics *graphics,
  8462. GpImage *image,
  8463. REAL x,
  8464. REAL y
  8465. )
  8466. {
  8467. API_ENTRY(GdipDrawImage);
  8468. CheckParameterValid(graphics);
  8469. CheckObjectBusy(graphics);
  8470. CheckParameterValid(image);
  8471. CheckObjectBusy(image);
  8472. return graphics->DrawImage(image, x, y);
  8473. }
  8474. GpStatus
  8475. WINGDIPAPI
  8476. GdipDrawImageI(
  8477. GpGraphics *graphics,
  8478. GpImage *image,
  8479. INT x,
  8480. INT y
  8481. )
  8482. {
  8483. API_ENTRY(GdipDrawImageI);
  8484. return GdipDrawImage(graphics, image, TOREAL(x), TOREAL(y));
  8485. }
  8486. GpStatus
  8487. WINGDIPAPI
  8488. GdipDrawImageRect(
  8489. GpGraphics *graphics,
  8490. GpImage *image,
  8491. REAL x,
  8492. REAL y,
  8493. REAL width,
  8494. REAL height
  8495. )
  8496. {
  8497. API_ENTRY(GdipDrawImageRect);
  8498. CheckParameterValid(graphics);
  8499. CheckObjectBusy(graphics);
  8500. CheckParameterValid(image);
  8501. CheckObjectBusy(image);
  8502. return graphics->DrawImage(image, x, y, width, height);
  8503. }
  8504. GpStatus
  8505. WINGDIPAPI
  8506. GdipDrawImageRectI(
  8507. GpGraphics *graphics,
  8508. GpImage *image,
  8509. INT x,
  8510. INT y,
  8511. INT width,
  8512. INT height
  8513. )
  8514. {
  8515. API_ENTRY(GdipDrawImageRectI);
  8516. return GdipDrawImageRect(graphics, image, TOREAL(x), TOREAL(y), TOREAL(width), TOREAL(height));
  8517. }
  8518. GpStatus
  8519. WINGDIPAPI
  8520. GdipDrawImagePoints(
  8521. GpGraphics *graphics,
  8522. GpImage *image,
  8523. GDIPCONST GpPointF *points,
  8524. INT count
  8525. )
  8526. {
  8527. API_ENTRY(GdipDrawImagePoints);
  8528. CheckParameter(points && count > 0);
  8529. CheckParameterValid(graphics);
  8530. CheckObjectBusy(graphics);
  8531. CheckParameterValid(image);
  8532. CheckObjectBusy(image);
  8533. return graphics->DrawImage(image, points, count);
  8534. }
  8535. GpStatus
  8536. WINGDIPAPI
  8537. GdipDrawImagePointsI(
  8538. GpGraphics *graphics,
  8539. GpImage *image,
  8540. GDIPCONST GpPoint *points,
  8541. INT count
  8542. )
  8543. {
  8544. API_ENTRY(GdipDrawImagePointsI);
  8545. CheckParameter(points && count > 0);
  8546. StackBuffer buffer;
  8547. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8548. if(!pointsF) return OutOfMemory;
  8549. for (INT i=0; i<count; i++)
  8550. {
  8551. pointsF[i].X = TOREAL(points[i].X);
  8552. pointsF[i].Y = TOREAL(points[i].Y);
  8553. }
  8554. GpStatus status = GdipDrawImagePoints(graphics, image, pointsF, count);
  8555. return status;
  8556. }
  8557. GpStatus
  8558. WINGDIPAPI
  8559. GdipDrawImagePointRect(
  8560. GpGraphics *graphics,
  8561. GpImage *image,
  8562. REAL x,
  8563. REAL y,
  8564. REAL srcx,
  8565. REAL srcy,
  8566. REAL srcwidth,
  8567. REAL srcheight,
  8568. GpPageUnit srcUnit
  8569. )
  8570. {
  8571. API_ENTRY(GdipDrawImagePointRect);
  8572. CheckParameterValid(graphics);
  8573. CheckObjectBusy(graphics);
  8574. CheckParameterValid(image);
  8575. CheckObjectBusy(image);
  8576. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  8577. // This additional check is required because we don't support the other
  8578. // source units in drawimage yet. RAID 311474
  8579. if(UnitPixel != srcUnit)
  8580. {
  8581. return NotImplemented;
  8582. }
  8583. GpRectF srcRect(srcx, srcy, srcwidth, srcheight);
  8584. return graphics->DrawImage(image, x, y, srcRect, srcUnit);
  8585. }
  8586. GpStatus
  8587. WINGDIPAPI
  8588. GdipDrawImagePointRectI(
  8589. GpGraphics *graphics,
  8590. GpImage *image,
  8591. INT x,
  8592. INT y,
  8593. INT srcx,
  8594. INT srcy,
  8595. INT srcwidth,
  8596. INT srcheight,
  8597. GpPageUnit srcUnit
  8598. )
  8599. {
  8600. API_ENTRY(GdipDrawImagePointRectI);
  8601. return GdipDrawImagePointRect(graphics, image, TOREAL(x), TOREAL(y), TOREAL(srcx),
  8602. TOREAL(srcy), TOREAL(srcwidth), TOREAL(srcheight),
  8603. srcUnit);
  8604. }
  8605. GpStatus
  8606. WINGDIPAPI
  8607. GdipDrawImageRectRect(
  8608. GpGraphics *graphics,
  8609. GpImage *image,
  8610. REAL dstx,
  8611. REAL dsty,
  8612. REAL dstwidth,
  8613. REAL dstheight,
  8614. REAL srcx,
  8615. REAL srcy,
  8616. REAL srcwidth,
  8617. REAL srcheight,
  8618. GpPageUnit srcUnit,
  8619. GDIPCONST GpImageAttributes* imageAttributes,
  8620. DrawImageAbort callback,
  8621. VOID * callbackData
  8622. )
  8623. {
  8624. API_ENTRY(GdipDrawImageRectRect);
  8625. CheckParameterValid(graphics);
  8626. CheckObjectBusy(graphics);
  8627. CheckParameterValid(image);
  8628. CheckObjectBusy(image);
  8629. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  8630. // This additional check is required because we don't support the other
  8631. // source units in drawimage yet. RAID 311474
  8632. if(UnitPixel != srcUnit)
  8633. {
  8634. return NotImplemented;
  8635. }
  8636. CheckOptionalParameterValid(imageAttributes);
  8637. CheckOptionalObjectBusy(imageAttributes);
  8638. GpRectF srcrect(srcx, srcy, srcwidth, srcheight);
  8639. GpRectF destrect(dstx, dsty, dstwidth, dstheight);
  8640. return graphics->DrawImage(image, destrect, srcrect, srcUnit,
  8641. imageAttributes, callback, callbackData);
  8642. }
  8643. GpStatus
  8644. WINGDIPAPI
  8645. GdipDrawImageRectRectI(
  8646. GpGraphics *graphics,
  8647. GpImage *image,
  8648. INT dstx,
  8649. INT dsty,
  8650. INT dstwidth,
  8651. INT dstheight,
  8652. INT srcx,
  8653. INT srcy,
  8654. INT srcwidth,
  8655. INT srcheight,
  8656. GpPageUnit srcUnit,
  8657. GDIPCONST GpImageAttributes* imageAttributes,
  8658. DrawImageAbort callback,
  8659. VOID * callbackData
  8660. )
  8661. {
  8662. API_ENTRY(GdipDrawImageRectRectI);
  8663. return GdipDrawImageRectRect(graphics, image, TOREAL(dstx), TOREAL(dsty),
  8664. TOREAL(dstwidth), TOREAL(dstheight),
  8665. TOREAL(srcx), TOREAL(srcy), TOREAL(srcwidth),
  8666. TOREAL(srcheight), srcUnit,
  8667. imageAttributes, callback, callbackData);
  8668. }
  8669. GpStatus
  8670. WINGDIPAPI
  8671. GdipDrawImagePointsRect(
  8672. GpGraphics *graphics,
  8673. GpImage *image,
  8674. GDIPCONST GpPointF *points,
  8675. INT count,
  8676. REAL srcx,
  8677. REAL srcy,
  8678. REAL srcwidth,
  8679. REAL srcheight,
  8680. GpPageUnit srcUnit,
  8681. GDIPCONST GpImageAttributes* imageAttributes,
  8682. DrawImageAbort callback,
  8683. VOID * callbackData
  8684. )
  8685. {
  8686. API_ENTRY(GdipDrawImagePointsRect);
  8687. CheckParameter(points && count > 0);
  8688. CheckParameterValid(graphics);
  8689. CheckObjectBusy(graphics);
  8690. CheckParameterValid(image);
  8691. CheckObjectBusy(image);
  8692. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  8693. // This additional check is required because we don't support the other
  8694. // source units in drawimage yet. RAID 311474
  8695. if(UnitPixel != srcUnit)
  8696. {
  8697. return NotImplemented;
  8698. }
  8699. CheckOptionalParameterValid(imageAttributes);
  8700. CheckOptionalObjectBusy(imageAttributes);
  8701. GpRectF srcrect(srcx, srcy, srcwidth, srcheight);
  8702. return graphics->DrawImage(image, points, count, srcrect, srcUnit,
  8703. imageAttributes, callback, callbackData);
  8704. }
  8705. GpStatus
  8706. WINGDIPAPI
  8707. GdipDrawImagePointsRectI(
  8708. GpGraphics *graphics,
  8709. GpImage *image,
  8710. GDIPCONST GpPoint *points,
  8711. INT count,
  8712. INT srcx,
  8713. INT srcy,
  8714. INT srcwidth,
  8715. INT srcheight,
  8716. GpPageUnit srcUnit,
  8717. GDIPCONST GpImageAttributes* imageAttributes,
  8718. DrawImageAbort callback,
  8719. VOID * callbackData
  8720. )
  8721. {
  8722. API_ENTRY(GdipDrawImagePointsRectI);
  8723. CheckParameter(points && count > 0);
  8724. StackBuffer buffer;
  8725. GpPointF *pointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8726. if(!pointsF) return OutOfMemory;
  8727. for (INT i=0; i<count; i++)
  8728. {
  8729. pointsF[i].X = TOREAL(points[i].X);
  8730. pointsF[i].Y = TOREAL(points[i].Y);
  8731. }
  8732. GpStatus status = GdipDrawImagePointsRect(
  8733. graphics,
  8734. image,
  8735. pointsF,
  8736. count,
  8737. TOREAL(srcx),
  8738. TOREAL(srcy),
  8739. TOREAL(srcwidth),
  8740. TOREAL(srcheight),
  8741. srcUnit,
  8742. imageAttributes,
  8743. callback,
  8744. callbackData
  8745. );
  8746. return status;
  8747. }
  8748. GpStatus WINGDIPAPI
  8749. GdipEnumerateMetafileDestPoint(
  8750. GpGraphics * graphics,
  8751. GDIPCONST GpMetafile * metafile,
  8752. GDIPCONST PointF & destPoint,
  8753. EnumerateMetafileProc callback,
  8754. VOID * callbackData,
  8755. GDIPCONST GpImageAttributes * imageAttributes
  8756. )
  8757. {
  8758. API_ENTRY(GdipEnumerateMetafileDestPoint);
  8759. CheckParameter(callback);
  8760. CheckParameterValid(graphics);
  8761. CheckObjectBusy(graphics);
  8762. CheckParameterValid(metafile);
  8763. CheckObjectBusy(metafile);
  8764. CheckOptionalParameterValid(imageAttributes);
  8765. CheckOptionalObjectBusy(imageAttributes);
  8766. // Only the current thread can play back records from this enumeration
  8767. metafile->SetThreadId(GetCurrentThreadId());
  8768. return graphics->EnumerateMetafile(
  8769. metafile,
  8770. destPoint,
  8771. callback,
  8772. callbackData,
  8773. imageAttributes
  8774. );
  8775. metafile->SetThreadId(0);
  8776. }
  8777. GpStatus WINGDIPAPI
  8778. GdipEnumerateMetafileDestPointI(
  8779. GpGraphics * graphics,
  8780. GDIPCONST GpMetafile * metafile,
  8781. GDIPCONST Point & destPoint,
  8782. EnumerateMetafileProc callback,
  8783. VOID * callbackData,
  8784. GDIPCONST GpImageAttributes * imageAttributes
  8785. )
  8786. {
  8787. API_ENTRY(GdipEnumerateMetafileDestPointI);
  8788. GpPointF destPointF(TOREAL(destPoint.X), TOREAL(destPoint.Y));
  8789. return GdipEnumerateMetafileDestPoint(
  8790. graphics,
  8791. metafile,
  8792. destPointF,
  8793. callback,
  8794. callbackData,
  8795. imageAttributes
  8796. );
  8797. }
  8798. GpStatus WINGDIPAPI
  8799. GdipEnumerateMetafileDestRect(
  8800. GpGraphics * graphics,
  8801. GDIPCONST GpMetafile * metafile,
  8802. GDIPCONST RectF & destRect,
  8803. EnumerateMetafileProc callback,
  8804. VOID * callbackData,
  8805. GDIPCONST GpImageAttributes * imageAttributes
  8806. )
  8807. {
  8808. API_ENTRY(GdipEnumerateMetafileDestRect);
  8809. CheckParameter(callback);
  8810. CheckParameterValid(graphics);
  8811. CheckObjectBusy(graphics);
  8812. CheckParameterValid(metafile);
  8813. CheckObjectBusy(metafile);
  8814. CheckOptionalParameterValid(imageAttributes);
  8815. CheckOptionalObjectBusy(imageAttributes);
  8816. // Only the current thread can play back records from this enumeration
  8817. metafile->SetThreadId(GetCurrentThreadId());
  8818. return graphics->EnumerateMetafile(
  8819. metafile,
  8820. destRect,
  8821. callback,
  8822. callbackData,
  8823. imageAttributes
  8824. );
  8825. metafile->SetThreadId(0);
  8826. }
  8827. GpStatus WINGDIPAPI
  8828. GdipEnumerateMetafileDestRectI(
  8829. GpGraphics * graphics,
  8830. GDIPCONST GpMetafile * metafile,
  8831. GDIPCONST Rect & destRect,
  8832. EnumerateMetafileProc callback,
  8833. VOID * callbackData,
  8834. GDIPCONST GpImageAttributes * imageAttributes
  8835. )
  8836. {
  8837. API_ENTRY(GdipEnumerateMetafileDestRectI);
  8838. GpRectF destRectF(TOREAL(destRect.X), TOREAL(destRect.Y),
  8839. TOREAL(destRect.Width), TOREAL(destRect.Height));
  8840. return GdipEnumerateMetafileDestRect(
  8841. graphics,
  8842. metafile,
  8843. destRectF,
  8844. callback,
  8845. callbackData,
  8846. imageAttributes
  8847. );
  8848. }
  8849. GpStatus WINGDIPAPI
  8850. GdipEnumerateMetafileDestPoints(
  8851. GpGraphics * graphics,
  8852. GDIPCONST GpMetafile * metafile,
  8853. GDIPCONST PointF * destPoints,
  8854. INT count,
  8855. EnumerateMetafileProc callback,
  8856. VOID * callbackData,
  8857. GDIPCONST GpImageAttributes * imageAttributes
  8858. )
  8859. {
  8860. API_ENTRY(GdipEnumerateMetafileDestPoints);
  8861. CheckParameter(callback);
  8862. CheckParameterValid(graphics);
  8863. CheckObjectBusy(graphics);
  8864. CheckParameterValid(metafile);
  8865. CheckObjectBusy(metafile);
  8866. CheckOptionalParameterValid(imageAttributes);
  8867. CheckOptionalObjectBusy(imageAttributes);
  8868. // Only the current thread can play back records from this enumeration
  8869. metafile->SetThreadId(GetCurrentThreadId());
  8870. return graphics->EnumerateMetafile(
  8871. metafile,
  8872. destPoints,
  8873. count,
  8874. callback,
  8875. callbackData,
  8876. imageAttributes
  8877. );
  8878. metafile->SetThreadId(0);
  8879. }
  8880. GpStatus WINGDIPAPI
  8881. GdipEnumerateMetafileDestPointsI(
  8882. GpGraphics * graphics,
  8883. GDIPCONST GpMetafile * metafile,
  8884. GDIPCONST Point * destPoints,
  8885. INT count,
  8886. EnumerateMetafileProc callback,
  8887. VOID * callbackData,
  8888. GDIPCONST GpImageAttributes * imageAttributes
  8889. )
  8890. {
  8891. API_ENTRY(GdipEnumerateMetafileDestPointsI);
  8892. CheckParameter(destPoints && (count > 0));
  8893. StackBuffer buffer;
  8894. GpPointF *destPointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  8895. if(!destPointsF) return OutOfMemory;
  8896. for (INT i = 0; i < count; i++)
  8897. {
  8898. destPointsF[i].X = TOREAL(destPoints[i].X);
  8899. destPointsF[i].Y = TOREAL(destPoints[i].Y);
  8900. }
  8901. return GdipEnumerateMetafileDestPoints(
  8902. graphics,
  8903. metafile,
  8904. destPointsF,
  8905. count,
  8906. callback,
  8907. callbackData,
  8908. imageAttributes
  8909. );
  8910. }
  8911. GpStatus WINGDIPAPI
  8912. GdipEnumerateMetafileSrcRectDestPoint(
  8913. GpGraphics * graphics,
  8914. GDIPCONST GpMetafile * metafile,
  8915. GDIPCONST PointF & destPoint,
  8916. GDIPCONST RectF & srcRect,
  8917. Unit srcUnit,
  8918. EnumerateMetafileProc callback,
  8919. VOID * callbackData,
  8920. GDIPCONST GpImageAttributes * imageAttributes
  8921. )
  8922. {
  8923. API_ENTRY(GdipEnumerateMetafileSrcRectDestPoint);
  8924. CheckParameter(callback);
  8925. CheckParameterValid(graphics);
  8926. CheckObjectBusy(graphics);
  8927. CheckParameterValid(metafile);
  8928. CheckObjectBusy(metafile);
  8929. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  8930. CheckOptionalParameterValid(imageAttributes);
  8931. CheckOptionalObjectBusy(imageAttributes);
  8932. // Only the current thread can play back records from this enumeration
  8933. metafile->SetThreadId(GetCurrentThreadId());
  8934. return graphics->EnumerateMetafile(
  8935. metafile,
  8936. destPoint,
  8937. srcRect,
  8938. srcUnit,
  8939. callback,
  8940. callbackData,
  8941. imageAttributes
  8942. );
  8943. metafile->SetThreadId(0);
  8944. }
  8945. GpStatus WINGDIPAPI
  8946. GdipEnumerateMetafileSrcRectDestPointI(
  8947. GpGraphics * graphics,
  8948. GDIPCONST GpMetafile * metafile,
  8949. GDIPCONST Point & destPoint,
  8950. GDIPCONST Rect & srcRect,
  8951. Unit srcUnit,
  8952. EnumerateMetafileProc callback,
  8953. VOID * callbackData,
  8954. GDIPCONST GpImageAttributes * imageAttributes
  8955. )
  8956. {
  8957. API_ENTRY(GdipEnumerateMetafileSrcRectDestPointI);
  8958. GpPointF destPointF(TOREAL(destPoint.X), TOREAL(destPoint.Y));
  8959. GpRectF srcRectF(TOREAL(srcRect.X), TOREAL(srcRect.Y),
  8960. TOREAL(srcRect.Width), TOREAL(srcRect.Height));
  8961. return GdipEnumerateMetafileSrcRectDestPoint(
  8962. graphics,
  8963. metafile,
  8964. destPointF,
  8965. srcRectF,
  8966. srcUnit,
  8967. callback,
  8968. callbackData,
  8969. imageAttributes
  8970. );
  8971. }
  8972. GpStatus WINGDIPAPI
  8973. GdipEnumerateMetafileSrcRectDestRect(
  8974. GpGraphics * graphics,
  8975. GDIPCONST GpMetafile * metafile,
  8976. GDIPCONST RectF & destRect,
  8977. GDIPCONST RectF & srcRect,
  8978. Unit srcUnit,
  8979. EnumerateMetafileProc callback,
  8980. VOID * callbackData,
  8981. GDIPCONST GpImageAttributes * imageAttributes
  8982. )
  8983. {
  8984. API_ENTRY(GdipEnumerateMetafileSrcRectDestRect);
  8985. CheckParameter(callback);
  8986. CheckParameterValid(graphics);
  8987. CheckObjectBusy(graphics);
  8988. CheckParameterValid(metafile);
  8989. CheckObjectBusy(metafile);
  8990. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  8991. CheckOptionalParameterValid(imageAttributes);
  8992. CheckOptionalObjectBusy(imageAttributes);
  8993. // Only the current thread can play back records from this enumeration
  8994. metafile->SetThreadId(GetCurrentThreadId());
  8995. return graphics->EnumerateMetafile(
  8996. metafile,
  8997. destRect,
  8998. srcRect,
  8999. srcUnit,
  9000. callback,
  9001. callbackData,
  9002. imageAttributes
  9003. );
  9004. metafile->SetThreadId(0);
  9005. }
  9006. GpStatus WINGDIPAPI
  9007. GdipEnumerateMetafileSrcRectDestRectI(
  9008. GpGraphics * graphics,
  9009. GDIPCONST GpMetafile * metafile,
  9010. GDIPCONST Rect & destRect,
  9011. GDIPCONST Rect & srcRect,
  9012. Unit srcUnit,
  9013. EnumerateMetafileProc callback,
  9014. VOID * callbackData,
  9015. GDIPCONST GpImageAttributes * imageAttributes
  9016. )
  9017. {
  9018. API_ENTRY(GdipEnumerateMetafileSrcRectDestRectI);
  9019. GpRectF destRectF(TOREAL(destRect.X), TOREAL(destRect.Y),
  9020. TOREAL(destRect.Width), TOREAL(destRect.Height));
  9021. GpRectF srcRectF(TOREAL(srcRect.X), TOREAL(srcRect.Y),
  9022. TOREAL(srcRect.Width), TOREAL(srcRect.Height));
  9023. return GdipEnumerateMetafileSrcRectDestRect(
  9024. graphics,
  9025. metafile,
  9026. destRectF,
  9027. srcRectF,
  9028. srcUnit,
  9029. callback,
  9030. callbackData,
  9031. imageAttributes
  9032. );
  9033. }
  9034. GpStatus WINGDIPAPI
  9035. GdipEnumerateMetafileSrcRectDestPoints(
  9036. GpGraphics * graphics,
  9037. GDIPCONST GpMetafile * metafile,
  9038. GDIPCONST PointF * destPoints,
  9039. INT count,
  9040. GDIPCONST RectF & srcRect,
  9041. Unit srcUnit,
  9042. EnumerateMetafileProc callback,
  9043. VOID * callbackData,
  9044. GDIPCONST GpImageAttributes * imageAttributes
  9045. )
  9046. {
  9047. API_ENTRY(GdipEnumerateMetafileSrcRectDestPoints);
  9048. CheckParameter(callback);
  9049. CheckParameterValid(graphics);
  9050. CheckObjectBusy(graphics);
  9051. CheckParameterValid(metafile);
  9052. CheckObjectBusy(metafile);
  9053. CheckParameter(SrcUnitIsValid((Unit)srcUnit));
  9054. CheckOptionalParameterValid(imageAttributes);
  9055. CheckOptionalObjectBusy(imageAttributes);
  9056. // Only the current thread can play back records from this enumeration
  9057. metafile->SetThreadId(GetCurrentThreadId());
  9058. return graphics->EnumerateMetafile(
  9059. metafile,
  9060. destPoints,
  9061. count,
  9062. srcRect,
  9063. srcUnit,
  9064. callback,
  9065. callbackData,
  9066. imageAttributes
  9067. );
  9068. metafile->SetThreadId(0);
  9069. }
  9070. GpStatus WINGDIPAPI
  9071. GdipEnumerateMetafileSrcRectDestPointsI(
  9072. GpGraphics * graphics,
  9073. GDIPCONST GpMetafile * metafile,
  9074. GDIPCONST Point * destPoints,
  9075. INT count,
  9076. GDIPCONST Rect & srcRect,
  9077. Unit srcUnit,
  9078. EnumerateMetafileProc callback,
  9079. VOID * callbackData,
  9080. GDIPCONST GpImageAttributes * imageAttributes
  9081. )
  9082. {
  9083. API_ENTRY(GdipEnumerateMetafileSrcRectDestPointsI);
  9084. CheckParameter(destPoints && (count > 0));
  9085. GpRectF srcRectF(TOREAL(srcRect.X), TOREAL(srcRect.Y),
  9086. TOREAL(srcRect.Width), TOREAL(srcRect.Height));
  9087. StackBuffer buffer;
  9088. GpPointF *destPointsF = (GpPointF*) buffer.GetBuffer(count*sizeof(GpPointF));
  9089. if(!destPointsF) return OutOfMemory;
  9090. for (INT i = 0; i < count; i++)
  9091. {
  9092. destPointsF[i].X = TOREAL(destPoints[i].X);
  9093. destPointsF[i].Y = TOREAL(destPoints[i].Y);
  9094. }
  9095. return GdipEnumerateMetafileSrcRectDestPoints(
  9096. graphics,
  9097. metafile,
  9098. destPointsF,
  9099. count,
  9100. srcRectF,
  9101. srcUnit,
  9102. callback,
  9103. callbackData,
  9104. imageAttributes
  9105. );
  9106. }
  9107. GpStatus
  9108. WINGDIPAPI
  9109. GdipPlayMetafileRecord(
  9110. GDIPCONST GpMetafile * metafile,
  9111. EmfPlusRecordType recordType,
  9112. UINT flags,
  9113. UINT dataSize,
  9114. GDIPCONST BYTE * data
  9115. )
  9116. {
  9117. API_ENTRY(GdipPlayMetafileRecord);
  9118. CheckParameterValid(metafile);
  9119. CheckParameter(recordType);
  9120. // The metafile must be already locked by the enumerator
  9121. GpLock lockMetafile (metafile->GetObjectLock());
  9122. if (lockMetafile.IsValid())
  9123. {
  9124. return InvalidParameter;
  9125. }
  9126. // Only the current thread can play back records from this enumeration
  9127. if (GetCurrentThreadId() != metafile->GetThreadId())
  9128. {
  9129. return ObjectBusy;
  9130. }
  9131. return metafile->PlayRecord(recordType, flags, dataSize, data);
  9132. }
  9133. GpStatus
  9134. WINGDIPAPI
  9135. GdipSetClipGraphics(
  9136. GpGraphics * graphics,
  9137. GpGraphics * srcgraphics,
  9138. CombineMode combineMode
  9139. )
  9140. {
  9141. API_ENTRY(GdipSetClipGraphics);
  9142. CheckParameterValid(graphics);
  9143. CheckObjectBusy(graphics);
  9144. CheckParameterValid(srcgraphics);
  9145. CheckObjectBusy(srcgraphics);
  9146. CheckParameter(CombineModeIsValid(combineMode));
  9147. return graphics->SetClip(srcgraphics, combineMode);
  9148. }
  9149. GpStatus
  9150. WINGDIPAPI
  9151. GdipSetClipRect(
  9152. GpGraphics * graphics,
  9153. REAL x,
  9154. REAL y,
  9155. REAL width,
  9156. REAL height,
  9157. CombineMode combineMode
  9158. )
  9159. {
  9160. API_ENTRY(GdipSetClipRect);
  9161. CheckParameterValid(graphics);
  9162. CheckObjectBusy(graphics);
  9163. CheckParameter(CombineModeIsValid(combineMode));
  9164. GpRectF rect(x, y, width, height);
  9165. return graphics->SetClip(rect, combineMode);
  9166. }
  9167. GpStatus
  9168. WINGDIPAPI
  9169. GdipSetClipRectI(
  9170. GpGraphics * graphics,
  9171. INT x,
  9172. INT y,
  9173. INT width,
  9174. INT height,
  9175. CombineMode combineMode
  9176. )
  9177. {
  9178. API_ENTRY(GdipSetClipRectI);
  9179. return GdipSetClipRect(graphics, TOREAL(x), TOREAL(y),
  9180. TOREAL(width), TOREAL(height), combineMode);
  9181. }
  9182. GpStatus
  9183. WINGDIPAPI
  9184. GdipSetClipPath(
  9185. GpGraphics * graphics,
  9186. GpPath * path,
  9187. CombineMode combineMode
  9188. )
  9189. {
  9190. API_ENTRY(GdipSetClipPath);
  9191. CheckParameterValid(graphics);
  9192. CheckObjectBusy(graphics);
  9193. CheckParameterValid(path);
  9194. CheckObjectBusy(path);
  9195. CheckParameter(CombineModeIsValid(combineMode));
  9196. return graphics->SetClip(path, combineMode);
  9197. }
  9198. GpStatus
  9199. WINGDIPAPI
  9200. GdipSetClipRegion(
  9201. GpGraphics * graphics,
  9202. GpRegion * region,
  9203. CombineMode combineMode
  9204. )
  9205. {
  9206. API_ENTRY(GdipSetClipRegion);
  9207. CheckParameterValid(graphics);
  9208. CheckObjectBusy(graphics);
  9209. CheckParameterValid(region);
  9210. CheckObjectBusy(region);
  9211. CheckParameter(CombineModeIsValid(combineMode));
  9212. return graphics->SetClip(region, combineMode);
  9213. }
  9214. GpStatus
  9215. WINGDIPAPI
  9216. GdipSetClipHrgn(
  9217. GpGraphics * graphics,
  9218. HRGN hRgn,
  9219. CombineMode combineMode
  9220. )
  9221. {
  9222. API_ENTRY(GdipSetClipHrgn);
  9223. CheckParameterValid(graphics);
  9224. CheckObjectBusy(graphics);
  9225. CheckParameter(hRgn && (GetObjectTypeInternal(hRgn) == OBJ_REGION));
  9226. CheckParameter(CombineModeIsValid(combineMode));
  9227. return graphics->SetClip(hRgn, combineMode);
  9228. }
  9229. GpStatus
  9230. WINGDIPAPI
  9231. GdipResetClip(
  9232. GpGraphics *graphics
  9233. )
  9234. {
  9235. API_ENTRY(GdipResetClip);
  9236. CheckParameterValid(graphics);
  9237. CheckObjectBusy(graphics);
  9238. return graphics->ResetClip();
  9239. }
  9240. GpStatus
  9241. WINGDIPAPI
  9242. GdipTranslateClip(
  9243. GpGraphics *graphics,
  9244. REAL dx,
  9245. REAL dy
  9246. )
  9247. {
  9248. API_ENTRY(GdipTranslateClip);
  9249. CheckParameterValid(graphics);
  9250. CheckObjectBusy(graphics);
  9251. return graphics->OffsetClip(dx, dy);
  9252. }
  9253. GpStatus
  9254. WINGDIPAPI
  9255. GdipTranslateClipI(
  9256. GpGraphics *graphics,
  9257. INT dx,
  9258. INT dy
  9259. )
  9260. {
  9261. API_ENTRY(GdipTranslateClipI);
  9262. return GdipTranslateClip(graphics, TOREAL(dx), TOREAL(dy));
  9263. }
  9264. GpStatus
  9265. WINGDIPAPI
  9266. GdipGetClip(
  9267. GpGraphics *graphics,
  9268. GpRegion *region
  9269. )
  9270. {
  9271. API_ENTRY(GdipGetClip);
  9272. CheckParameter(region);
  9273. CheckObjectBusy(region);
  9274. CheckParameterValid(graphics);
  9275. CheckObjectBusy(graphics);
  9276. return graphics->GetClip(region);
  9277. }
  9278. GpStatus
  9279. WINGDIPAPI
  9280. GdipGetClipBounds(
  9281. GpGraphics *graphics,
  9282. GpRectF *rect
  9283. )
  9284. {
  9285. API_ENTRY(GdipGetClipBounds);
  9286. CheckParameter(rect);
  9287. CheckParameterValid(graphics);
  9288. CheckObjectBusy(graphics);
  9289. graphics->GetClipBounds(*rect);
  9290. return Ok;
  9291. }
  9292. GpStatus
  9293. WINGDIPAPI
  9294. GdipGetClipBoundsI(
  9295. GpGraphics *graphics,
  9296. GpRect *rect
  9297. )
  9298. {
  9299. API_ENTRY(GdipGetClipBoundsI);
  9300. CheckParameter(rect);
  9301. CheckParameterValid(graphics);
  9302. CheckObjectBusy(graphics);
  9303. RectF rectf;
  9304. graphics->GetClipBounds(rectf);
  9305. rect->X = GpRound(rectf.X);
  9306. rect->Y = GpRound(rectf.Y);
  9307. rect->Width = GpRound(rectf.Width);
  9308. rect->Height = GpRound(rectf.Height);
  9309. return Ok;
  9310. }
  9311. GpStatus
  9312. WINGDIPAPI
  9313. GdipIsClipEmpty(
  9314. GpGraphics *graphics,
  9315. BOOL *result
  9316. )
  9317. {
  9318. API_ENTRY(GdipIsClipEmpty);
  9319. CheckParameter(result);
  9320. CheckParameterValid(graphics);
  9321. CheckObjectBusy(graphics);
  9322. *result = graphics->IsClipEmpty();
  9323. return Ok;
  9324. }
  9325. GpStatus
  9326. WINGDIPAPI
  9327. GdipGetVisibleClipBounds(
  9328. GpGraphics *graphics,
  9329. GpRectF *rect
  9330. )
  9331. {
  9332. API_ENTRY(GdipGetVisibleClipBounds);
  9333. CheckParameter(rect);
  9334. CheckParameterValid(graphics);
  9335. CheckObjectBusy(graphics);
  9336. graphics->GetVisibleClipBounds(*rect);
  9337. return Ok;
  9338. }
  9339. GpStatus
  9340. WINGDIPAPI
  9341. GdipGetVisibleClipBoundsI(
  9342. GpGraphics *graphics,
  9343. GpRect *rect
  9344. )
  9345. {
  9346. API_ENTRY(GdipGetVisibleClipBoundsI);
  9347. CheckParameter(rect);
  9348. CheckParameterValid(graphics);
  9349. CheckObjectBusy(graphics);
  9350. RectF rectf;
  9351. graphics->GetVisibleClipBounds(rectf);
  9352. rect->X = GpRound(rectf.X);
  9353. rect->Y = GpRound(rectf.Y);
  9354. rect->Width = GpRound(rectf.Width);
  9355. rect->Height = GpRound(rectf.Height);
  9356. return Ok;
  9357. }
  9358. GpStatus
  9359. WINGDIPAPI
  9360. GdipIsVisibleClipEmpty(
  9361. GpGraphics *graphics,
  9362. BOOL *result
  9363. )
  9364. {
  9365. API_ENTRY(GdipIsVisibleClipEmpty);
  9366. CheckParameter(result);
  9367. CheckParameterValid(graphics);
  9368. CheckObjectBusy(graphics);
  9369. *result = graphics->IsVisibleClipEmpty();
  9370. return Ok;
  9371. }
  9372. GpStatus
  9373. WINGDIPAPI
  9374. GdipIsVisiblePoint(
  9375. GpGraphics *graphics,
  9376. REAL x,
  9377. REAL y,
  9378. BOOL *result
  9379. )
  9380. {
  9381. API_ENTRY(GdipIsVisiblePoint);
  9382. CheckParameter(result);
  9383. CheckParameterValid(graphics);
  9384. CheckObjectBusy(graphics);
  9385. GpPointF pt(x,y);
  9386. *result = graphics->IsVisible(pt);
  9387. return Ok;
  9388. }
  9389. GpStatus
  9390. WINGDIPAPI
  9391. GdipIsVisiblePointI(
  9392. GpGraphics *graphics,
  9393. INT x,
  9394. INT y,
  9395. BOOL *result
  9396. )
  9397. {
  9398. API_ENTRY(GdipIsVisiblePointI);
  9399. return GdipIsVisiblePoint(graphics, TOREAL(x), TOREAL(y), result);
  9400. }
  9401. GpStatus
  9402. WINGDIPAPI
  9403. GdipIsVisibleRect(
  9404. GpGraphics *graphics,
  9405. REAL x,
  9406. REAL y,
  9407. REAL width,
  9408. REAL height,
  9409. BOOL *result
  9410. )
  9411. {
  9412. API_ENTRY(GdipIsVisibleRect);
  9413. CheckParameter(result);
  9414. CheckParameterValid(graphics);
  9415. CheckObjectBusy(graphics);
  9416. GpRectF rect(x, y, width, height);
  9417. *result = graphics->IsVisible(rect);
  9418. return Ok;
  9419. }
  9420. GpStatus
  9421. WINGDIPAPI
  9422. GdipIsVisibleRectI(
  9423. GpGraphics *graphics,
  9424. INT x,
  9425. INT y,
  9426. INT width,
  9427. INT height,
  9428. BOOL *result
  9429. )
  9430. {
  9431. API_ENTRY(GdipIsVisibleRectI);
  9432. return GdipIsVisibleRect(graphics, TOREAL(x), TOREAL(y),
  9433. TOREAL(width), TOREAL(height), result);
  9434. }
  9435. GpStatus
  9436. WINGDIPAPI
  9437. GdipSaveGraphics(
  9438. GpGraphics *graphics,
  9439. GraphicsState *state
  9440. )
  9441. {
  9442. API_ENTRY(GdipSaveGraphics);
  9443. CheckParameter(state);
  9444. CheckParameterValid(graphics);
  9445. CheckObjectBusy(graphics);
  9446. *state = (GraphicsState)graphics->Save();
  9447. return Ok;
  9448. }
  9449. GpStatus
  9450. WINGDIPAPI
  9451. GdipRestoreGraphics(
  9452. GpGraphics *graphics,
  9453. GraphicsState state
  9454. )
  9455. {
  9456. API_ENTRY(GdipRestoreGraphics);
  9457. CheckParameterValid(graphics);
  9458. CheckObjectBusy(graphics);
  9459. graphics->Restore((INT)state);
  9460. return Ok;
  9461. }
  9462. GpStatus
  9463. WINGDIPAPI
  9464. GdipBeginContainer(
  9465. GpGraphics *graphics,
  9466. GDIPCONST GpRectF *dstrect,
  9467. GDIPCONST GpRectF *srcrect,
  9468. GpPageUnit unit,
  9469. GraphicsContainer *state
  9470. )
  9471. {
  9472. API_ENTRY(GdipBeginContainer);
  9473. CheckParameter(state && dstrect && srcrect);
  9474. CheckParameterValid(graphics);
  9475. CheckObjectBusy(graphics);
  9476. CheckParameter(SrcUnitIsValid((Unit)unit));
  9477. *state = (GraphicsContainer)graphics->BeginContainer(*dstrect, *srcrect, unit);
  9478. return Ok;
  9479. }
  9480. GpStatus
  9481. WINGDIPAPI
  9482. GdipBeginContainer2(
  9483. GpGraphics *graphics,
  9484. GraphicsContainer *state
  9485. )
  9486. {
  9487. API_ENTRY(GdipBeginContainer2);
  9488. CheckParameter(state);
  9489. CheckParameterValid(graphics);
  9490. CheckObjectBusy(graphics);
  9491. *state = (GraphicsContainer)graphics->BeginContainer();
  9492. return Ok;
  9493. }
  9494. GpStatus
  9495. WINGDIPAPI
  9496. GdipBeginContainerI(
  9497. GpGraphics *graphics,
  9498. GDIPCONST GpRect *dstrect,
  9499. GDIPCONST GpRect *srcrect,
  9500. GpPageUnit unit,
  9501. GraphicsContainer *state
  9502. )
  9503. {
  9504. API_ENTRY(GdipBeginContainerI);
  9505. GpRectF dstrectF(TOREAL(dstrect->X), TOREAL(dstrect->Y), TOREAL(dstrect->Width), TOREAL(dstrect->Height));
  9506. GpRectF srcrectF(TOREAL(srcrect->X), TOREAL(srcrect->Y), TOREAL(srcrect->Width), TOREAL(srcrect->Height));
  9507. return GdipBeginContainer(graphics, &dstrectF, &srcrectF, unit, state);
  9508. }
  9509. GpStatus
  9510. WINGDIPAPI
  9511. GdipEndContainer(
  9512. GpGraphics *graphics,
  9513. GraphicsContainer state
  9514. )
  9515. {
  9516. API_ENTRY(GdipEndContainer);
  9517. CheckParameterValid(graphics);
  9518. CheckObjectBusy(graphics);
  9519. graphics->EndContainer((INT)state);
  9520. return Ok;
  9521. }
  9522. GpStatus
  9523. WINGDIPAPI
  9524. GdipGetMetafileHeaderFromWmf(
  9525. HMETAFILE hWmf,
  9526. GDIPCONST WmfPlaceableFileHeader * wmfPlaceableFileHeader,
  9527. MetafileHeader * header
  9528. )
  9529. {
  9530. API_ENTRY(GdipGetMetafileHeaderFromWmf);
  9531. CheckParameter(hWmf && wmfPlaceableFileHeader);
  9532. return GetMetafileHeader(hWmf, wmfPlaceableFileHeader, *header);
  9533. }
  9534. GpStatus
  9535. WINGDIPAPI
  9536. GdipGetMetafileHeaderFromEmf(
  9537. HENHMETAFILE hEmf,
  9538. MetafileHeader * header
  9539. )
  9540. {
  9541. API_ENTRY(GdipGetMetafileHeaderFromEmf);
  9542. CheckParameter(hEmf);
  9543. return GetMetafileHeader(hEmf, *header);
  9544. }
  9545. GpStatus
  9546. WINGDIPAPI
  9547. GdipGetMetafileHeaderFromFile(
  9548. GDIPCONST WCHAR* filename,
  9549. MetafileHeader * header
  9550. )
  9551. {
  9552. API_ENTRY(GdipGetMetafileHeaderFromFile);
  9553. CheckParameter(filename);
  9554. return GetMetafileHeader(filename, *header);
  9555. }
  9556. GpStatus
  9557. WINGDIPAPI
  9558. GdipGetMetafileHeaderFromStream(
  9559. IStream * stream,
  9560. MetafileHeader * header
  9561. )
  9562. {
  9563. API_ENTRY(GdipGetMetafileHeaderFromStream);
  9564. CheckParameter(stream);
  9565. return GetMetafileHeader(stream, *header);
  9566. }
  9567. GpStatus
  9568. WINGDIPAPI
  9569. GdipGetMetafileHeaderFromMetafile(
  9570. GpMetafile * metafile,
  9571. MetafileHeader * header
  9572. )
  9573. {
  9574. API_ENTRY(GdipGetMetafileHeaderFromMetafile);
  9575. CheckParameterValid(metafile);
  9576. CheckObjectBusy(metafile);
  9577. metafile->GetHeader(*header);
  9578. return Ok;
  9579. }
  9580. GpStatus
  9581. WINGDIPAPI
  9582. GdipGetHemfFromMetafile(
  9583. GpMetafile * metafile,
  9584. HENHMETAFILE * hEmf
  9585. )
  9586. {
  9587. API_ENTRY(GdipGetHemfFromMetafile);
  9588. CheckParameter(hEmf);
  9589. *hEmf = NULL; // init to NULL in case the metafile is busy or invalid (Windows bug 216941)
  9590. CheckParameterValid(metafile);
  9591. CheckObjectBusy(metafile);
  9592. return metafile->GetHemf(hEmf);
  9593. }
  9594. GpStatus
  9595. WINGDIPAPI
  9596. GdipCreateStreamOnFile(
  9597. GDIPCONST WCHAR * filename,
  9598. UINT access, // GENERIC_READ and/or GENERIC_WRITE
  9599. IStream ** stream
  9600. )
  9601. {
  9602. // We don't support this API anymore, simply return NotImplemented
  9603. /*
  9604. API_ENTRY(GdipCreateStreamOnFile);
  9605. CheckGdiplusInitialized; // We do this in all our object creation API's
  9606. CheckParameter(filename && stream);
  9607. CheckParameter((access & (GENERIC_READ | GENERIC_WRITE)) != 0);
  9608. if ((*stream = CreateStreamOnFile(filename, access)) != NULL)
  9609. {
  9610. return Ok;
  9611. }
  9612. return GenericError;
  9613. */
  9614. return NotImplemented;
  9615. }
  9616. GpStatus
  9617. WINGDIPAPI
  9618. GdipCreateMetafileFromWmf(
  9619. HMETAFILE hWmf,
  9620. BOOL deleteWmf,
  9621. GDIPCONST WmfPlaceableFileHeader * wmfPlaceableFileHeader, // can be NULL
  9622. GpMetafile ** metafile
  9623. )
  9624. {
  9625. API_ENTRY(GdipCreateMetafileFromWmf);
  9626. CheckGdiplusInitialized; // We do this in all our object creation API's
  9627. CheckParameter(hWmf && metafile);
  9628. *metafile = new GpMetafile(hWmf, wmfPlaceableFileHeader, deleteWmf);
  9629. if (*metafile)
  9630. {
  9631. if ((*metafile)->IsValid())
  9632. {
  9633. return Ok;
  9634. }
  9635. (*metafile)->Dispose();
  9636. *metafile = NULL;
  9637. }
  9638. return GenericError;
  9639. }
  9640. GpStatus
  9641. WINGDIPAPI
  9642. GdipCreateMetafileFromEmf(
  9643. HENHMETAFILE hEmf,
  9644. BOOL deleteEmf,
  9645. GpMetafile ** metafile
  9646. )
  9647. {
  9648. API_ENTRY(GdipCreateMetafileFromEmf);
  9649. CheckGdiplusInitialized; // We do this in all our object creation API's
  9650. CheckParameter(hEmf && metafile);
  9651. *metafile = new GpMetafile(hEmf, deleteEmf);
  9652. if (*metafile)
  9653. {
  9654. if ((*metafile)->IsValid())
  9655. {
  9656. return Ok;
  9657. }
  9658. (*metafile)->Dispose();
  9659. *metafile = NULL;
  9660. }
  9661. return GenericError;
  9662. }
  9663. GpStatus
  9664. WINGDIPAPI
  9665. GdipCreateMetafileFromFile(
  9666. GDIPCONST WCHAR* filename,
  9667. GpMetafile ** metafile
  9668. )
  9669. {
  9670. API_ENTRY(GdipCreateMetafileFromFile);
  9671. CheckGdiplusInitialized; // We do this in all our object creation API's
  9672. CheckParameter(filename && metafile);
  9673. *metafile = new GpMetafile(filename);
  9674. if (*metafile)
  9675. {
  9676. if ((*metafile)->IsValid())
  9677. {
  9678. return Ok;
  9679. }
  9680. (*metafile)->Dispose();
  9681. *metafile = NULL;
  9682. }
  9683. return GenericError;
  9684. }
  9685. GpStatus
  9686. WINGDIPAPI
  9687. GdipCreateMetafileFromWmfFile(
  9688. GDIPCONST WCHAR* filename,
  9689. GDIPCONST WmfPlaceableFileHeader * wmfPlaceableFileHeader, // can be NULL
  9690. GpMetafile ** metafile
  9691. )
  9692. {
  9693. API_ENTRY(GdipCreateMetafileFromWmfFile);
  9694. CheckGdiplusInitialized; // We do this in all our object creation API's
  9695. CheckParameter(filename && metafile);
  9696. *metafile = new GpMetafile(filename, wmfPlaceableFileHeader);
  9697. if (*metafile)
  9698. {
  9699. if ((*metafile)->IsValid())
  9700. {
  9701. return Ok;
  9702. }
  9703. (*metafile)->Dispose();
  9704. *metafile = NULL;
  9705. }
  9706. return GenericError;
  9707. }
  9708. GpStatus
  9709. WINGDIPAPI
  9710. GdipCreateMetafileFromStream(
  9711. IStream * stream,
  9712. GpMetafile ** metafile
  9713. )
  9714. {
  9715. API_ENTRY(GdipCreateMetafileFromStream);
  9716. CheckGdiplusInitialized; // We do this in all our object creation API's
  9717. CheckParameter(stream && metafile);
  9718. *metafile = new GpMetafile(stream);
  9719. if (*metafile)
  9720. {
  9721. if ((*metafile)->IsValid())
  9722. {
  9723. return Ok;
  9724. }
  9725. (*metafile)->Dispose();
  9726. *metafile = NULL;
  9727. }
  9728. return GenericError;
  9729. }
  9730. GpStatus
  9731. WINGDIPAPI
  9732. GdipRecordMetafile(
  9733. HDC referenceHdc,
  9734. EmfType type,
  9735. GDIPCONST GpRectF * frameRect,
  9736. MetafileFrameUnit frameUnit,
  9737. GDIPCONST WCHAR * description,
  9738. GpMetafile ** metafile
  9739. )
  9740. {
  9741. API_ENTRY(GdipRecordMetafile);
  9742. CheckParameter(referenceHdc && metafile);
  9743. CheckParameter(EmfTypeIsValid(type));
  9744. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9745. *metafile = new GpMetafile(referenceHdc, type, frameRect, frameUnit, description);
  9746. if (*metafile)
  9747. {
  9748. if ((*metafile)->IsValid())
  9749. {
  9750. return Ok;
  9751. }
  9752. (*metafile)->Dispose();
  9753. *metafile = NULL;
  9754. }
  9755. return GenericError;
  9756. }
  9757. GpStatus
  9758. WINGDIPAPI
  9759. GdipRecordMetafileI(
  9760. HDC referenceHdc,
  9761. EmfType type,
  9762. GDIPCONST GpRect * frameRect,
  9763. MetafileFrameUnit frameUnit,
  9764. GDIPCONST WCHAR * description,
  9765. GpMetafile ** metafile
  9766. )
  9767. {
  9768. API_ENTRY(GdipRecordMetafileI);
  9769. CheckParameter(referenceHdc && frameRect);
  9770. CheckParameter(EmfTypeIsValid(type));
  9771. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9772. GpRectF frameRectF(TOREAL(frameRect->X),
  9773. TOREAL(frameRect->Y),
  9774. TOREAL(frameRect->Width),
  9775. TOREAL(frameRect->Height));
  9776. return GdipRecordMetafile(referenceHdc,
  9777. type,
  9778. &frameRectF,
  9779. frameUnit,
  9780. description,
  9781. metafile);
  9782. }
  9783. GpStatus
  9784. WINGDIPAPI
  9785. GdipRecordMetafileFileName(
  9786. GDIPCONST WCHAR* fileName,
  9787. HDC referenceHdc,
  9788. EmfType type,
  9789. GDIPCONST GpRectF * frameRect,
  9790. MetafileFrameUnit frameUnit,
  9791. GDIPCONST WCHAR * description,
  9792. GpMetafile ** metafile
  9793. )
  9794. {
  9795. API_ENTRY(GdipRecordMetafileFileName);
  9796. CheckParameter(fileName && referenceHdc && metafile);
  9797. CheckParameter(EmfTypeIsValid(type));
  9798. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9799. *metafile = new GpMetafile(fileName, referenceHdc, type, frameRect, frameUnit, description);
  9800. if (*metafile)
  9801. {
  9802. if ((*metafile)->IsValid())
  9803. {
  9804. return Ok;
  9805. }
  9806. (*metafile)->Dispose();
  9807. *metafile = NULL;
  9808. }
  9809. return GenericError;
  9810. }
  9811. GpStatus
  9812. WINGDIPAPI
  9813. GdipRecordMetafileFileNameI(
  9814. GDIPCONST WCHAR* fileName,
  9815. HDC referenceHdc,
  9816. EmfType type,
  9817. GDIPCONST GpRect * frameRect,
  9818. MetafileFrameUnit frameUnit,
  9819. GDIPCONST WCHAR * description,
  9820. GpMetafile ** metafile
  9821. )
  9822. {
  9823. API_ENTRY(GdipRecordMetafileFileNameI);
  9824. CheckParameter(referenceHdc && frameRect);
  9825. CheckParameter(EmfTypeIsValid(type));
  9826. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9827. GpRectF frameRectF(TOREAL(frameRect->X),
  9828. TOREAL(frameRect->Y),
  9829. TOREAL(frameRect->Width),
  9830. TOREAL(frameRect->Height));
  9831. return GdipRecordMetafileFileName(fileName,
  9832. referenceHdc,
  9833. type,
  9834. &frameRectF,
  9835. frameUnit,
  9836. description,
  9837. metafile);
  9838. }
  9839. GpStatus
  9840. WINGDIPAPI
  9841. GdipRecordMetafileStream(
  9842. IStream * stream,
  9843. HDC referenceHdc,
  9844. EmfType type,
  9845. GDIPCONST GpRectF * frameRect,
  9846. MetafileFrameUnit frameUnit,
  9847. GDIPCONST WCHAR * description,
  9848. GpMetafile ** metafile
  9849. )
  9850. {
  9851. API_ENTRY(GdipRecordMetafileStream);
  9852. CheckParameter(stream && referenceHdc && metafile);
  9853. CheckParameter(EmfTypeIsValid(type));
  9854. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9855. *metafile = new GpMetafile(stream, referenceHdc, type, frameRect, frameUnit, description);
  9856. if (*metafile)
  9857. {
  9858. if ((*metafile)->IsValid())
  9859. {
  9860. return Ok;
  9861. }
  9862. (*metafile)->Dispose();
  9863. *metafile = NULL;
  9864. }
  9865. return GenericError;
  9866. }
  9867. GpStatus
  9868. WINGDIPAPI
  9869. GdipRecordMetafileStreamI(
  9870. IStream * stream,
  9871. HDC referenceHdc,
  9872. EmfType type,
  9873. GDIPCONST GpRect * frameRect,
  9874. MetafileFrameUnit frameUnit,
  9875. GDIPCONST WCHAR * description,
  9876. GpMetafile ** metafile
  9877. )
  9878. {
  9879. API_ENTRY(GdipRecordMetafileStreamI);
  9880. CheckParameter(referenceHdc && frameRect);
  9881. CheckParameter(EmfTypeIsValid(type));
  9882. CheckParameter(MetafileFrameUnitIsValid(frameUnit));
  9883. GpRectF frameRectF(TOREAL(frameRect->X),
  9884. TOREAL(frameRect->Y),
  9885. TOREAL(frameRect->Width),
  9886. TOREAL(frameRect->Height));
  9887. return GdipRecordMetafileStream(stream,
  9888. referenceHdc,
  9889. type,
  9890. &frameRectF,
  9891. frameUnit,
  9892. description,
  9893. metafile);
  9894. }
  9895. GpStatus
  9896. WINGDIPAPI
  9897. GdipSetMetafileDownLevelRasterizationLimit(
  9898. GpMetafile * metafile,
  9899. UINT metafileRasterizationLimitDpi
  9900. )
  9901. {
  9902. API_ENTRY(GdipSetMetafileDownLevelRasterizationLimit);
  9903. CheckParameterValid(metafile);
  9904. CheckObjectBusy(metafile);
  9905. // Since the rasterization limit is actually set in the graphics,
  9906. // we check if the graphics is busy too.
  9907. GpGraphics * g = metafile->PrivateAPIForGettingMetafileGraphicsContext();
  9908. CheckOptionalObjectBusy(g);
  9909. return metafile->SetDownLevelRasterizationLimit(metafileRasterizationLimitDpi);
  9910. }
  9911. GpStatus WINGDIPAPI
  9912. GdipGetMetafileDownLevelRasterizationLimit(
  9913. GDIPCONST GpMetafile * metafile,
  9914. UINT * metafileRasterizationLimitDpi
  9915. )
  9916. {
  9917. API_ENTRY(GdipGetMetafileDownLevelRasterizationLimit);
  9918. CheckParameterValid(metafile);
  9919. CheckObjectBusy(metafile);
  9920. CheckParameter(metafileRasterizationLimitDpi);
  9921. // Since the rasterization limit is actually set in the graphics,
  9922. // we check if the graphics is busy too.
  9923. GpGraphics * g = metafile->PrivateAPIForGettingMetafileGraphicsContext();
  9924. CheckOptionalObjectBusy(g);
  9925. return metafile->GetDownLevelRasterizationLimit(metafileRasterizationLimitDpi);
  9926. }
  9927. // Codec management APIs
  9928. #define COPYCODECINFOSTR(_f) \
  9929. dst->_f = (GDIPCONST WCHAR*) buf; \
  9930. size = SizeofWSTR(cur->_f); \
  9931. memcpy(buf, cur->_f, size); \
  9932. buf += size
  9933. /**************************************************************************\
  9934. *
  9935. * Function Description:
  9936. *
  9937. * Returns, via the OUT arguments, the number of installed decoders
  9938. * and how much memory is needed to store the ImageCodecInfo for all the
  9939. * decoders. size tells how much memory the caller should allocate for
  9940. * the call to GdipGetImageDecoders.
  9941. *
  9942. * Arguments:
  9943. * numDecoders -- number of installed decoders
  9944. * size -- size (in bytes) of the ImageCodecInfo's of the decoders
  9945. *
  9946. * Return Value:
  9947. *
  9948. * Status code
  9949. *
  9950. \**************************************************************************/
  9951. GpStatus
  9952. WINGDIPAPI
  9953. GdipGetImageDecodersSize(OUT UINT *numDecoders, OUT UINT *size)
  9954. {
  9955. API_ENTRY(GdipGetImageDecodersSize);
  9956. // Acquire global critical section
  9957. ImagingCritSec critsec;
  9958. ReloadCachedCodecInfo();
  9959. CachedCodecInfo* cur;
  9960. // Count the number of selected codecs
  9961. // and figure the amount of memory we need to allocate
  9962. *numDecoders = 0;
  9963. *size = 0;
  9964. for (cur = CachedCodecs; cur; cur = cur->next)
  9965. {
  9966. if (cur->Flags & IMGCODEC_DECODER)
  9967. {
  9968. (*numDecoders)++;
  9969. *size += cur->structSize;
  9970. }
  9971. }
  9972. // Global critical section is released in critsec destructor
  9973. return Ok;
  9974. }
  9975. /**************************************************************************\
  9976. *
  9977. * Function Description:
  9978. *
  9979. * Given the number of decoders (numDecoders), the size of
  9980. * the incoming buffer (size), and a pointer to the buffer (decoders),
  9981. * fill the buffer with the decoder information.
  9982. *
  9983. * Arguments:
  9984. * numDecoders -- number of installed decoders
  9985. * size -- size (in bytes) of the ImageCodecInfo's of the decoders
  9986. * decoders -- pointer to a buffer to fill in the ImageCodecInfo
  9987. *
  9988. * Return Value:
  9989. *
  9990. * Status code
  9991. *
  9992. \**************************************************************************/
  9993. GpStatus
  9994. WINGDIPAPI
  9995. GdipGetImageDecoders(UINT numDecoders,
  9996. UINT size,
  9997. ImageCodecInfo *decoders)
  9998. {
  9999. API_ENTRY(GdipGetImageDecoders);
  10000. GpStatus rv;
  10001. HRESULT hResult;
  10002. BYTE *buf;
  10003. ImageCodecInfo* dst;
  10004. CachedCodecInfo* cur;
  10005. UINT numDecodersCheck = 0;
  10006. UINT sizeCheck = 0;
  10007. // Acquire global critical section
  10008. ImagingCritSec critsec;
  10009. if (decoders == NULL)
  10010. {
  10011. rv = GenericError;
  10012. goto done;
  10013. }
  10014. GdipGetImageDecodersSize(&numDecodersCheck, &sizeCheck);
  10015. // Check that the number of codecs (and size) now equals the number
  10016. // that the user thinks there is.
  10017. if ((numDecoders != numDecodersCheck) || (size != sizeCheck))
  10018. {
  10019. rv = GenericError;
  10020. goto done;
  10021. }
  10022. // ASSERT: The result placed in sizeCheck is not used throughout
  10023. // the rest of this function.
  10024. buf = (BYTE *) decoders;
  10025. // Copy codec information to the output buffer
  10026. dst = decoders;
  10027. buf += numDecoders * sizeof(ImageCodecInfo);
  10028. for (cur = CachedCodecs; cur; cur = cur->next)
  10029. {
  10030. if ((cur->Flags & IMGCODEC_DECODER) == 0)
  10031. continue;
  10032. // First do a simple memory copy
  10033. *dst = *static_cast<ImageCodecInfo *>(cur);
  10034. // Then modify the pointer fields
  10035. COPYCODECINFOSTR(CodecName);
  10036. COPYCODECINFOSTR(FormatDescription);
  10037. COPYCODECINFOSTR(FilenameExtension);
  10038. COPYCODECINFOSTR(MimeType);
  10039. if (size = cur->SigCount*cur->SigSize)
  10040. {
  10041. dst->SigPattern = buf;
  10042. memcpy(buf, cur->SigPattern, size);
  10043. buf += size;
  10044. dst->SigMask = buf;
  10045. memcpy(buf, cur->SigMask, size);
  10046. buf += size;
  10047. }
  10048. dst++;
  10049. }
  10050. rv = Ok;
  10051. // Global critical section is released in critsec destructor
  10052. done:
  10053. return rv;
  10054. }
  10055. /**************************************************************************\
  10056. *
  10057. * Function Description:
  10058. *
  10059. * Returns, via the OUT arguments, the number of installed encoders
  10060. * and how much memory is needed to store the ImageCodecInfo for all the
  10061. * encoders. size tells how much memory the caller should allocate for
  10062. * the call to GdipGetImageEncoders.
  10063. *
  10064. * Arguments:
  10065. * numDecoders -- number of installed encoders
  10066. * size -- size (in bytes) of the ImageCodecInfo's of the encoders
  10067. *
  10068. * Return Value:
  10069. *
  10070. * Status code
  10071. *
  10072. \**************************************************************************/
  10073. GpStatus
  10074. WINGDIPAPI
  10075. GdipGetImageEncodersSize(OUT UINT *numEncoders, OUT UINT *size)
  10076. {
  10077. API_ENTRY(GdipGetImageEncodersSize);
  10078. // Acquire global critical section
  10079. ImagingCritSec critsec;
  10080. ReloadCachedCodecInfo();
  10081. CachedCodecInfo* cur;
  10082. // Count the number of selected codecs
  10083. // and figure the amount of memory we need to allocate
  10084. *numEncoders = 0;
  10085. *size = 0;
  10086. for (cur = CachedCodecs; cur; cur = cur->next)
  10087. {
  10088. if (cur->Flags & IMGCODEC_ENCODER)
  10089. {
  10090. (*numEncoders)++;
  10091. *size += cur->structSize;
  10092. }
  10093. }
  10094. // Global critical section is released in critsec destructor
  10095. return Ok;
  10096. }
  10097. /**************************************************************************\
  10098. *
  10099. * Function Description:
  10100. *
  10101. * Given the number of encoders (numEncoders), the size of
  10102. * the incoming buffer (size), and a pointer to the buffer (encoders),
  10103. * fill the buffer with the encoder information.
  10104. *
  10105. * Arguments:
  10106. * numEncoders -- number of installed encoders
  10107. * size -- size (in bytes) of the ImageCodecInfo's of the encoders
  10108. * encoders -- pointer to a buffer to fill in the ImageCodecInfo
  10109. *
  10110. * Return Value:
  10111. *
  10112. * Status code
  10113. *
  10114. \**************************************************************************/
  10115. GpStatus
  10116. WINGDIPAPI
  10117. GdipGetImageEncoders(UINT numEncoders,
  10118. UINT size,
  10119. ImageCodecInfo *encoders)
  10120. {
  10121. API_ENTRY(GdipGetImageEncoders);
  10122. GpStatus rv;
  10123. HRESULT hResult;
  10124. BYTE *buf;
  10125. ImageCodecInfo* dst;
  10126. CachedCodecInfo* cur;
  10127. UINT numEncodersCheck = 0;
  10128. UINT sizeCheck = 0;
  10129. // Acquire global critical section
  10130. ImagingCritSec critsec;
  10131. if (encoders == NULL)
  10132. {
  10133. rv = GenericError;
  10134. goto done;
  10135. }
  10136. GdipGetImageEncodersSize(&numEncodersCheck, &sizeCheck);
  10137. // Check that the number of codecs (and size) now equals the number
  10138. // that the user thinks there is.
  10139. if ((numEncoders != numEncodersCheck) || (size != sizeCheck))
  10140. {
  10141. rv = GenericError;
  10142. goto done;
  10143. }
  10144. // ASSERT: The result placed in sizeCheck is not used throughout
  10145. // the rest of this function.
  10146. buf = (BYTE *) encoders;
  10147. // Copy codec information to the output buffer
  10148. dst = encoders;
  10149. buf += numEncoders * sizeof(ImageCodecInfo);
  10150. for (cur = CachedCodecs; cur; cur = cur->next)
  10151. {
  10152. if ((cur->Flags & IMGCODEC_ENCODER) == 0)
  10153. continue;
  10154. // First do a simple memory copy
  10155. *dst = *static_cast<ImageCodecInfo*>(cur);
  10156. // Then modify the pointer fields
  10157. COPYCODECINFOSTR(CodecName);
  10158. COPYCODECINFOSTR(FormatDescription);
  10159. COPYCODECINFOSTR(FilenameExtension);
  10160. COPYCODECINFOSTR(MimeType);
  10161. if (size = cur->SigCount*cur->SigSize)
  10162. {
  10163. dst->SigPattern = buf;
  10164. memcpy(buf, cur->SigPattern, size);
  10165. buf += size;
  10166. dst->SigMask = buf;
  10167. memcpy(buf, cur->SigMask, size);
  10168. buf += size;
  10169. }
  10170. dst++;
  10171. }
  10172. rv = Ok;
  10173. // Global critical section is released in critsec destructor
  10174. done:
  10175. return rv;
  10176. }
  10177. void*
  10178. WINGDIPAPI
  10179. GdipAlloc(
  10180. size_t size
  10181. )
  10182. {
  10183. API_ENTRY(GdipAlloc);
  10184. CheckGdiplusInitialized_ReturnNULL;
  10185. #if DBG
  10186. return GpMallocAPI(size);
  10187. #else
  10188. return GpMalloc(size);
  10189. #endif
  10190. }
  10191. void
  10192. WINGDIPAPI
  10193. GdipFree(
  10194. void* ptr
  10195. )
  10196. {
  10197. API_ENTRY(GdipFree);
  10198. GpFree(ptr);
  10199. }
  10200. /// Out of place font/text stuff
  10201. GpStatus
  10202. WINGDIPAPI
  10203. GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
  10204. GpFontCollection *fontCollection,
  10205. GpFontFamily **fontFamily)
  10206. {
  10207. API_ENTRY(GdipCreateFontFamilyFromName);
  10208. CheckGdiplusInitialized; // We do this in all our object creation API's
  10209. CheckParameter(name && fontFamily);
  10210. GlobalTextLock lock;
  10211. CheckOptionalParameterValid(fontCollection);
  10212. return GpFontFamily::CreateFontFamilyFromName(
  10213. name,
  10214. fontCollection,
  10215. fontFamily);
  10216. }
  10217. GpStatus
  10218. WINGDIPAPI
  10219. GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
  10220. {
  10221. API_ENTRY(GdipGetGenericFontFamilySansSerif);
  10222. CheckParameter(nativeFamily);
  10223. return GpFontFamily::GetGenericFontFamilySansSerif(nativeFamily);
  10224. }
  10225. GpStatus
  10226. WINGDIPAPI
  10227. GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
  10228. {
  10229. API_ENTRY(GdipGetGenericFontFamilySerif);
  10230. CheckParameter(nativeFamily);
  10231. return GpFontFamily::GetGenericFontFamilySerif(nativeFamily);
  10232. }
  10233. GpStatus
  10234. WINGDIPAPI
  10235. GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
  10236. {
  10237. API_ENTRY(GdipGetGenericFontFamilyMonospace);
  10238. CheckParameter(nativeFamily);
  10239. return GpFontFamily::GetGenericFontFamilyMonospace(nativeFamily);
  10240. }
  10241. GpStatus
  10242. WINGDIPAPI
  10243. GdipCreateFont(
  10244. GDIPCONST GpFontFamily *fontFamily,
  10245. REAL size,
  10246. INT style,
  10247. Unit unit,
  10248. GpFont **font
  10249. )
  10250. {
  10251. API_ENTRY(GdipCreateFont);
  10252. CheckGdiplusInitialized; // We do this in all our object creation API's
  10253. GpStatus status = Ok;
  10254. // check parameters
  10255. CheckParameter(font);
  10256. // UnitDisplay is NOT valid; its only use is for Page Transforms
  10257. if (size <= 0 ||
  10258. // (style < StyleRegular || style > StyleStrikeout) ||
  10259. (unit < UnitWorld || unit > UnitMillimeter || unit == UnitDisplay))
  10260. {
  10261. return InvalidParameter;
  10262. }
  10263. GlobalTextLock lock;
  10264. CheckParameterValid(fontFamily);
  10265. if (*font = new GpFont(size, fontFamily, style, unit)) {
  10266. if (!(*font)->GetFace()) {
  10267. delete *font;
  10268. *font = NULL;
  10269. status = FontStyleNotFound;
  10270. }
  10271. }
  10272. else
  10273. {
  10274. status = OutOfMemory;
  10275. }
  10276. return status;
  10277. }
  10278. GpStatus
  10279. WINGDIPAPI
  10280. GdipDeleteFontFamily(GpFontFamily *gpFontFamily)
  10281. {
  10282. API_ENTRY(GdipDeleteFontFamily);
  10283. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  10284. // the object, even if it's not in a valid state.
  10285. CheckParameter(gpFontFamily);
  10286. GlobalTextLock lock;
  10287. gpFontFamily->DecFontFamilyRef();
  10288. if (gpFontFamily->IsFileLoaded(FALSE))
  10289. {
  10290. // Try to delete the font file (RemoveFontFile) for each Face[].
  10291. // This also will have the side effect of attempting to delete
  10292. // any deletable GpFontFamily objects.
  10293. UINT iFace = 0;
  10294. UINT iLastFace = 0;
  10295. GpFontFace *face = NULL;
  10296. // Compute the index of the last non-NULL Face[] pointer.
  10297. for (iFace = 0; iFace < NumFontFaces; iFace++)
  10298. {
  10299. face = gpFontFamily->GetFaceAbsolute(iFace);
  10300. if (face != NULL)
  10301. {
  10302. iLastFace = iFace;
  10303. }
  10304. }
  10305. for (iFace = 0; iFace <= iLastFace; iFace++)
  10306. {
  10307. face = gpFontFamily->GetFaceAbsolute(iFace);
  10308. // Try to remove the font file if RemoveFontFile has
  10309. // already been called on it.
  10310. // Note that if iFace == iLastFace, then the call to
  10311. // RemoveFontFile below might delete this gpFontFamily object,
  10312. // which means the Face[] pointers would be garbage. This is
  10313. // why the for loop index goes up to iLastFace.
  10314. if (face && face->pff->bRemoved)
  10315. {
  10316. GpFontCollection* actualFontCollection;
  10317. actualFontCollection = gpFontFamily->GetFontCollection();
  10318. actualFontCollection = actualFontCollection ?
  10319. actualFontCollection :
  10320. GpInstalledFontCollection::GetGpInstalledFontCollection();
  10321. actualFontCollection->GetFontTable()->RemoveFontFile(face->pff->pwszPathname_);
  10322. }
  10323. }
  10324. }
  10325. return Ok;
  10326. }
  10327. GpStatus
  10328. WINGDIPAPI
  10329. GdipCloneFontFamily(GpFontFamily *gpFontFamily, GpFontFamily **gpClonedFontFamily)
  10330. {
  10331. API_ENTRY(GdipCloneFontFamily);
  10332. CheckParameter(gpClonedFontFamily);
  10333. GlobalTextLock lock;
  10334. CheckParameterValid(gpFontFamily);
  10335. gpFontFamily->IncFontFamilyRef();
  10336. *gpClonedFontFamily = gpFontFamily;
  10337. return Ok;
  10338. }
  10339. GpStatus
  10340. WINGDIPAPI
  10341. GdipGetFamily(GpFont *font, GpFontFamily **family)
  10342. {
  10343. API_ENTRY(GdipGetFamily);
  10344. CheckParameter(family);
  10345. GlobalTextLock lock;
  10346. CheckParameterValid(font);
  10347. *family = const_cast<GpFontFamily *>(font->GetFamily());
  10348. return Ok;
  10349. }
  10350. GpStatus
  10351. WINGDIPAPI
  10352. GdipGetFontStyle(GpFont *font, INT *style)
  10353. {
  10354. API_ENTRY(GdipGetFontStyle);
  10355. CheckParameter(style);
  10356. GlobalTextLock lock;
  10357. CheckParameterValid(font);
  10358. *style = font->GetStyle();
  10359. return Ok;
  10360. }
  10361. GpStatus
  10362. WINGDIPAPI
  10363. GdipGetLogFontA(GpFont * font, GpGraphics *graphics, LOGFONTA * logfontA)
  10364. {
  10365. API_ENTRY(GdipGetLogFontA);
  10366. CheckParameter(logfontA);
  10367. CheckParameterValid(graphics);
  10368. CheckObjectBusy(graphics);
  10369. GlobalTextLock lock;
  10370. CheckParameterValid(font);
  10371. font->GetLogFontA(graphics, logfontA);
  10372. return Ok;
  10373. }
  10374. GpStatus
  10375. WINGDIPAPI
  10376. GdipGetLogFontW(GpFont * font, GpGraphics *graphics, LOGFONTW * logfontW)
  10377. {
  10378. API_ENTRY(GdipGetLogFontW);
  10379. CheckParameter(logfontW);
  10380. CheckParameterValid(graphics);
  10381. CheckObjectBusy(graphics);
  10382. GlobalTextLock lock;
  10383. CheckParameterValid(font);
  10384. font->GetLogFontW(graphics, logfontW);
  10385. return Ok;
  10386. }
  10387. GpStatus
  10388. WINGDIPAPI
  10389. GdipGetFontSize(GpFont *font, REAL *size)
  10390. {
  10391. API_ENTRY(GdipGetFontSize);
  10392. CheckParameter(size);
  10393. GlobalTextLock lock;
  10394. CheckParameterValid(font);
  10395. *size = font->GetEmSize();
  10396. return Ok;
  10397. }
  10398. GpStatus
  10399. WINGDIPAPI
  10400. GdipGetFontUnit(GpFont *font, Unit *unit)
  10401. {
  10402. API_ENTRY(GdipGetFontUnit);
  10403. CheckParameter(unit);
  10404. GlobalTextLock lock;
  10405. CheckParameterValid(font);
  10406. *unit = font->GetUnit();
  10407. return Ok;
  10408. }
  10409. GpStatus
  10410. WINGDIPAPI
  10411. GdipGetFontHeight(GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height)
  10412. {
  10413. API_ENTRY(GdipGetFontHeight);
  10414. CheckParameter(height);
  10415. CheckOptionalParameterValid(graphics);
  10416. CheckOptionalObjectBusy(graphics);
  10417. GlobalTextLock lock;
  10418. CheckParameterValid(font);
  10419. return font->GetHeight(graphics, height);
  10420. }
  10421. GpStatus
  10422. WINGDIPAPI
  10423. GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
  10424. {
  10425. API_ENTRY(GdipGetFontHeight);
  10426. CheckParameter(height);
  10427. GlobalTextLock lock;
  10428. CheckParameterValid(font);
  10429. return font->GetHeight(dpi, height);
  10430. }
  10431. GpStatus
  10432. WINGDIPAPI
  10433. GdipCloneFont(
  10434. GpFont* font,
  10435. GpFont** cloneFont
  10436. )
  10437. {
  10438. API_ENTRY(GdipCloneFont);
  10439. CheckParameter(cloneFont);
  10440. GlobalTextLock lock;
  10441. CheckParameterValid(font);
  10442. *cloneFont = font->Clone();
  10443. if (*cloneFont)
  10444. return Ok;
  10445. else
  10446. return OutOfMemory;
  10447. }
  10448. GpStatus
  10449. WINGDIPAPI
  10450. GdipDeleteFont(
  10451. GpFont* font
  10452. )
  10453. {
  10454. API_ENTRY(GdipDeleteFont);
  10455. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  10456. // the object, even if it's not in a valid state.
  10457. CheckParameter(font);
  10458. GlobalTextLock lock;
  10459. delete font;
  10460. return Ok;
  10461. }
  10462. /// End out of place font/text stuff
  10463. GpStatus
  10464. WINGDIPAPI
  10465. GdipGetDC(
  10466. GpGraphics* graphics,
  10467. HDC * hdc
  10468. )
  10469. {
  10470. API_ENTRY(GdipGetDC);
  10471. CheckParameter(hdc);
  10472. CheckParameterValid(graphics);
  10473. // NOTE: We have to leave the graphics locked until the GdipReleaseDC call
  10474. LONG * lockCount = (graphics->GetObjectLock())->GetLockCount();
  10475. LONG result = InterlockedIncrement(lockCount);
  10476. if (result != 0)
  10477. {
  10478. InterlockedDecrement(lockCount);
  10479. return ObjectBusy;
  10480. }
  10481. if ((*hdc = graphics->GetHdc()) == NULL)
  10482. {
  10483. InterlockedDecrement(lockCount);
  10484. return InvalidParameter;
  10485. }
  10486. graphics->LockedByGetDC = -1; // set graphics GetDC lock
  10487. return Ok;
  10488. }
  10489. GpStatus
  10490. WINGDIPAPI
  10491. GdipReleaseDC(
  10492. GpGraphics* graphics,
  10493. HDC hdc
  10494. )
  10495. {
  10496. API_ENTRY(GdipReleaseDC);
  10497. CheckParameter(hdc);
  10498. CheckParameterValid(graphics);
  10499. // NOTE: The graphics should already be locked from the GdipGetDC call
  10500. LONG result;
  10501. if ((InterlockedIncrement(&(graphics->LockedByGetDC)) != 0) ||
  10502. (!(graphics->GetObjectLock())->IsLocked()))
  10503. {
  10504. InterlockedDecrement(&(graphics->LockedByGetDC));
  10505. return InvalidParameter;
  10506. }
  10507. graphics->ReleaseHdc(hdc);
  10508. InterlockedDecrement((graphics->GetObjectLock())->GetLockCount());
  10509. return Ok;
  10510. }
  10511. GpStatus
  10512. WINGDIPAPI
  10513. GdipComment(
  10514. GpGraphics* graphics,
  10515. UINT sizeData,
  10516. GDIPCONST BYTE * data
  10517. )
  10518. {
  10519. API_ENTRY(GdipComment);
  10520. CheckParameter(data && (sizeData > 0));
  10521. CheckParameterValid(graphics);
  10522. CheckObjectBusy(graphics);
  10523. return graphics->Comment(sizeData, data);
  10524. }
  10525. // FontFamily
  10526. /// GdipCreateFontFamilyFromName should be moved here
  10527. /// GdipEnumerableFonts should be moved here
  10528. /// GdipEnumerateFonts should be moved here
  10529. /// GdipGetFamilyName should be moved here
  10530. GpStatus
  10531. WINGDIPAPI
  10532. GdipIsStyleAvailable(GDIPCONST GpFontFamily *family, INT style, BOOL * IsAvailable)
  10533. {
  10534. API_ENTRY(GdipIsStyleAvailable);
  10535. CheckParameter(IsAvailable);
  10536. GlobalTextLock lock;
  10537. CheckParameterValid(family);
  10538. *IsAvailable = family->IsStyleAvailable(style);
  10539. return Ok;
  10540. }
  10541. GpStatus
  10542. WINGDIPAPI
  10543. GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16 * EmHeight)
  10544. {
  10545. API_ENTRY(GdipGetEmHeight);
  10546. CheckParameter(EmHeight);
  10547. GlobalTextLock lock;
  10548. CheckParameterValid(family);
  10549. *EmHeight = family->GetDesignEmHeight(style);
  10550. return Ok;
  10551. }
  10552. GpStatus
  10553. WINGDIPAPI
  10554. GdipGetCellAscent(GDIPCONST GpFontFamily *family, INT style, UINT16 * CellAscent)
  10555. {
  10556. API_ENTRY(GdipGetCellAscent);
  10557. CheckParameter(CellAscent);
  10558. GlobalTextLock lock;
  10559. CheckParameterValid(family);
  10560. *CellAscent = family->GetDesignCellAscent(style);
  10561. return Ok;
  10562. }
  10563. GpStatus
  10564. WINGDIPAPI
  10565. GdipGetCellDescent(GDIPCONST GpFontFamily *family, INT style, UINT16 * CellDescent)
  10566. {
  10567. API_ENTRY(GdipGetCellDescent);
  10568. CheckParameter(CellDescent);
  10569. GlobalTextLock lock;
  10570. CheckParameterValid(family);
  10571. *CellDescent = family->GetDesignCellDescent(style);
  10572. return Ok;
  10573. }
  10574. GpStatus
  10575. WINGDIPAPI
  10576. GdipGetLineSpacing(GDIPCONST GpFontFamily *family, INT style, UINT16 * LineSpacing)
  10577. {
  10578. API_ENTRY(GdipGetLineSpacing);
  10579. CheckParameter(LineSpacing);
  10580. GlobalTextLock lock;
  10581. CheckParameterValid(family);
  10582. *LineSpacing = family->GetDesignLineSpacing(style);
  10583. return Ok;
  10584. }
  10585. // Font
  10586. GpStatus
  10587. WINGDIPAPI
  10588. GdipCreateFontFromDC(
  10589. HDC hdc,
  10590. GpFont **font
  10591. )
  10592. {
  10593. API_ENTRY(GdipCreateFontFromDC);
  10594. CheckGdiplusInitialized; // We do this in all our object creation API's
  10595. GpStatus status = GenericError;
  10596. CheckParameter(hdc);
  10597. GlobalTextLock lock;
  10598. if (*font = new GpFont(hdc))
  10599. {
  10600. // we should fail in case we don't have valid font family. (non-true type font selected in the hdc)
  10601. if (!(*font)->IsValid())
  10602. {
  10603. delete *font;
  10604. *font = NULL;
  10605. status = NotTrueTypeFont;
  10606. }
  10607. else
  10608. status = Ok;
  10609. }
  10610. return status;
  10611. }
  10612. GpStatus
  10613. WINGDIPAPI
  10614. GdipCreateFontFromLogfontA(
  10615. HDC hdc,
  10616. GDIPCONST LOGFONTA *logfont,
  10617. GpFont **font
  10618. )
  10619. {
  10620. API_ENTRY(GdipCreateFontFromLogfontA);
  10621. CheckGdiplusInitialized; // We do this in all our object creation API's
  10622. GpStatus status = GenericError;
  10623. CheckParameter(hdc && logfont);
  10624. GlobalTextLock lock;
  10625. if (*font = new GpFont(hdc, const_cast<LOGFONTA*>(logfont)))
  10626. {
  10627. // we should fail in case we don't have valid font family. (non-true type font selected in the hdc)
  10628. if (!(*font)->IsValid())
  10629. {
  10630. delete *font;
  10631. *font = NULL;
  10632. status = NotTrueTypeFont;
  10633. }
  10634. else
  10635. status = Ok;
  10636. }
  10637. return status;
  10638. }
  10639. GpStatus
  10640. WINGDIPAPI
  10641. GdipCreateFontFromLogfontW(
  10642. HDC hdc,
  10643. GDIPCONST LOGFONTW *logfont,
  10644. GpFont **font
  10645. )
  10646. {
  10647. API_ENTRY(GdipCreateFontFromLogfontW);
  10648. CheckGdiplusInitialized; // We do this in all our object creation API's
  10649. GpStatus status = GenericError;
  10650. CheckParameter(hdc && logfont);
  10651. GlobalTextLock lock;
  10652. if (*font = new GpFont(hdc, const_cast<LOGFONTW*>(logfont)))
  10653. {
  10654. // we should fail in case we don't have valid font family. (non-true type font selected in the hdc)
  10655. if (!(*font)->IsValid())
  10656. {
  10657. delete *font;
  10658. *font = NULL;
  10659. status = NotTrueTypeFont;
  10660. }
  10661. else
  10662. status = Ok;
  10663. }
  10664. return status;
  10665. }
  10666. /// GdipCreateFont should be moved here
  10667. /// GdipCloneFont should be moved here
  10668. /// GdipDeleteFont should be moved here
  10669. /// GdipGetFamily should be moved here
  10670. /// GdipGetFontStyle should be moved here
  10671. /// GdipGetFontSize should be moved here
  10672. GpStatus
  10673. WINGDIPAPI
  10674. GdipNewInstalledFontCollection(GpFontCollection** fontCollection)
  10675. {
  10676. API_ENTRY(GdipNewInstalledFontCollection);
  10677. CheckParameter (fontCollection);
  10678. GlobalTextLock lock;
  10679. *fontCollection = GpInstalledFontCollection::GetGpInstalledFontCollection();
  10680. return (*fontCollection ? Ok : FileNotFound);
  10681. }
  10682. GpStatus
  10683. WINGDIPAPI
  10684. GdipNewPrivateFontCollection(GpFontCollection** fontCollection)
  10685. {
  10686. API_ENTRY(GdipNewPrivateFontCollection);
  10687. CheckParameter (fontCollection);
  10688. GlobalTextLock lock;
  10689. *fontCollection = new GpPrivateFontCollection;
  10690. return (*fontCollection ? Ok : GenericError);
  10691. }
  10692. GpStatus
  10693. WINGDIPAPI
  10694. GdipDeletePrivateFontCollection(GpFontCollection** fontCollection)
  10695. {
  10696. API_ENTRY(GdipDeletePrivateFontCollection);
  10697. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  10698. // the object, even if it's not in a valid state.
  10699. CheckParameter (fontCollection);
  10700. GlobalTextLock lock;
  10701. delete static_cast<GpPrivateFontCollection *>(*fontCollection);
  10702. *fontCollection = NULL;
  10703. return Ok;
  10704. }
  10705. GpStatus
  10706. WINGDIPAPI
  10707. GdipGetFontCollectionFamilyCount(
  10708. GpFontCollection* fontCollection,
  10709. INT * numFound
  10710. )
  10711. {
  10712. API_ENTRY(GdipGetFontCollectionFamilyCount);
  10713. CheckParameter (numFound);
  10714. GlobalTextLock lock;
  10715. CheckParameterValid(fontCollection);
  10716. *numFound = fontCollection->GetFamilyCount();
  10717. return Ok;
  10718. }
  10719. GpStatus
  10720. WINGDIPAPI
  10721. GdipGetFontCollectionFamilyList(
  10722. GpFontCollection* fontCollection,
  10723. INT numSought,
  10724. GpFontFamily* gpfamilies[],
  10725. INT* numFound
  10726. )
  10727. {
  10728. API_ENTRY(GdipGetFontCollectionFamilyList);
  10729. GpStatus status;
  10730. CheckParameter(gpfamilies);
  10731. CheckParameter (numFound);
  10732. GlobalTextLock lock;
  10733. CheckParameterValid(fontCollection);
  10734. return fontCollection->GetFamilies(
  10735. numSought,
  10736. gpfamilies,
  10737. numFound);
  10738. }
  10739. GpStatus
  10740. WINGDIPAPI
  10741. GdipPrivateAddFontFile(
  10742. GpFontCollection* fontCollection,
  10743. GDIPCONST WCHAR* filename
  10744. )
  10745. {
  10746. API_ENTRY(GdipPrivateAddFontFile);
  10747. CheckParameter (filename);
  10748. // We can cast the fontCollection because we know that this
  10749. // function is called only from PrivateFontCollection::AddFontFile,
  10750. // and so we know that fontCollection really was constructed as
  10751. // a PrivateFontCollection.
  10752. GlobalTextLock lock;
  10753. CheckParameterValid(fontCollection);
  10754. return static_cast<GpPrivateFontCollection *>
  10755. (fontCollection)->AddFontFile(filename);
  10756. }
  10757. GpStatus
  10758. WINGDIPAPI
  10759. GdipPrivateAddMemoryFont(
  10760. GpFontCollection* fontCollection,
  10761. GDIPCONST void* memory,
  10762. INT length
  10763. )
  10764. {
  10765. API_ENTRY(GdipPrivateAddMemoryFont);
  10766. CheckParameter (memory);
  10767. // We can cast the fontCollection because we know that this
  10768. // function is called only from PrivateFontCollection::AddMemoryFontFile,
  10769. // and so we know that fontCollection really was constructed as
  10770. // an PrivateFontCollection.
  10771. GlobalTextLock lock;
  10772. CheckParameterValid(fontCollection);
  10773. return static_cast<GpPrivateFontCollection *>
  10774. (fontCollection)->AddMemoryFont(memory, length);
  10775. }
  10776. GpStatus
  10777. WINGDIPAPI
  10778. GdipSetFontSize(GpFont *font, REAL size, Unit unit)
  10779. {
  10780. API_ENTRY(GdipSetFontSize);
  10781. GlobalTextLock lock;
  10782. CheckParameterValid(font);
  10783. // UnitDisplay is NOT valid; its only use is for Page Transforms
  10784. if ((unit >= UnitWorld) && (unit <= UnitMillimeter) && (unit != UnitDisplay))
  10785. {
  10786. font->SetEmSize(size);
  10787. font->SetUnit(unit);
  10788. return Ok;
  10789. }
  10790. else
  10791. {
  10792. return GenericError;
  10793. }
  10794. }
  10795. GpStatus
  10796. WINGDIPAPI
  10797. GdipCreateStringFormat(
  10798. INT formatAttributes,
  10799. LANGID language,
  10800. GpStringFormat **format
  10801. )
  10802. {
  10803. API_ENTRY(GdipCreateStringFormat);
  10804. CheckGdiplusInitialized; // We do this in all our object creation API's
  10805. CheckParameter(format);
  10806. GlobalTextLock lock;
  10807. *format = new GpStringFormat(formatAttributes, language);
  10808. return format ? Ok : OutOfMemory;
  10809. }
  10810. GpStatus
  10811. WINGDIPAPI
  10812. GdipStringFormatGetGenericDefault(GpStringFormat **format)
  10813. {
  10814. API_ENTRY(GdipStringFormatGetGenericDefault);
  10815. CheckParameter(format);
  10816. GlobalTextLock lock;
  10817. *format = GpStringFormat::GenericDefault();
  10818. return Ok;
  10819. }
  10820. GpStatus
  10821. WINGDIPAPI
  10822. GdipStringFormatGetGenericTypographic(GpStringFormat **format)
  10823. {
  10824. API_ENTRY(GdipStringFormatGetGenericTypographic);
  10825. CheckParameter(format);
  10826. GlobalTextLock lock;
  10827. *format = GpStringFormat::GenericTypographic();
  10828. return Ok;
  10829. }
  10830. GpStatus
  10831. WINGDIPAPI
  10832. GdipCloneStringFormat(
  10833. GDIPCONST GpStringFormat *format,
  10834. GpStringFormat **newFormat)
  10835. {
  10836. API_ENTRY(GdipCloneStringFormat);
  10837. CheckParameter(newFormat);
  10838. GlobalTextLock lock;
  10839. CheckParameterValid(format);
  10840. *newFormat = format->Clone();
  10841. return newFormat == NULL ? OutOfMemory : Ok;
  10842. }
  10843. GpStatus
  10844. WINGDIPAPI
  10845. GdipDeleteStringFormat(GpStringFormat *format)
  10846. {
  10847. API_ENTRY(GdipDeleteStringFormat);
  10848. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  10849. // the object, even if it's not in a valid state.
  10850. CheckParameter(format);
  10851. GlobalTextLock lock;
  10852. if (!format->IsPermanent())
  10853. {
  10854. delete format;
  10855. }
  10856. return Ok;
  10857. }
  10858. GpStatus
  10859. WINGDIPAPI
  10860. GdipSetStringFormatFlags(GpStringFormat *format, INT flags)
  10861. {
  10862. API_ENTRY(GdipSetStringFormatFlags);
  10863. GlobalTextLock lock;
  10864. CheckParameterValid(format);
  10865. format->SetFormatFlags(flags);
  10866. return Ok;
  10867. }
  10868. GpStatus
  10869. WINGDIPAPI
  10870. GdipGetStringFormatFlags(GDIPCONST GpStringFormat *format, INT *flags)
  10871. {
  10872. API_ENTRY(GdipGetStringFormatFlags);
  10873. CheckParameter(flags);
  10874. GlobalTextLock lock;
  10875. CheckParameterValid(format);
  10876. *flags = format->GetFormatFlags();
  10877. return Ok;
  10878. }
  10879. GpStatus
  10880. WINGDIPAPI
  10881. GdipSetStringFormatAlign(
  10882. GpStringFormat *format,
  10883. StringAlignment align)
  10884. {
  10885. API_ENTRY(GdipSetStringFormatAlign);
  10886. GlobalTextLock lock;
  10887. CheckParameterValid(format);
  10888. CheckParameter( align >= StringAlignmentNear
  10889. && align <= StringAlignmentFar);
  10890. return format->SetAlign(align);
  10891. }
  10892. GpStatus
  10893. WINGDIPAPI
  10894. GdipGetStringFormatAlign(
  10895. GDIPCONST GpStringFormat *format,
  10896. StringAlignment *align)
  10897. {
  10898. API_ENTRY(GdipGetStringFormatAlign);
  10899. CheckParameter(align);
  10900. GlobalTextLock lock;
  10901. CheckParameterValid(format);
  10902. return format->GetAlign(align);
  10903. }
  10904. GpStatus
  10905. WINGDIPAPI
  10906. GdipSetStringFormatLineAlign(
  10907. GpStringFormat *format,
  10908. StringAlignment align)
  10909. {
  10910. API_ENTRY(GdipSetStringFormatLineAlign);
  10911. GlobalTextLock lock;
  10912. CheckParameterValid(format);
  10913. CheckParameter( align >= StringAlignmentNear
  10914. && align <= StringAlignmentFar);
  10915. return format->SetLineAlign(align);
  10916. }
  10917. GpStatus
  10918. WINGDIPAPI
  10919. GdipGetStringFormatLineAlign(
  10920. GDIPCONST GpStringFormat *format,
  10921. StringAlignment *align)
  10922. {
  10923. API_ENTRY(GdipGetStringFormatLineAlign);
  10924. CheckParameter(align);
  10925. GlobalTextLock lock;
  10926. CheckParameterValid(format);
  10927. return format->GetLineAlign(align);
  10928. }
  10929. GpStatus
  10930. WINGDIPAPI
  10931. GdipSetStringFormatHotkeyPrefix(
  10932. GpStringFormat *format,
  10933. INT hotkeyPrefix)
  10934. {
  10935. API_ENTRY(GdipSetStringFormatHotkeyPrefix);
  10936. CheckParameter( hotkeyPrefix >= HotkeyPrefixNone
  10937. && hotkeyPrefix <= HotkeyPrefixHide);
  10938. GlobalTextLock lock;
  10939. CheckParameterValid(format);
  10940. return format->SetHotkeyPrefix(hotkeyPrefix);
  10941. }
  10942. GpStatus
  10943. WINGDIPAPI
  10944. GdipGetStringFormatHotkeyPrefix(
  10945. GDIPCONST GpStringFormat *format,
  10946. INT *hotkeyPrefix)
  10947. {
  10948. API_ENTRY(GdipGetStringFormatHotkeyPrefix);
  10949. CheckParameter(hotkeyPrefix);
  10950. GlobalTextLock lock;
  10951. CheckParameterValid(format);
  10952. return format->GetHotkeyPrefix(hotkeyPrefix);
  10953. }
  10954. GpStatus
  10955. WINGDIPAPI
  10956. GdipSetStringFormatTabStops(
  10957. GpStringFormat *format,
  10958. REAL firstTabOffset,
  10959. INT count,
  10960. GDIPCONST REAL *tabStops
  10961. )
  10962. {
  10963. API_ENTRY(GdipSetStringFormatTabStops);
  10964. CheckParameter(tabStops);
  10965. GlobalTextLock lock;
  10966. CheckParameterValid(format);
  10967. return format->SetTabStops (
  10968. firstTabOffset,
  10969. count,
  10970. tabStops
  10971. );
  10972. }
  10973. GpStatus
  10974. WINGDIPAPI
  10975. GdipGetStringFormatTabStopCount(
  10976. GDIPCONST GpStringFormat *format,
  10977. INT *count
  10978. )
  10979. {
  10980. API_ENTRY(GdipGetStringFormatTabStopCount);
  10981. CheckParameter(count);
  10982. GlobalTextLock lock;
  10983. CheckParameterValid(format);
  10984. return format->GetTabStopCount (count);
  10985. }
  10986. GpStatus
  10987. WINGDIPAPI
  10988. GdipGetStringFormatTabStops(
  10989. GDIPCONST GpStringFormat *format,
  10990. INT count,
  10991. REAL *firstTabOffset,
  10992. REAL *tabStops
  10993. )
  10994. {
  10995. API_ENTRY(GdipGetStringFormatTabStops);
  10996. CheckParameter(firstTabOffset && tabStops);
  10997. GlobalTextLock lock;
  10998. CheckParameterValid(format);
  10999. return format->GetTabStops (
  11000. firstTabOffset,
  11001. count,
  11002. tabStops
  11003. );
  11004. }
  11005. GpStatus
  11006. WINGDIPAPI
  11007. GdipGetStringFormatMeasurableCharacterRangeCount(
  11008. GDIPCONST GpStringFormat *format,
  11009. INT *count
  11010. )
  11011. {
  11012. API_ENTRY(GdipGetStringFormatMeasurableCharacterRangeCount);
  11013. CheckParameter(count);
  11014. CheckParameterValid(format);
  11015. *count = format->GetMeasurableCharacterRanges();
  11016. return Ok;
  11017. }
  11018. GpStatus
  11019. WINGDIPAPI
  11020. GdipSetStringFormatMeasurableCharacterRanges(
  11021. GpStringFormat *format,
  11022. INT rangeCount,
  11023. GDIPCONST CharacterRange *ranges
  11024. )
  11025. {
  11026. API_ENTRY(GdipSetStringFormatMeasurableCharacterRanges);
  11027. CheckParameter(ranges);
  11028. CheckParameterValid(format);
  11029. if (rangeCount > 32)
  11030. {
  11031. return ValueOverflow;
  11032. }
  11033. return format->SetMeasurableCharacterRanges(
  11034. rangeCount,
  11035. ranges
  11036. );
  11037. return Ok;
  11038. }
  11039. GpStatus
  11040. WINGDIPAPI
  11041. GdipSetStringFormatDigitSubstitution(
  11042. GpStringFormat *format,
  11043. LANGID language,
  11044. StringDigitSubstitute substitute
  11045. )
  11046. {
  11047. API_ENTRY(GdipSetStringFormatDigitSubstitution);
  11048. GlobalTextLock lock;
  11049. CheckParameterValid(format);
  11050. return format->SetDigitSubstitution (
  11051. language,
  11052. substitute
  11053. );
  11054. }
  11055. GpStatus
  11056. WINGDIPAPI
  11057. GdipGetStringFormatDigitSubstitution(
  11058. GDIPCONST GpStringFormat *format,
  11059. LANGID *language,
  11060. StringDigitSubstitute *substitute
  11061. )
  11062. {
  11063. API_ENTRY(GdipGetStringFormatDigitSubstitution);
  11064. GlobalTextLock lock;
  11065. CheckParameterValid(format);
  11066. return format->GetDigitSubstitution (
  11067. language,
  11068. substitute
  11069. );
  11070. }
  11071. GpStatus
  11072. WINGDIPAPI
  11073. GdipSetStringFormatTrimming(
  11074. GpStringFormat *format,
  11075. StringTrimming trimming
  11076. )
  11077. {
  11078. API_ENTRY(GdipSetStringFormatTrimming);
  11079. CheckParameter( trimming >= StringTrimmingNone
  11080. && trimming <= StringTrimmingEllipsisPath);
  11081. GlobalTextLock lock;
  11082. CheckParameterValid(format);
  11083. return format->SetTrimming(trimming);
  11084. }
  11085. GpStatus
  11086. WINGDIPAPI
  11087. GdipGetStringFormatTrimming(
  11088. GDIPCONST GpStringFormat *format,
  11089. StringTrimming *trimming
  11090. )
  11091. {
  11092. API_ENTRY(GdipGetStringFormatTrimming);
  11093. CheckParameter(trimming);
  11094. GlobalTextLock lock;
  11095. CheckParameterValid(format);
  11096. return format->GetTrimming(trimming);
  11097. }
  11098. GpStatus
  11099. WINGDIPAPI
  11100. GdipCreateCachedBitmap(
  11101. GpBitmap *bitmap,
  11102. GpGraphics *graphics,
  11103. GpCachedBitmap **nativeCachedBitmap
  11104. )
  11105. {
  11106. API_ENTRY(GdipCreateCachedBitmap);
  11107. CheckGdiplusInitialized; // We do this in all our object creation API's
  11108. CheckParameter(nativeCachedBitmap);
  11109. // must have a bitmap and a graphics to create a CachedBitmap.
  11110. // Also we must lock both objects for the duration of this call
  11111. // because we can't have any other APIs modifying them.
  11112. CheckParameterValid(graphics);
  11113. CheckObjectBusy(graphics);
  11114. CheckParameterValid(bitmap);
  11115. CheckObjectBusy(bitmap);
  11116. *nativeCachedBitmap = new GpCachedBitmap(bitmap, graphics);
  11117. if(nativeCachedBitmap)
  11118. {
  11119. return Ok;
  11120. }
  11121. else
  11122. {
  11123. return OutOfMemory;
  11124. }
  11125. }
  11126. GpStatus WINGDIPAPI
  11127. GdipDeleteCachedBitmap(GpCachedBitmap *nativeCachedBitmap)
  11128. {
  11129. API_ENTRY(GdipDeleteCachedBitmap);
  11130. // NOTE: Do NOT call CheckParameterValid(), because we need to free
  11131. // the object, even if it's not in a valid state.
  11132. CheckParameter(nativeCachedBitmap);
  11133. // Grab the lock for the duration of the delete so that we bounce if
  11134. // someone is busy rendering on it.
  11135. // !!! [asecchia] note this will bounce if the object is locked and then
  11136. // the deletion will fail. This will cause the app to leak memory because
  11137. // there is no way to check the return status from delete.
  11138. // This problem is common to all our deletion APIs
  11139. CheckObjectBusyForDelete(nativeCachedBitmap);
  11140. delete nativeCachedBitmap;
  11141. return Ok;
  11142. }
  11143. GpStatus WINGDIPAPI
  11144. GdipDrawCachedBitmap(
  11145. GpGraphics *nativeGraphics,
  11146. GpCachedBitmap *cb,
  11147. INT x,
  11148. INT y
  11149. )
  11150. {
  11151. API_ENTRY(GdipDrawCachedBitmap);
  11152. // Check the input parameters for NULL
  11153. CheckParameterValid(nativeGraphics);
  11154. CheckParameterValid(cb);
  11155. // Grab the lock to make sure nobody is currently trying to delete the
  11156. // object under us.
  11157. CheckObjectBusy(cb);
  11158. // Grab the lock on the GpGraphics
  11159. CheckObjectBusy(nativeGraphics);
  11160. return (nativeGraphics->DrawCachedBitmap(cb, x, y));
  11161. }
  11162. // The palette must be freed and recreated whenever the Desktop colors change
  11163. HPALETTE
  11164. WINGDIPAPI
  11165. GdipCreateHalftonePalette()
  11166. {
  11167. API_ENTRY(GdipCreateHalftonePalette);
  11168. // !!! [agodfrey]: I bet we haven't documented the fact that the user
  11169. // has to call this any time the desktop colors change.
  11170. // Also, I don't know why we read 12 colors instead of 4 (I thought
  11171. // there were only 4 magic colors.)
  11172. HPALETTE hpalette;
  11173. HDC hdc = ::GetDC(NULL); // Get a screen DC
  11174. if (hdc != NULL)
  11175. {
  11176. // See if we need to get the desktop colors
  11177. if ((::GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) &&
  11178. (::GetSystemPaletteUse(hdc) == SYSPAL_STATIC) &&
  11179. (::GetDeviceCaps(hdc, SIZEPALETTE) == 256))
  11180. {
  11181. // We have to get the desktop colors to guarantee
  11182. // a XO_TRIVIAL translate in GDI.
  11183. // First Entry is always Black
  11184. ::GetSystemPaletteEntries(hdc, 1, 9,
  11185. Win9xHalftonePalette.palPalEntry + 1);
  11186. // We only can handle changes to the first 3 of the last 10
  11187. ::GetSystemPaletteEntries(hdc, 246, 3,
  11188. Win9xHalftonePalette.palPalEntry + 246);
  11189. }
  11190. ::ReleaseDC(NULL, hdc);
  11191. }
  11192. hpalette = ::CreatePalette((LOGPALETTE *)(&Win9xHalftonePalette));
  11193. return hpalette;
  11194. }
  11195. GpStatus
  11196. WINGDIPAPI
  11197. GdipMonitorControl(GpMonitorControlEnum control, void * param)
  11198. {
  11199. API_ENTRY(GdipMonitorControl);
  11200. if(Globals::Monitors == NULL)
  11201. {
  11202. Globals::Monitors = new GpMonitors;
  11203. if(Globals::Monitors == NULL)
  11204. return OutOfMemory;
  11205. }
  11206. return Globals::Monitors->Control(control, param);
  11207. }
  11208. GpStatus
  11209. WINGDIPAPI
  11210. GdipTestControl(GpTestControlEnum control, void * param)
  11211. {
  11212. API_ENTRY(GdipTestControl);
  11213. GpStatus result = Ok;
  11214. switch(control)
  11215. {
  11216. case TestControlForceBilinear:
  11217. Globals::ForceBilinear = *((BOOL *) param);
  11218. break;
  11219. case TestControlNoICM:
  11220. Globals::NoICM = *((BOOL *) param);
  11221. break;
  11222. case TestControlGetBuildNumber:
  11223. *((INT32 *) param) = VER_PRODUCTBUILD;
  11224. break;
  11225. default:
  11226. result = InvalidParameter;
  11227. break;
  11228. }
  11229. return result;
  11230. }
  11231. UINT
  11232. WINGDIPAPI
  11233. GdipEmfToWmfBits(HENHMETAFILE hemf,
  11234. UINT cbData16,
  11235. LPBYTE pData16,
  11236. INT iMapMode,
  11237. INT eFlags)
  11238. {
  11239. API_ENTRY(GdipEmfToWmfBits);
  11240. return ConvertEmfToPlaceableWmf(
  11241. hemf,
  11242. cbData16,
  11243. pData16,
  11244. iMapMode,
  11245. eFlags);
  11246. }
  11247. // Version information for debugging purposes
  11248. UINT32 GpBuildNumber = VER_PRODUCTBUILD;
  11249. } // end of extern "C"