Page 1 of 1

GdiPlus

Posted: Tue Sep 07, 2004 2:04 pm
by wilbert
Does there exist a GdiPlus lib for PureBasic ?

I noticed on the GDI+ Flat Api reference that it has a lot of nice features.
Here's a little example.

Code: Select all

#HatchStyleDottedDiamond = 44
#SmoothingModeAntiAlias  = 4
#UnitPixel               = 2 

Structure GdiplusStartupInput
   GdiplusVersion.l
   DebugEventCallback.l
   SuppressBackgroundThread.l
   SuppressExternalCodecs.l
EndStructure

Procedure.l ARGB(alpha.b, r.b, g.b, b.b)
  ProcedureReturn alpha << 24 + r << 16 + g << 8 + b
EndProcedure

GdiPlus.l = OpenLibrary(#PB_Any, "gdiplus.dll")

If GdiPlus

  GSI.GdiplusStartupInput\GdiplusVersion = 1
  If CallFunction(GdiPlus, "GdiplusStartup", @token.l, GSI) = 0

    OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "GdiPlus demo")

    CreateImage(0, 300, 200) 
    hDC = StartDrawing(ImageOutput()) 
    If hDC
      CallFunction(GdiPlus, "GdipCreateFromHDC", hDC, @graphics.l)
      CallFunction(GdiPlus, "GdipSetSmoothingMode", graphics, #SmoothingModeAntiAlias)

      CallFunction(GdiPlus, "GdipCreatePen1", ARGB(255, 255, 255, 0), 8, #UnitPixel, @pen1.l)
      CallFunction(GdiPlus, "GdipCreatePen1", ARGB(255, 255, 0, 0), 8, #UnitPixel, @pen2.l)

      CallFunction(GdiPlus, "GdipCreateHatchBrush", #HatchStyleDottedDiamond, ARGB(255, 0, 255, 0),ARGB(128, 0, 255, 0), @brush1.l)

      CallFunction(GdiPlus, "GdipDrawLineI", graphics, pen1, 50, 10, 40, 40)

      CallFunction(GdiPlus, "GdipDrawEllipseI", graphics, pen2, 60, 60, 200, 100)
      CallFunction(GdiPlus, "GdipFillEllipseI", graphics, brush1, 50, 50, 70, 70)

      CallFunction(GdiPlus, "GdipDeleteGraphics", graphics)

      StopDrawing()
    EndIf

    CreateGadgetList(WindowID())
    ImageGadget(0, 0, 0, 300, 300, UseImage(0)) 

    Repeat
      EventID = WaitWindowEvent()
    Until EventID = #PB_EventCloseWindow

    CallFunction(GdiPlus, "GdiplusShutdown", token)

  EndIf

EndIf
GdiPlus comes with WindowsXP or the Microsoft .Net framework and is available as a download for Windows 98, Windows NT, Windows 2000 and Windows ME .

The GDI+ Flat Api reference
http://msdn.microsoft.com/library/defau ... latapi.asp

Posted: Tue Sep 07, 2004 6:34 pm
by benny
@wilbert:
Nice example ... perhaps you may have a look on this examples from
the german forum:

http://www.ampsoft.org/data/gdip.zip

Posted: Tue Sep 07, 2004 8:57 pm
by wilbert
Very nice. :D

I hadn't thought of checking the german forum since my knowledge of the language isn't that good (although it looks a bit like dutch).
Would be nice to see some of that features in a real lib so that they are easier to use.