Jump to content

_GDIPlus and problem deleting an image


Recommended Posts

Hi! I am using a simple function to put a watermark into another image. It works very well, but if then I try to delete the source image file (in the script below it is called $sFile) I have the error that the file is open in my process. Thanks in advance and sorry for my bad english.

Func _Watermark($sFile2, $sFile, $sLogo)
    Local $hImage1, $hImage2, $hGraphic

    _GDIPlus_Startup ()
    $hImage1 = _GDIPlus_ImageLoadFromFile ($sFile)   ; image
    $X1 = _GDIPlus_ImageGetWidth ($hImage1)
    $Y1 = _GDIPlus_ImageGetHeight ($hImage1)
    $hImage2 = _GDIPlus_ImageLoadFromFile ($sLogo)  ; logo
    $X2 = _GDIPlus_ImageGetWidth ($hImage2)
    $Y2 = _GDIPlus_ImageGetHeight ($hImage2)

    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)
    _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, $X1-$X2-5, 5)
    _GDIPlus_ImageSaveToFile ($hImage1, $sFile2)  ; image watermarked

    _GDIPlus_ImageDispose ($hImage1)
    _GDIPlus_ImageDispose ($hImage2)
    _GDIPlus_ShutDown ()
EndFunc   ;==>_Watermark


Link to comment
Share on other sites

You need to Release the Graphics object. 



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

  • Create New...