Interactive PowerBasic Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 23, 2008, 05:07:54 AM

Title: GDI+: GdipDrawEllipse
Post by: José Roca on June 23, 2008, 05:07:54 AM


The following example draws an ellipse.

C++


VOID Example_DrawEllipse4(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Pen object.
   Pen bluePen(Color(255, 0, 0, 255));

   // Initialize the variables that define the ellipse.
   REAL x = 0.0f;
   REAL y =0.0f;
   REAL width = 200.0f;
   REAL height = 100.0f;

   // Draw the ellipse.
   graphics.DrawEllipse(&bluePen, x, y, width, height);
}


PowerBASIC


SUB GDIP_DrawEllipse (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBluePen AS DWORD
   LOCAL x AS SINGLE
   LOCAL y AS SINGLE
   LOCAL nWidth AS SINGLE
   LOCAL nHeight AS SINGLE

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a blue Pen
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 1.0!, %UnitWorld, pBluePen)

   ' // Initialize the variables that define the ellipse.
   x = 90.0!
   y = 60.0!
   nWidth = 200.0!
   nHeight = 100.0!

   ' // Draw the ellipse
   hStatus = GdipDrawEllipse(pGraphics, pBluePen, x, y, nWidth, nHeight)

   ' // Cleanup
   IF pBluePen THEN GdipDeletePen(pBluePen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


(http://www.jose.it-berater.org/captures/GdipDrawEllipse.png)