Sign in to follow this  
Followers 0
Szhlopp

GDIplus clear - Fixed!

6 posts in this topic

#1 ·  Posted (edited)

Fixed. This repaints the image correctly=)

#include <GDIPLUS.au3>

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Clock_Blank.jpg')
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)

$backgroundimage = _GDIPlus_BitmapCreateFromGraphics(400, 150, $hGraphic)
$background = _GDIPlus_ImageGetGraphicsContext($backgroundimage)


$hFamily = _GDIPlus_FontFamilyCreate ("Britannic Bold")
$hFont = _GDIPlus_FontCreate($hFamily, 20, 1)
$tLayout = _GDIPlus_RectFCreate (104, 48, 400, 60)
$hFormat  = _GDIPlus_StringFormatCreate(0)
$hBrush  = _GDIPlus_BrushCreateSolid(0xA7FFFFFF)


Do
    
_GDIPlus_GraphicsClear($background, 0xFF000000)
_GDIPlus_GraphicsDrawImageRect($background, $hImage,0,0, 400, 150)

$time = @HOUR & ":" & @MIN

if @HOUR  >= 13 then 
    
$tLayout = _GDIPlus_RectFCreate (122, 48, 400, 60)
$time = @HOUR - 12 & ":" & @MIN

EndIf

_GDIPlus_GraphicsDrawStringEx($background, $time, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_ImageSaveToFile($backgroundimage, @ScriptDir & '\Clocktest.jpg')



Sleep(3000)

until False

Func OnAutoItExit ( )
_GDIPlus_Shutdown()
EndFunc
Edited by Szhlopp

Share this post


Link to post
Share on other sites



Any help?

I can re-read the image from the file, but I don't want to constantly do this. I just want to be able to clear what ever I've painted on the screen and then re-draw everything.

Share this post


Link to post
Share on other sites

Why do you even need to call _GDIPlus_GraphicsClear? You are redrawing everything over it anyways.

Share this post


Link to post
Share on other sites

Why do you even need to call _GDIPlus_GraphicsClear? You are redrawing everything over it anyways.

Because I wasn't clearing it and it was layering when the time changed.

I fixed it. Thanks though

Created a seperate 'Layer' to work on with the text, it works fine now=)

Share this post


Link to post
Share on other sites

Well don't delete your original question, it helps others in the future to see your solution.

Share this post


Link to post
Share on other sites

Well don't delete your original question, it helps others in the future to see your solution.

Sorry lol

I'll update the title with fixed and repost the solution=)

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  
Followers 0