October 5, 200619 yr 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 =)
October 8, 200619 yr 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
October 8, 200619 yr 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.
October 8, 200619 yr 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
October 8, 200619 yr 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
Create an account or sign in to comment