Jump to content

2 questions about Graphics


Maurice
 Share

Recommended Posts

Question 1:

I'm trying to create a graphic with X * Y size in autoit. How do I do that?

Question 2:

Whenever I try to call _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight[, $hBrush = 0]) Autoit crashes.

dim $Image = _GDIPlus_ImageLoadFromFile("C:\source.png")
dim $Graphic = _GDIPlus_ImageGetGraphicsContext ($Image)
_GDIPlus_GraphicsFillRect( $Graphic, 10, 10, 10, 10)
Link to comment
Share on other sites

Question 1:

I'm trying to create a graphic with X * Y size in autoit. How do I do that?

Question 2:

Whenever I try to call _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight[, $hBrush = 0]) Autoit crashes.

dim $Image = _GDIPlus_ImageLoadFromFile("C:\source.png")
dim $Graphic = _GDIPlus_ImageGetGraphicsContext ($Image)
_GDIPlus_GraphicsFillRect( $Graphic, 10, 10, 10, 10)
Try posting a short but complete, runnable script to demonstrate your issue. This, for example does not crash:
#include <GDIPlus.au3>

_GDIPlus_Startup()

dim $Image = _GDIPlus_ImageLoadFromFile(@WindowsDir & '\Web\Wallpaper\Ascent.jpg')
dim $Graphic = _GDIPlus_ImageGetGraphicsContext ($Image)
_GDIPlus_GraphicsFillRect( $Graphic, 10, 10, 10, 10)
ConsoleWrite("So far, so good..." & @LF)

If _GDIPlus_ImageSaveToFile($Image, @ScriptDir & "\Test.jpg") Then
    ConsoleWrite("ImageSaveToFile succeeded." & @LF)
Else
    ConsoleWrite("ImageSaveToFile failed." & @LF)
EndIf

_GDIPlus_ImageDispose($Image)

_GDIPlus_Shutdown()
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't get it. Why does this crash? (at least for me)

#include <GDIPlus.au3>

dim $Image = _GDIPlus_ImageLoadFromFile("C:\source.png")
dim $Graphic = _GDIPlus_ImageGetGraphicsContext ($Image)
    
_GDIPlus_Startup()

func _drawimage()
    _GDIPlus_GraphicsFillRect( $Graphic, 10, 10, 10, 10)
    _GDIPlus_ImageSaveToFile ($Graphic, "C:\output.png")
endfunc

_drawimage()
Link to comment
Share on other sites

I don't get it. Why does this crash? (at least for me)

#include <GDIPlus.au3>

dim $Image = _GDIPlus_ImageLoadFromFile("C:\source.png")
dim $Graphic = _GDIPlus_ImageGetGraphicsContext ($Image)
    
_GDIPlus_Startup()

func _drawimage()
    _GDIPlus_GraphicsFillRect( $Graphic, 10, 10, 10, 10)
    _GDIPlus_ImageSaveToFile ($Graphic, "C:\output.png")
endfunc

_drawimage()
Because you start using _GDIPlus_* functions before you run _GDIPlus_Startup(). Move the Startup to the top.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...