Jump to content

GDIPlus IsImageValid?


Go to solution Solved by funkey,

Recommended Posts

Hello!  i have a question regarding GDIPlus Images & Bitmaps. 

is it possible to check if an image / bitmap handle is valid? because in my case its possible that the handle is disposed and autoit will crash as soon its used in a function so i am not able to do an error test or something like this since it just crashes. i found out i could check an image handle with _GDIPlus_ImageGetPropertyIdList , this will not crash if the image is not valid, but this dosnt work for bitmaps.

 

Edit: i found a solution which works for images and bitmaps, sure it's not the "right way", but its the only way for me which does not result in a crash.

Func _GDIPlus_IsValid($hImage)

    __GDIPlus_ImageGetPropertyCount($hImage)

    If @error Then
        Return False
    Else
        Return True
    EndIf

EndFunc

 

if you have a better solution for this, please let me know! it seems like the solution above still give me random crashes.

Edited by Aaron3569
solution
Link to comment
Share on other sites

  • Solution

When you dispose the image, then set the handle in variable to 0.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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