GdiP Library beta

Developed or developing a new product in PureBasic? Tell the world about it.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

GdiP Library beta

Post 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
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Re: GdiP Library beta

Post by Ralf »

have tried to test your lib and example on my win2k +sp4 +dx9b system! Everytime "failed to init GDI".
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: GdiP Library beta

Post 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
User avatar
J. Baker
Addict
Addict
Posts: 2185
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Nice work wilbert! :D Back to check it out some more.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply