Prev: Linux
Next: The BIG Picture (VB vs the OS)
From: argusy on 25 Jan 2010 08:21 I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) I'm trying to open a jpg file, find the position of "FF C0 00 01 08" and get the next four bytes of info. (width and height of said jpg) That data never stays in one fixed spot, so I have to find it. Seniors moments are a pita, and I can't remember how to do it. I could go through all those books I bought on VB6, but I'll bet you I won't find what I want until next week, or next month. Anyone interested in giving me a hand with the code? (63 in 8 minutes, now) Graham
From: argusy on 25 Jan 2010 08:29 argusy wrote: > I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) > > I'm trying to open a jpg file, find the position of "FF C0 00 01 08" and > get the next four bytes of info. (width and height of said jpg) > > That data never stays in one fixed spot, so I have to find it. > > Seniors moments are a pita, and I can't remember how to do it. > I could go through all those books I bought on VB6, but I'll bet you I > won't find what I want until next week, or next month. > > Anyone interested in giving me a hand with the code? > > (63 in 8 minutes, now) > > Graham > oops! that's "FC C0 00 11 08" for those finicky buggers who probably know what I'm supposed to be looking for. Happy birthday to me, happy birthday too meee, hippy burfdy to Graham... Yep, I've been imbibing a bit as well....... Grah .. now how do i spel that name?
From: argusy on 25 Jan 2010 08:32 argusy wrote: > argusy wrote: >> I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) >> >> I'm trying to open a jpg file, find the position of "FF C0 00 01 08" >> and get the next four bytes of info. (width and height of said jpg) >> >> That data never stays in one fixed spot, so I have to find it. >> >> Seniors moments are a pita, and I can't remember how to do it. >> I could go through all those books I bought on VB6, but I'll bet you I >> won't find what I want until next week, or next month. >> >> Anyone interested in giving me a hand with the code? >> >> (63 in 8 minutes, now) >> >> Graham >> > oops! > > that's "FC C0 00 11 08" for those finicky buggers who probably know what > I'm supposed to be looking for. > > Happy birthday to me, happy birthday too meee, hippy burfdy to Graham... > Yep, I've been imbibing a bit as well....... > > Grah .. now how do i spel that name? > Hellup!! Hellppp!! The XYL is dragging me orff, I'll pick up tomorrow.
From: Nobody on 25 Jan 2010 12:33 Happy Birthday! Option Explicit Private Sub Form_Load() Dim b() As Byte Dim bFind(1 To 5) As Byte bFind(1) = &HFC bFind(2) = &HC0 bFind(3) = &H0 bFind(4) = &H11 bFind(5) = &H8 b = GetEntireFile("C:\Test.jpg") Debug.Print InByteArray(1, b, bFind) End Sub ' Read the entire file into a byte array and returns it Public Function GetEntireFile(ByRef FileName As String) As Byte() Dim f As Integer Dim FileContents() As Byte Dim i As Long f = FreeFile Open FileName For Binary Access Read Shared As f ' Allocate buffer for the entire file ReDim FileContents(1 To LOF(f)) ' Read the entire file into memory Get f, , FileContents Close f GetEntireFile = FileContents End Function ' Searches a binary array for a matching series of bytes. Returns the ' index of the first byte that matches the series of bytes, 0 otherwise. Public Function InByteArray(ByVal posStart As Long, ByRef a() As Byte, _ ByRef bFind() As Byte) As Long Dim i As Long Dim j As Long Dim FindLBound As Long Dim FindUBound As Long ' For performance, store LBound/UBound in variables ' because they don't change. FindLBound = LBound(bFind) FindUBound = UBound(bFind) For i = posStart To UBound(a) For j = FindLBound To FindUBound If bFind(j) <> a(i + j - FindLBound) Then ' Not all bytes match Exit For End If Next If j = FindUBound + 1 Then ' This is only True when the "j" loop completed ' without interruption. We can use a Boolean "Found" ' variable, but that uses extra variable. InByteArray = i Exit Function End If Next End Function
From: Mike Williams on 25 Jan 2010 18:27
"argusy" <argusy(a)slmember.on.net> wrote in message news:00e71fe6$0$15588$c3e8da3(a)news.astraweb.com... > I'm having a seniors moment (63 tomorrow, that's > in 13 minutes time, btw) So by now you'll be heading for 64! Still just a youngster though . . . according to DateDiff I turned 63 about 1,805,727 minutes ago :-) Mike |