Jump to content
Sign in to follow this  

Creating a new image file

Recommended Posts


I am new to AutoIt, but I have quite a bit of programming experience in other languages, notably VBA.

I have developed a system under Excel that creates an image from a series of user-input text instructions, somewhat as follows:

- create image 400x300

- background OxFC57D3

- draw line 100,100 to 100,250 0xCC4432

- text 150,250 "Hello World" arial 16 0x1234F3

- ...

In practice, the system is actually far more complex, but this gives you the idea.

I am now looking to convert the Excel system into a standalone executable, and came across AutoIt in my search for a suitable compiler. I have looked through the included help file and examples, but I cannot find how to perform the vital first step, i.e. create the new image.

Can anybody help?



Share this post

Link to post
Share on other sites

I have looked at the examples, but there is no function to create a new file. There is talk of graphic objects, image objects, handles, open files, saving files, etc, but nothing about creating files...

Share this post

Link to post
Share on other sites

Try this:

;coded by UEZ 2010
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

Local Const $width = 400
Local Const $height = 300
Opt("GUIOnEventMode", 1)

Local $hGUI = GUICreate("GDI+ Test", $width, $height)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")

Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

Local $hPen = _GDIPlus_PenCreate(0xFFCC4432)

_GDIPlus_GraphicsClear($hContext, 0xFFFC57D3)

_GDIPlus_GraphicsDrawLine($hContext, 100, 100, 100, 250)

Local $hBrush = _GDIPlus_BrushCreateSolid (0xFF1234F3)
Local $hFormat = _GDIPlus_StringFormatCreate ()
Local $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
Local $hFont = _GDIPlus_FontCreate ($hFamily, 16)
Local $tLayout = _GDIPlus_RectFCreate (150, 250, 0, 0)
Local $sString = "Hello World"
Local $aInfo = _GDIPlus_GraphicsMeasureString ($hGraphic, $sString, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hContext, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
Until Not Sleep(30)

Func Close()
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\AutoIt.jpg")
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_BrushDispose ($hBrush)




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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...