Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 349
Viewed: 2815
Added: Aug 19, 2002
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

reads the header of a jpeg and gets it's information

Highlight all by clicking in box

Highlight All
Width As Long
Height As Long
End Type

Public Function GetJPGInfo(ByVal FileName As String) As BITMAPINFO
Dim bChar As Byte
Dim a As Byte, b As Byte
Dim c As Byte, D As Byte
Dim E As Byte, f As Byte
Dim i As Integer
Dim DotPos As Integer
Dim Header As String
Dim blExit As Boolean
Dim MarkerLen As Long
Dim ImgWidth As Integer
Dim ImgHeight As Integer
Dim ImgSize As String
Dim fnum As Integer
On Error Resume Next

fnum = FreeFile
Open FileName For Binary As #fnum

ImgSize = LOF(fnum) / 1024
DotPos = InStr(ImgSize, ",")
ImgSize = Left(ImgSize, DotPos)

Get #fnum, , bChar
Header = Hex$(bChar)
Get #fnum, , bChar
Header = Header & Hex$(bChar)
If Header <> "FFD8" Then Exit Function

While Not blExit
Do Until Hex$(bChar) = "FF"
Get #fnum, , bChar

Get #fnum, , bChar
If Hex$(bChar) >= "C0" And _
Hex$(bChar) <= "C3" Then
Get #fnum, , bChar
Get #fnum, , bChar
Get #fnum, , bChar

Get #fnum, , bChar
a = bChar
Get #fnum, , bChar
b = bChar
Get #fnum, , bChar
c = bChar
Get #fnum, , bChar
D = bChar

ImgHeight = CInt(a * 256 + b)
ImgWidth = CInt(c * 256 + D)
blExit = True
If Hex$(bChar) = "DA" Then
blExit = True
Get #fnum, , bChar
E = bChar
Get #fnum, , bChar
f = bChar
MarkerLen = (E * 256 + f) - 2

Dim marker As String
marker = String(MarkerLen, vbNullChar)
Get #fnum, , marker
End If
End If

Close #fnum

With ImageInfo
.Width = ImgWidth
.Height = ImgHeight
End With

GetJPGInfo = ImageInfo
End Function;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions