Sign in to follow this  
Followers 0
rapot

Help GDIPlus load Image and save to same file?

4 posts in this topic

I want to load an image file, edit..., then... save it.

Load image :

#include <gdip.au3>
#include <GDIPlus.au3>

$image = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

Edit : put pixel

_GDIPlus_BitmapSetPixel($image, 15, 10, 0xffff00ff)

Save :

_GDIPlus_ImageSaveToFile($image, @MyDocumentsDir & "\GDIPlus_Image.jpg")

so it don't work.

Please help me.

Share this post


Link to post
Share on other sites



Try this here:

#include <GDIPlus.au3>

_GDIPlus_Startup()
Global Const $sFile = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png")
Global Const $hBrush = _GDIPlus_BrushCreateSolid(0x80FFFF00)
Global Const $hBitmap = _GDIPlus_BitmapCreateFromFile($sFile)
Global Const $iW = _GDIPlus_ImageGetWidth($hBitmap )
Global Const $iH = _GDIPlus_ImageGetHeight($hBitmap )
Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsFillRect($hContext, $iW / 3, $iH / 3,  $iW / 3, $iH / 3, $hBrush)
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "Test.jpg")
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "Test.jpg")

Br,

UEZ


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

still save as different file. I want save :

_GDIPlus_ImageSaveToFile($hBitmap, $sFile)

overwrite not work?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The file is locked by GDI+. Just save it with a different name and when file has been unlocked delete original file and rename new file back to original filename.

Br,

UEZ

Edited by UEZ

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