|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problems with FileAccess and PcitoreBoxFor viewing pictures I am using a pictures box... For making proper saving of the pic, I must delete an existing pic-file and overwrite it with the picture in the picturebox... Trying this I always get an exeption, that the file is in use... This is my code... 'remarks Imports System.IO Imports System.Drawing ' Dim mytempic as String= "X:\Photos\MyTempPic1.jpg" If System.Io.File.Exists(mytempic) = False Then Me.pboPicture.Image.Save(mytempPic) Else Dim tempPic As String = "X:\Photos\tmp.jpg" Me.pboPicture.Image.Save(tempPic) Me.pboPicture.Image = Image.FromFile(tempPic) 'The error occurs here, but I cleared the picturebox File.Delete(mytemppic) Me.pboPicture.Image.Save(mytempic) 'other way to load the picture Me.pboPicture.ImageLocation = mytempic Me.pboPicture.Load() End If end if If anyone has an idea, please write... I tried everything and didn't get it work... Thanks alot Nijazi Halimaji Hi I always load a temp copy of the original image in a picturebox if I'm
going to do some editing to a picture. So I don't use Me.pboPicture.Image = Image.FromFile(tempPic), I hope my sample below is clear enough to do the rest of the explanation Dim myLoc As String = "c:\2.jpg" Dim myBmp As Bitmap Dim myNewBmp As Bitmap Dim g As Graphics myBmp = DirectCast(Bitmap.FromFile(myLoc), Bitmap) myNewBmp = New Bitmap(myBmp.Width, myBmp.Height) myNewBmp SetResolution(myBmp.HorizontalResolution, myBmp.VerticalResolution) g = Graphics.FromImage(myNewBmp) g.DrawImage(myBmp, New Rectangle(0, 0, myBmp.Width, myBmp.Height), 0, 0, myBmp.Width, myBmp.Height, GraphicsUnit.Pixel) g.DrawString("Peter Proost vb.net", Me.Font, Brushes.Black, 2, 2) myBmp.Dispose() g.Dispose() PictureBox1.Image = myNewBmp If System.IO.File.Exists(myLoc) Then System.IO.File.Delete(myLoc) End If myNewBmp.Save(myLoc, Imaging.ImageFormat.Jpeg) -- Show quoteHide quoteProgramming 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. (Rich Cook) "Halimaji Nijazi" <t***@hotmail.com> schreef in bericht news:e0Ie9nvKGHA.140@TK2MSFTNGP12.phx.gbl... > Hi > > For viewing pictures I am using a pictures box... For making proper saving > of the pic, I must delete an existing pic-file and overwrite it with the > picture in the picturebox... Trying this I always get an exeption, that the > file is in use... This is my code... > > 'remarks > Imports System.IO > Imports System.Drawing > ' > > Dim mytempic as String= "X:\Photos\MyTempPic1.jpg" > If System.Io.File.Exists(mytempic) = False Then > Me.pboPicture.Image.Save(mytempPic) > Else > Dim tempPic As String = "X:\Photos\tmp.jpg" > Me.pboPicture.Image.Save(tempPic) > Me.pboPicture.Image = Image.FromFile(tempPic) > 'The error occurs here, but I cleared the picturebox > File.Delete(mytemppic) > Me.pboPicture.Image.Save(mytempic) > 'other way to load the picture > Me.pboPicture.ImageLocation = mytempic > Me.pboPicture.Load() > End If > > end if > > > If anyone has an idea, please write... I tried everything and didn't get it > work... > > Thanks alot > > Nijazi Halimaji > > -- > Nijazi Halimaji > brain solutions > i***@brainsolutions.ch > www.brainsolutions.ch > > "Halimaji Nijazi" <t***@hotmail.com> schrieb: Check out the two snippets at > For viewing pictures I am using a pictures box... For making proper saving > of the pic, I must delete an existing pic-file and overwrite it with the > picture in the picturebox... Trying this I always get an exeption, that > the file is in use... <URL:http://dotnet.mvps.org/dotnet/code/graphics/#ImageNoLock>. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Automatic type casting?
Reference To Controls On A Form Crash in VB.NET 2005 Read mail from exchange 2003 DateDiff(DateInterval.DayOfYear Insert related tables into database. Automated Refactoring w/ CodeDom and VBCodeProvider... Class as an array Listbox DataSource Design binding problem TreeNode.Remove(Boolean notify) exception |
|||||||||||||||||||||||