|
-
Aug 30th, 2012, 04:56 PM
#11
Re: [VB6] - animated gif function errors:(
You should not depend on just checking for Chr(33) as that will appear many times in the file and have nothing to do with the start of a frame. You need to scan for at least two characters Chr(33) and Chr(249) and then if the 3rd character is a Chr(4) can you be sure you have a start of frame. You use 13 to get the starting point because that is the end of the fixed header portion to scan for the 1st frames after that position (you could have just as well started with position 1, not 0) to get the same answer.
I know you are not picking up the correct data for an image because when I run your code I save each temp.gif file like this temp(1).gif, temp(2).gif, temp(3).gif, etc (I do not Kill the files during testing). Now when I double click on them I get invalid picture from different gif viewer applications and they won't display, they wont even display in the browser so I know they are not complete. It turns out that loading them back into your picturebox works (most of the time) because the picturebox doesn't seem to care but that doesn't mean the frames are correct or complete.
The InStr works the same for text, binary, chr(n) or any data.
VB requires that you at least start at position 1 (there is no position 0)
So,
Offset = Instr(start_position, data_to_scan, data_to_look_for)
start_position must be at least 1
data_to_scan can be any string. What is in the string doesn't matter because all data is binary.
data_to_look_for can be any valid string data like:
1) "you can scan for this"
2) Chr(33)
3) vbCrLf
4) 0 or any number from 0 to 255
If the data is not found in the string then Offset = 0
If the data is found in the string then Offset has the position of the 1st byte of the data_to_look_for.
Dim data_to_scan As String
data_to_scan = "This is a string which contains letters"
Offest = InStr(1, data_to_scan, "contains")
Offset will contain the value 24
Offest = InStr(26, data_to_scan, "contains")
Offset will contain the value 0
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|