Hi
hi all, I am new in here and I want asking, I have program that read the image from file with extension .ojn, I can show that image file into picturebox, Here my code to read the image:
VB.NET Syntax (Toggle Plain Text)
Dim path As String
path = openfiledialog1.filename
Using fs As New FileStream(path, FileMode.Open)
Using rdr As New BinaryReader(fs)
Dim Image As System.Drawing.Image = Nothing
fs.Seek(268, System.IO.SeekOrigin.Begin)
Dim BinaryReader As System.IO.BinaryReader = New System.IO.BinaryReader(fs)
Dim ImageLength As System.Int32 = BinaryReader.ReadInt32
fs.Seek(296, System.IO.SeekOrigin.Begin)
Dim ImageOffset As System.Int32 = BinaryReader.ReadInt32
fs.Seek(ImageOffset, System.IO.SeekOrigin.Begin)
Dim Buffer(ImageLength - 1) As System.Byte
Dim BytesRead As System.Int32 = 0
BytesRead = fs.Read(Buffer, 0, Buffer.Length)
If BytesRead = Buffer.Length Then
Dim MemoryStream As System.IO.MemoryStream = New System.IO.MemoryStream(Buffer)
Image = System.Drawing.Image.FromStream(MemoryStream).Clone
PictureBox1.Image = Image
MemoryStream.Close()
MemoryStream.Dispose()
End If
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message , vbCritical, "Error!")
End Try
268 is offset that contain image size (in byte) and 296 is offset that contains the image.
I want user can replace image on offset 296 and write size of selected image to 268.
Sorry If My English so bad, Thanks!