# A little stuck with drawing text onto a image (GDI+)

## Recommended Posts

I got this code:

#include <GDIPlus.au3>
_GDIPlus_Startup ()
$hImage = _GDIPlus_BitmapCreateFromFile("template.bmp") _GDIPlus_GraphicsClear ($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$iWidth = _GDIPlus_ImageGetWidth($hImage)

_GDIPlus_GraphicsDrawString ($hImage, "Hello world", 1, 1)$sCLSID = _GDIPlus_EncodersGetCLSID ("BMP")
_GDIPlus_ImageSaveToFileEx ($hImage, ".\GDIPlus_Image2.bmp",$sCLSID)

_GDIPlus_Shutdown ()

template.bmp is a plain white BMP image. I am wanting to overlay text onto it, then save the finished image.

When I run that code, the samed image doesn't have any text overlayed on it. I am using autoit v3.2.0.10

What am I doing wrong?

Thanks,

_Spyrorocks

##### Share on other sites

I got this code:

#include <GDIPlus.au3>
_GDIPlus_Startup ()
$hImage = _GDIPlus_BitmapCreateFromFile("template.bmp") _GDIPlus_GraphicsClear ($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$iWidth = _GDIPlus_ImageGetWidth($hImage)

_GDIPlus_GraphicsDrawString ($hImage, "Hello world", 1, 1)$sCLSID = _GDIPlus_EncodersGetCLSID ("BMP")
_GDIPlus_ImageSaveToFileEx ($hImage, ".\GDIPlus_Image2.bmp",$sCLSID)

_GDIPlus_Shutdown ()

template.bmp is a plain white BMP image. I am wanting to overlay text onto it, then save the finished image.

When I run that code, the samed image doesn't have any text overlayed on it. I am using autoit v3.2.0.10

What am I doing wrong?

Thanks,

_Spyrorocks

In this line

_GDIPlus_GraphicsDrawString ($hImage, "Hello world", 1, 1)$hImage is a handle for the image but it should be a handle to a graphics object.

There is an example for using _GDIPlus_GraphicsDrawStringEx in

If you want the background of the pic to show through comment out the _GDIPlus_GraphicsFillRect line.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

## Create an account

Register a new account