View Full Version : GDI
I need a module where I can draw in memory, and then blit that image onto a window. I'm familiar with Windows' GDI, but I can't find a module that wraps that for me. Do I need to Declare all those functions myself? I can start hunting down VB6 wrappers if I have to and making them compatible.
I'm not experienced in GDI+, but I'm sure a module utilizing that would work just as well.
Basically, I"m used to the following workflow:
Get the Desktop Window Device Context (DC)
Create a compatible bitmap (width x height) based on the desktop DC
Create a compatible DC, release the desktop DC...
Select my bitmap into my DC, create brushes, pens, etc
Drawing operations...
Blit my bitmap onto the DC of another window so the user can see my image.
Repeat as many times as is necessary...
[list] Delete objects, release my DC
But if there's a simpler way to draw in memory I don't know about, I'd love to be doing it.
ErosOlmi
23-07-2010, 07:10
Joseph,
UI module has some wraps under the Windows area, check help at http://www.thinbasic.com/public/products/thinBasic/help/html/windows.htm
(functions whose name start with WIN_...) but the list is not complete. Just some functions that people needed during last few years.
Again UI module has some graphic functions grouped under the CANVAS control: http://www.thinbasic.com/public/products/thinBasic/help/html/canvas_control.htm
Check examples into \samplescripts\UI\Canvas\
So if you need GDI functions not present in UI module you need to DECLARE them and than you can use.
In any case I will be happy to natively add (September time) wrappers of more GDI functions, just list the exact name of the one needed.
Ciao
Eros
Thanks Eros. Most of the GDI functions I need aren't in there, but it shouldn't be too much trouble to declare the ones I need.
ErosOlmi
23-07-2010, 20:42
http://www.powerbasic.com/support/downloads/files/win32api.zip
In the above file you will find most of what you need.
Check WIN32API.INC
Thanks Eros. That will be very useful. :)
So after looking at the Canvas control, I figured something out.
I could create a window with a canvas and hide it. Then I would create the window my user would see. I could draw on the canvas of the hidden window, and then get the final image and display it onto the visible window. That way there wouldn't be any flickering if I updated the drawing quickly.
Petr Schreiber
29-07-2010, 23:17
Hi JosephE,
if you need to do all this just to have flicker free render, than there is easier way. Just attach the control in double buffer mode (that is the purpose of TRUE in 3rd parameter):
Canvas_Attach(hWnd, %myCanvas, %True)
Then draw everything you need (canvas will seem to be not updated), and to update the bitmap in the end in one go, just call:
Canvas_Redraw
Petr
Oh wow, thank you so much Petr! That's going to make things so much easier! I didn't know that was an option.
:)
Petr Schreiber
30-07-2010, 00:28
I am happy it worked for you!
The difference between single and double buffered drawing is demonstrated for example in:
SampleScripts/UI/Canvas/Buffering.tBasic
But I guess maybe some dedicated articles on specific areas could serve as more obvious guide to use?
Petr
ErosOlmi
30-07-2010, 10:37
I will add more info in help file on this.
Thanks guys. I've just been looking around to see what graphics libarary to use (straight GDI, third party dlls, and thinbasic features). So i've decided on the canvas and it's ease of use. I hadn't read too much in the helpfile, it was a little vague. As for the examples, I forgot there were examples haha.