gdi library test

BlitzPlus Forums/BlitzPlus Programming/gdi library test

skn3(Posted 2004) [#1]
Hey, just working on some gdi functions (needed for an application I am creating)

I have created quite an advanced blitz api for interfacing with gdi. IT includes memory management, and presents gdi in blitz like commands.

Examples:
Outline + resizer (look in corner)


Draw Arrow.. (uses draw polygon)


Take a look at an unfinished library (Still needs many GDI commands added)
http://skn3.acsv.net/junk/skn3gdi.zip

Some feedback would be nice. Do the examples run on your system ?


Beaker(Posted 2004) [#2]
All working here.


Cold Harbour(Posted 2004) [#3]
Hi skn, very impressive.

All works btw.


Eikon(Posted 2004) [#4]
Where I was heading but with a DLL, see you ran into same flicker problem I did :(

Nice userlib work, I especially liked the arrow example. Sure hope this gets fixed in the update.


skn3(Posted 2004) [#5]
Using the download above, try this. To avoid flicker you have to perform a double buffer with GDI. It envolves creating an "off screen" of virtual device context. You draw into this, then blt to your front dc (the client area).

I have managed to do this with some success, but have not managed to have flicker free gdi operations, overlaying the contents already in the client area.

;Example of drawing an arrow, double buffered

Include "skn3gdi.bb"

Global window   = CreateWindow("test",100,100,800,700,0,1)
Global panel    = CreatePanel(2,2,ClientWidth(window)-4,ClientHeight(window)-4,window)
Global timer    = CreateTimer(60)

Global dcfront  = CreateGadgetDc(panel)
Global dcback   = CreateVirtualDc(ClientWidth(panel),ClientHeight(panel),dcfront)
Global brushcls = CreateRgbBrush(255,255,255)
Global brush    = CreateRgbBrush(255,155,0)
Global pen      = CreateRgbPen(0,0,0,1)

Repeat
	Select WaitEvent()
		Case $803 : Exit
		Case $4001
			SetDc DcBuffer(dcback)
			SetPen pen
			SetBrush brush
			DrawRectFill(0,0,ClientWidth(panel),ClientHeight(panel),brushcls)
			DrawArrow(ClientWidth(panel)/2,ClientHeight(panel)/2,GadgetMouseX(panel),GadgetMouseY(panel),18,66)
			
			SetDc DcBuffer(dcfront)
			DrawDc(dcback,gdi_bltmode_srccopy)
	End Select
Forever

FreeDc(dcfront)
FreeBrush(brush)
FreeBrush(brushcls)
FreePen(pen)



BlitzSupport(Posted 2004) [#6]
Yeah, it works nicely, and the arrow example is especially cool. Nice job on the double buffering too.