Hi, is there any workaround image locking after being setted to an image control?
I'm developing a database based app, with embeded images as blobs, but to assure the correct image is being selected, i first show it in an image control, and after the user clicks a button I add the image to the database...
If i do not preview the image in the image control all works fine, but if I do preview it, the I cannot add the image to the database, as it is locked...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
I cannot copy it from within the code as that would, again, lock the file...
@Andrew: I've been searching for a .net solution, and I found some mentions to FileStream.closestream...
Since you are a far better dll maker than me, and have a much greater understnading of how things work in b4ppc and .net, would it be possible to create a "unlock" dll?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
My Posts helped you? Consider Buying me a Porto Glass!
I think that this question is the same as that one: http://www.basic4ppc.com/forum/bug-r...restarted.html
I hope that all these proposals are only temporary workarounds, because the problem seems beeing a more general one. And I hope that it will be fixed soon, before we turn in circle.
Hi, with this code I get the error: "A generic error ocurred in GDI+ continue?"
when I try to save a image that is used in the form control. If I try to continue, not always appears the same error (sometimes yes, sometimes no...)
I think this problem has something to do whith the image locked, is there any solution?
The code:
Sub Globals
Dim Devices(0)
End Sub
Sub App_Start
Form1.Show
AddButton("form1","bSaveimage",2,230,90,20,"Save Image")
AddButton("form1","Button3",100,230,90,20,"To Form")
AddImage("form1","image1",5,5,100,100)
From the .NET docs for Image - "Saving the image to the same file it was constructed from is not allowed and throws an exception." Certainly a Bitmap seems to hold open the file it was created from as you can't delete or rename it in Explorer while the Bitmap exists. I have no idea why this limitation that a Bitmap needs to hold the file open exists but it does seem known/intended as the problem/limitation is documented
I have tried using the Door library to clone the underlying Bitmap and assign the clone to Form1.Image and dispose of Bitmap1 but the original file is still held open! The link to the file seems to follow even a copy of Bitmap1.
This is the only way that I have found to free that link.
Code:
Sub Button3_Click bitmap1.New1(AppPath & "\capture.jpg") Rect1.New1(0, 0, Bitmap1.Width, Bitmap1.Height) Draw.New1("Form1", False) Draw.DrawImage(Bitmap1.Value, Rect1.Value, Rect1.Value, False) Form1.Refresh Bitmap1.Dispose End Sub
Note the Bitmap1.Dispose. Even New1ing Bitmap1 to another file or New2ing it to a new size or New3ing it to an image from a different bitmap from a different file or assigning Bitmap1.Value with a different bitmap doesn't break the link between Bitmap1 and the original file. I don't understand this, it is counter-intuitive and I can't think of a reason why this behaviour seems to be designed in to the Bitmap object at a very low level. I'm probably missing something !
Thanks Agraham, I have modified the code in order to be able of use more than once the button3, and works fine! (If not, you get an error when you try to use the bitmap1 object after the dispose sentence)