[Windows] 2DDrawing commands with AntiAliasing through GDI+

Share your advanced PureBasic knowledge/code with the community.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by Danilo »

@VisualJump3D:
I see now. ScreenOutput() does not work when using InitEngine3D(), it returns 0.
Do a forum search for "ScreenOutput null" to read about it.

You could use Images and Sprites. Draw to Image, then do ImageToSprite() similar
to the ImageToTexture() above. Display the sprites instead directly drawing to ScreenOutput().
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by IdeasVacuum »

Is it necessary to display the text on the screen? Since you are using a WindowedScreen, you could have the Window larger and show the text in a text/string gadget or Status Bar.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by VisualJump3D »

Thank
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by VisualJump3D »

Hi ,

How can I rotate a loaded image? (.wmf)

can you write a simple example?

Thanks!
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by IdeasVacuum »

.wmf files are a complex beast, containing vector and bitmap data, so may require a special transform, not sure. Take a look at example11 of this GDI+ lib, using gRotateAt() and gDrawClippedImage().

Luis has written some excellent image rotate functions:
Image Rotation routines for 24/32 bit with optional AA
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by Danilo »

VisualJump3D wrote:How can I rotate a loaded image? (.wmf)

can you write a simple example?

Code: Select all

EnableExplicit

;#gDrawing_NO_DLL_IMPORT = 1

XIncludeFile "gDrawing.pbi"

Global metafile, mainWin, canvas, angle.f

Procedure OnTimer()
    Protected windowWidth  = WindowWidth(mainWin)
    Protected windowHeight = WindowHeight(mainWin)
    If gStartDrawing( CanvasOutput(canvas) )
        gClear( RGBA($40,$40,$40,$FF) )
        gRotateAt(windowWidth*0.5,windowHeight*0.5,angle) : angle + 3
        gDrawImage(metafile,0,0,windowWidth,windowHeight)
        gStopDrawing()
    EndIf
EndProcedure

Procedure OnSize()
    ResizeGadget(canvas,0,0,WindowWidth(mainWin),WindowHeight(mainWin))
    OnTimer()
EndProcedure


If gInit()
    metafile = gLoadMetafile("myfile.emf")
    mainWin  = OpenWindow(#PB_Any  , 0, 0, 320,200,"gDrawing feature demo",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
    canvas   = CanvasGadget(#PB_Any, 0, 0, WindowWidth(mainWin),WindowHeight(mainWin))
    WindowBounds(mainWin,100,100,800,600)
    AddWindowTimer(mainWin, 0, 16)
    BindEvent(#PB_Event_Timer     , @OnTimer())
    BindEvent(#PB_Event_SizeWindow, @OnSize())
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

    gEnd()
EndIf
Requires: gDrawing_v0.85b2.zip (myfile.emf is included)
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by VisualJump3D »

Now I'm out of the house,

When I get home I try it,

Thanks!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by Danilo »

What are external thoughts/wishes about 'gDrawing2'?

Thoughts/wishes about compatibility (OS, command set, ...), supported Operating Systems,
about coding style (procedural vs. object-oriented), feature requests, or anything else...?
I'm open to suggestions.

(Personal Message and Public Message accepted)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by IdeasVacuum »

Hi Danilo

Definitely keep it Procedural. The lib is very good as-is, can't think of any important features to add.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by StarBootics »

My thoughts about this library are theses :

A version compatible with linux OS
A pure procedural version
A module version
Preferably not compiled and written in PureBasic

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by netmaestro »

A version compatible with linux OS
[..]
Preferably not compiled and written in PureBasic
Since the whole library is based on a Windows dll that ships with the OS you'd have to start from scratch on Linux.

Not sure what you mean in your last line, the library isn't compiled. It's a sourcecode include and it won't compile in any other language than Purebasic.

btw, Danilo thanks for this if I didn't say so before. It's timesaving over importing and using the functions directly.
BERESHEIT
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by StarBootics »

netmaestro wrote:Not sure what you mean in your last line, the library isn't compiled. It's a sourcecode include and it won't compile in any other language than Purebasic.
sourcecode include yes ! How many time we see compiled libraries in the forum no longer maintained by their authors and no longer compatible from one version of PureBasic to the next ?
When you have the source code we can upgrade the lib according to the change in the syntax from on version to the next. No need to keep old version of the compiler and libraries to compile old projects.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by IdeasVacuum »

Bold Bold? Heavy?

There are a few fonts where Bold is not-so-bold and I need them to be closer to Arial Black. Is there anything in GDI to make Bold bolder?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by netmaestro »

In the past I've enhanced boldness with a second drawing one pixel to the right or down (or both)
BERESHEIT
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Post by IdeasVacuum »

Good tip netmaestro! With AntialiasMode_HighQuality set, I get a good Bold with an offset of 0.5 in X and Y. That gives a good result for both normal and italic styles, but basically it is what bold should be in the first place :D Need something more for the Bold Bold or Heavy effect of Arial Black though.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply