Jump to content
Sign in to follow this  
Guest titan_ve

Bitmap::fromFile(L"") blocking a .bmp file

Recommended Posts

Guest titan_ve

Hi I posted few weeks ago a msg about the blocking of an .bmp file when I load it with GDI+ function BitmaP::fromFile(L""), so I tried something suggest that was creating a temp .bmp file, I did it, but I still need to refresh the .bmp loaded on GDI+, so is there a way to UNLOCK the image and reload it???, Im programing a gauge with C.Thank you in advance!! please help!!!Rafa =)

Share this post


Link to post
Share on other sites
Guest titan_ve

Hi all!!!I FINALLY FOUND THE SOLUTION TO MY PROBLEM:Image *_img;_img = new Bitmap(L"img.bmp");graphics.DrawImage(_img, destination);_img->~Image(); <--- destructor!!well, thanx to everyone in the previous posts!!, byeRafa

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Hmmm..Calling the destructor explicitly is a bad idea. The destructor will be called when _img goes out of scope, and cause you problems that you will not see.Also, as I mention before, you should NOT name variables with a leading underscore (_) character. That is reserved for certain systems programming and considered very bad form.Try this:{ myImg = new Bitmap(L"img.bmp"); graphics.DrawImage(myImg, destination); delete myImg; // <----- Will allow you to now assign new pointer myImg = NULL; // Make sure it doesn't point to anything // Now you can use it again if needed myImg = new Bitmap(L"another.bmp"); graphics.DrawImage(myImg, destination);} // <--- Destructor will be called hereGood luck.

Share this post


Link to post
Share on other sites
Guest titan_ve

Hi Patrick!!!Well, I will change my var's names right away! =), u told me that before but I was so worried about I couldn't load my .bmp that I didnt pay attention to ur suggestion, thank u =).Well, what if i have that loading inside a time conditionallike:if(time1.var_value.n == time2){ myImg = new Bitmap(L"img.bmp"); graphics.DrawImage(myImg, destination); delete myImg; // <----- Will allow you to now assign new pointer myImg = NULL; // Make sure it doesn't point to anything}will that still unlock the .bmp file?????, so I can modify it?Well I'm going to test it, and I'll tell u what happened!!Thank you for your great help Patrick!!Rafa

Share this post


Link to post
Share on other sites
Guest titan_ve

Well it works nice!! =)what I did:if(time1.var_value.n == time2){time3 = time1.var_value.n + 72;img = new Bitmap(L"img.bmp");graphics.DrawImage(img, destination);//img->~Image();delete img;img = NULL; }///endifThank you very much Patrick!!!!Rafa

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...