Page 1 of 1

GdiP Library beta

Posted: Sun Sep 12, 2004 7:18 am
by wilbert
Here's the beta version of the GdiP library I've been working on. It offers a subset of the features of GDI+ wrapped in a PB library.
You should have GDI+ installed on your computer if you want to use it.

Here's you can download the lib
http://www.geboortegrond.nl/pb/GdiP.zip
and here's a code example.

Code: Select all

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

CreateImage(0, 300, 200) 
If StartDrawing(ImageOutput()) 
  graphics = Gdip_StartGraphics()
  If graphics
    Gdip_ClearGraphics(#Gdip_Maroon)
  
    Gdip_SetSmoothingMode(#Gdip_SmoothingModeAntiAlias)

    brush1 = Gdip_HatchBrush(#Gdip_HatchStyleDottedDiamond,Gdip_ARGB(255,255,255,255),Gdip_ARGB(255,255,0,0))
    brush2 = Gdip_SolidBrush(Gdip_ARGB(255,50,50,255))
    pen1 = Gdip_SolidPen(#Gdip_Salmon,4,#Gdip_UnitPixel)
    pen2 = Gdip_BrushPen(brush1,4,#Gdip_UnitPixel)
    bitmap = Gdip_BitmapFromFile("s40.jpg")

    Gdip_SetPenEndCap(pen1, 2)

    Gdip_ImageRotateFlip(bitmap,#Gdip_Rotate90FlipNone)

    brush3 = Gdip_TextureBrush(bitmap,#Gdip_WrapModeTile)

    Gdip_FillEllipse(brush3, 50,70,80,80)
    
    Gdip_DrawRectangle(pen1, 70,100,80,50)

    Gdip_DrawArc(pen1,40,40,100,50,250,90)

    Dim Points.Gdip_PointL(5)
    Points(0)\x = 10
    Points(0)\y = 20
    Points(1)\x = 30
    Points(1)\y = 40
    Points(2)\x = 50
    Points(2)\y = 120
    Points(3)\x = 10
    Points(3)\y = 40
    Points(4)\x = 60
    Points(4)\y = 30
    Points(5)\x = 50
    Points(5)\y = 50
    Gdip_FillClosedCurve(brush1,Points(), 6, 1, #Gdip_FillModeWinding)

    Gdip_DeletePen(pen1)
    Gdip_DeleteBrush(brush1)
    Gdip_DisposeImage(image)

    Gdip_StopGraphics()

  EndIf
  StopDrawing()
EndIf

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

Repeat
  EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow

Re: GdiP Library beta

Posted: Sun Sep 12, 2004 9:29 am
by Ralf
have tried to test your lib and example on my win2k +sp4 +dx9b system! Everytime "failed to init GDI".

Re: GdiP Library beta

Posted: Sun Sep 12, 2004 10:01 am
by wilbert
Ralf wrote:have tried to test your lib and example on my win2k +sp4 +dx9b system! Everytime "failed to init GDI".
GDI+ isn't the same as DirectX !
It has some really nice features like antialiased drawing, splines, alpha support (the alpha channel of a png for example is handled fine)

I've tried WinXP and Win2000 with .NET framework installed and both worked fine.

If you are running WindowsXP or have the .NET framework installed you already should have gdiplus.dll on your computer otherwise you can download the redistributable from the microsoft website (windows 95 isn't supported). In case you decide to use the gdiplus functionality, you can also include this dll with the application you create.

Here's a link to the redistributeble. It's a self extracting exe
http://download.microsoft.com/download/ ... s_dnld.exe

Posted: Mon Sep 27, 2004 8:51 am
by J. Baker
Nice work wilbert! :D Back to check it out some more.