Page 2 of 5
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Aug 14, 2011 11:24 am
by Polo
Zach wrote:Personally I'd like to see something that uses the newer 2D Drawing stuff, I forgot what it is called but its hardware accelerated etc through DirectX I think, and supposedly MS is pushing developers to use this newer stuff, since IIRC GDI was crippled etc by removing hardware acceleration. (A lot of GDI apps perform poorly on Windows 7 for instance).
But that aside, this is a nice effort. Thank you for sharing

Using the newest Windows API for custom drawing makes you loose compatibility to Windows XP IIRC and since many companies/users still use XP that's a no go for me

Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Aug 14, 2011 6:31 pm
by Zach
That's a fair point, but I still hope to see it one day
Although it is designed to Interoperate with GDI/GDI+ and Direct3D so it could ease the transition.. If you ever decide to do it, you could keep the functions all in one "package" that can choose which code path to use based on the OS?
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
How could I forget such a simple name

Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Aug 14, 2011 6:41 pm
by Danilo
Yes, GDI & GDI+ are very old. Latest API für Windows programmers
is the .NET Framework 4 with Windows Presentation Foundation 4 (WPF),
Direct2D, Direct3D and everything.
I use it with C# but to me it does not make sense to wrap the .NET stuff
for PureBasic. PB is Win95 style - for modern coding there are other options
available, and all compilers (C++/C#) are available for free with
the .NET Framework and the MS Platform SDK.
Why import all the constants and headers and functions into PureBasic,
when you can just use them in C++/C# by including a header file or a
namespace? (#include "gdiplus.h" or using System.Drawing)
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Aug 14, 2011 10:42 pm
by Zach
So... you're asking on a Purebasic forum, why someone would want to do something in Purebasic, when it can just be done in another language?
Did I get that right?
Also, I am insulted by the insinuation Purebasic is not for programming "modern" applications. It is far from some relic that only works well for Win95/98/XP systems.
Look around this forum, and you will find that at least 50% of the User Libraries involve importing and wrapping libraries from other languages, etc.. I'd be doing it myself if I had the proper skills and knowledge to release such "for the public use" tools. Clearly many people feel it is worth it to have various tools for use in Purebasic.
We are not all born C/C++/insert favorite language/, programming gurus.
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sat Sep 17, 2011 12:15 am
by kenmo
I'm a little late here - I missed this thread before...
Can this libary draw to ScreenOutput(), and also to the new CanvasOutput()?
And would there be any performance increase in real-time drawing basic shapes, compared to PB's own 'Win95 style' functions?
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Nov 13, 2011 10:04 am
by Danilo
Update v0.83
Code: Select all
Changes:
- Added import libraries for gdiplus.dll (gdiplus_x86.lib & gdiplus_x64.lib)
-> the import libraries are used now by Default!
To use the old way with OpenLibrary(), declare the constant
#gDrawing_NO_DLL_IMPORT=1 before XIncludeFile "gDrawing.pbi"
- Added example19.pb, draw on screen
- Fixed text drawing problem with font offset (reported by Stargate)
- Fixed some small 64bit problems
- removed #PB_Font_Default constant for PB4.60
DOWNLOAD:
gDrawing_v0.83.zip or
gDrawing_v0.83.zip (75k)
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Nov 13, 2011 10:33 am
by Danilo
kenmo wrote:Can this libary draw to ScreenOutput(), and also to the new CanvasOutput()?
Yes, i use it with the CanvasGadget myself. Screen example (example19.pb) is included and works too.
kenmo wrote:And would there be any performance increase in real-time drawing basic shapes, compared to PB's own 'Win95 style' functions?
No, it is slower but better quality. Should be fast enough for most CanvasGadget stuff.
It gets slow if you rotate, scale and shear big images, but for normal stuff it should be quite OK.
Just try it for yourself, i don't know what you want to do.
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Nov 13, 2011 4:52 pm
by Danilo
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Jan 15, 2012 10:13 pm
by Danilo
Version 0.84 adds a feature to change the line join mode (requested by STARGÅTE)
and gDrawFormattedText() for drawing aligned text into a specified rectangle.
DOWNLOAD:
gDrawing_v0.84.zip or
gDrawing_v0.84.zip (83k)
Code: Select all
gDrawing v0.84, 15. Jan. 2012
- added commands
gSetPenLineJoin( lineJoin.l )
set line join mode, requested by Stargate
mode is one of the following constants:
#PenLineJoinMiter (default)
#PenLineJoinBevel
#PenLineJoinRound
#PenLineJoinMiterClipped
gSetPenMiterLimit( miterLimit.f )
set miter limit for line joins
gGetFontList( List fontList.s() )
get GDI+ font list (font family names)
gDrawRotatedFormattedText( x.f, y.f, width.f, height.f, Text$, angle.f [, color.q] )
draw rotated formatted text, see gDrawFormattedText()
gDrawFormattedText( x.f, y.f, width.f, height.f, Text$ [, color.q] )
draw formatted text into the rectangle specified by "x,y,width,height"
use gSetDrawTextFlags() to set the flags for formatting
gSetDrawTextFlags( flags.l )
set the formatting options for gDrawFormattedText()
flags is a combination of the following constants:
#DrawTextFullLinesOnly - draws last line on bottom only if fully visible
#DrawTextMeasureTrailingSpaces - include trailing spaces in measurement for text alignment
#DrawTextNoWordWrap - no automatic wordwrap at line end
#DrawTextNoHotkey - no hotkey (ampersand) processing
#DrawTextShowHotkey - process ampersand '&' and underline the next char.
to display an ampersand, use it 2 times: &&
#DrawTextHideHotkey - process ampersand '&' but do not display underlined chars.
to display an ampersand, use it 2 times: &&
the following group defines how text on each line
is aligned horizontally.
you can only use 1 constant out of this group:
#DrawTextLeftAligned - text is horizontally left aligned
#DrawTextCentered - text is horizontally centered
#DrawTextRightAligned - text is horizontally right aligned
the following group defines how text lines
are aligned vertically.
you can only use 1 constant out of this group:
#DrawTextLineTopAligned - text lines are vertically top aligned
#DrawTextLineCentered - text lines are vertically center aligned
#DrawTextLineBottomAligned - text lines are vertically bottom aligned
the following group defines how text is cut/trimmed at the end
if the text does not fit in the rectangle specified by gDrawFormattedText().
you can only use 1 constant out of this group:
#DrawTextNoTrimming - no trimming
#DrawTextCharacterTrimming - cut at character boundary
#DrawTextWordTrimming - cut at word boundary
#DrawTextEllipsisCharacterTrimming - cut at character boundary and display ellipsis '...'
#DrawTextEllipsisWordTrimming - cut at word boundary and display ellipsis '...'
#DrawTextEllipsisPathTrimming - cut in the center and display ellipsis '...'
(for example: "http://pure...com/forums")
- added examples
example 21 - test gSetPenLineJoin()
example 22 - quick test for gDrawFormattedText()
example 23 - shows continuous text (running text) with resizable window
example 24 - little font browser that displays the gGetFontList()

Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Jan 15, 2012 10:59 pm
by einander
Thanks Danilo for the great examples.
I have found the canvas gadget and the fontbrowser to be very helpful to me.
Cheers!
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sat Jan 21, 2012 1:29 pm
by IdeasVacuum
I'm doing something wrong when trying to use a Canvas gadget, but what? Example19.pb ScreenOutput example works fine, but this fails to draw a circle (no error messages):
Code: Select all
EnableExplicit
XIncludeFile "gDrawing.pbi"
Define iEvent.i
#WinMain = 0
#MyCanvas = 1
Procedure TestWin()
;------------------
If gInit()
If OpenWindow(#WinMain, 0, 0, 200, 200, "gDrawing",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(#MyCanvas,10, 10, 180, 180)
If gStartDrawing(CanvasOutput(#MyCanvas))
gDrawingMode(#PB_2DDrawing_Default)
gCircle(90, 90, 6, #Blue)
gStopDrawing()
Else
Debug "gStartDrawing failed"
EndIf
If StartDrawing(CanvasOutput(#MyCanvas))
DrawingMode(#PB_2DDrawing_Default)
Circle(90, 120, 6, #Blue)
StopDrawing()
EndIf
EndIf
gEnd()
Else
Debug "gInit failed"
EndIf
EndProcedure
TestWin()
Repeat
iEvent = WaitWindowEvent()
Until iEvent = #PB_Event_CloseWindow
End
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sat Jan 21, 2012 1:49 pm
by Danilo
IdeasVacuum wrote:I'm doing something wrong when trying to use a Canvas gadget, but what? Example19.pb ScreenOutput example works fine, but this fails to draw a circle (no error messages):
The color #Blue has the alpha channel set to 0, so you don't see the circle.
Please use "#Blue|$FF000000" or RGBA() as the GDI+ functions use the alpha channel.
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sat Jan 21, 2012 3:30 pm
by Polo
Actually you should just not use #Blue and such, as they are not defined on PB Mac IIRC.
Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sat Jan 21, 2012 3:35 pm
by IdeasVacuum
Doh!

Re: [Windows] 2DDrawing commands with AntiAliasing through G
Posted: Sun Jan 22, 2012 10:09 pm
by IdeasVacuum
.....Oh this lib works so nice with the Canvas Gadget! 'Little' things like gTextWidth() - very handy.