Jump to content
Sign in to follow this  
Terenz

GDI+ GraphicsDrawLine outline

Recommended Posts

Terenz

Hello,

How to create an outline to a line created by _GDIPlus_GraphicsDrawLine? Since it use _GDIPlus_PenCreate for the width, i don't know how to create the outline. An example is very welcome ( maybe a custom function of _GDIPlus_GraphicsDrawLine with outline color-width? :D ) i'm not so expert in this. Oh, and i'd like to apply the same method to _GDIPlus_GraphicsFillEllipse if is possible.

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

_Main()

Func _Main()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState()

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFFFF0000, 50)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

EndFunc   ;==>_Main

Result:

a42b1z.jpg

Expected result with paint just for make an idea:

282htdw.jpg

Many thanks

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Terenz

Hi UEZ. I'll bother you if a ask, when you have some time obluviusly, to make an example script? From your post seems i don't have to use anymore the GraphicsDrawLine. Thanks


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
UEZ

Here an example:

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

_Main()

Func _Main()
    Local $hGUI, $hGraphic, $hPen, $hPath, $hBrush

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState()

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 2)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddRectangle($hPath, 10, 150, 380, 50)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

EndFunc   ;==>_Main

 

What you can do is also to draw a filled red rectangle and afterwards a black rectangle over the red one.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Terenz

UEZ that script "crash" on my XP with this error:

If $aResult[0] Then Return SetError(10, $aResult[0], False)
If $aResult^ ERROR

On the function _GDIPlus_GraphicsFillPath. After a fast checking with IsArray seems $aResult is not an array, don't ask me why. Same destiny of _GDIPlus_GraphicsDrawPath with the same error if i'm comment out _GDIPlus_GraphicsFillPath. If i'll comment both no errors but i don't see nothing :D

$hGraphic return me an handle so is not that the problem, i think

P.S. Also this example:

https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_GraphicsFillPath.htm

Same result, what? :o

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
UEZ

WinXP? You should upgrade your operating system!

Anyhow, in my vm the script doesn't crash but the drawn stuff is erased afterwards.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×