Jump to content

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

Link to comment
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

@Program Files\AutoIt3\beta\Examples\GUI\Advanced\Emboss.au3

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.
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...