Image Clear

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have Problem to clear the image vb.net
i have one picture box and 4 button but the problem is that if picture is save in the path folder
and load in the form load the clear button is work fine and clear the image but after that
when i browse the image and press OK picture box load the image then i press clear button
the image is not clear its automatically Stretch the Image.plz help me how can i clear thew image
button 1 browse

If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then<br/>
OpenFileDialog1.Filter = "All Type Of Image Files|*.*|Joint Photographic Experts Group [JPEG]|*.jpg|Bitmap [BMP|*.bmp|Tagged Image File Format [TIFF]|*.tiff|Portable Network Graphics [PNG]|*.png"<br/>
PictureBox1.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName)<br/>
Dim bm As New Bitmap(OpenFileDialog1.FileName)<br/>
PictureBox1.Image = bm<br/>
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage<br/>
<br/>
End If
button 2 Clear picture
<br/>
PictureBox1.Image = Nothing
button 3 Delete from the path picture.
Dim FileToDelete As String<br/>
FileToDelete = "C:PhotosA.jpg"<br/>
If System.IO.File.Exists(FileToDelete) = True Then<br/>
System.IO.File.Delete(FileToDelete)<br/>
MsgBox("File Deleted")<br/>
End If<br/>
button 4 save picture.
Dim strFilePath As String<br/>
Dim strFileName As String<br/>
strFileName = "A.jpg"<br/>
strFilePath = "C:Photos"<br/>
>> Check if Folder Exists
<br/>
If Directory.Exists(strFilePath) = False Then<br/>
Call Directory.CreateDirectory(strFilePath)<br/>
End If<br/>
>> Save Picture
<br/>
Call PictureBox1.Image.Save(strFilePath & "" & strFileName, System.Drawing.Imaging.ImageFormat.Jpeg)

<br/>

View the full article
 
Back
Top