I\'m am having a heck of a time finding a code snippet that works for this. I have got to the point where it appears the picture is stored as a blob (perhaps incorrectly) by
What happens if you switch this:
Dim ad As New System.IO.MemoryStream(100000)
to:
Dim ad As New System.IO.MemoryStream()
EDIT
VB array sizes are different than other programming languages, I think you need to do a minus 1:
rawData = New Byte(FileSize - 1) {}
EDIT 2
Alright, lets look over what you have for raw binary data. All JPGs should start with FFD8
and end with FFD9
. Insert the following after you set the rawData
array. If it throws an error then your JPEG information is corrupt.
If (rawData(0) = &HFF) AndAlso (rawData(1) = &HD8) Then
Trace.WriteLine("File start OK")
Else
Throw New ApplicationException("Invalid jpg header")
End If
If (rawData(rawData.Length - 2) = &HFF) AndAlso (rawData(rawData.Length - 1) = &HD9) Then
Trace.WriteLine("File end OK")
Else
Throw New ApplicationException("Invalid jpg footer")
End If
EDIT 3
We're going to need to see what the first few bytes of the data look like. Run this and post what gets outputed:
For I = 0 To 20
Trace.Write(Convert.ToString(rawData(I), 16).ToUpperInvariant())
Next