|
-
Aug 22nd, 2012, 05:33 PM
#9
Re: [VB6] - animated gif function errors:(
 Originally Posted by joaquim
[CODE]
i have 1 question: if we use '*256' for with 2 bytes, we must use for 1 byte too?
is:
GCGraficControl.TransparentColor = Asc(Mid$(strFrame, 7, 1))
or
GCGraficControl.TransparentColor = Asc(Mid$(strFrame, 7, 1))*256
??
thanks
The * 256 is only for 2-byte values. That's how you get the MSD/LSD order which is what we need for normal math. The values in the file are in LSD/MSD order.
Forget about your BinaryToDecimal and DecimalToBinary functions- they are not needed and they are just over-kills; it isn't that complicated to get the correct results.
'
' Logical Screen Description
'
strLogicalScreenDescription = Mid$(FileBuffer, 7, 7)
LSDLogicalScreenDescription.GifWidth = Asc(Mid(strLogicalScreenDescription, 1, 1)) + Asc(Mid(strLogicalScreenDescription, 2, 1)) * 256
LSDLogicalScreenDescription.GifHeight = Asc(Mid(strLogicalScreenDescription, 3, 1)) + Asc(Mid(strLogicalScreenDescription, 4, 1)) * 256
PackedField = Asc(Mid$(strLogicalScreenDescription, 5, 1))
LSDLogicalScreenDescription.GlobalColorFlag = (PackedField And 128) / 2 ^ 7
LSDLogicalScreenDescription.ColorResolution = (PackedField And 112) / 2 ^ 4
LSDLogicalScreenDescription.SortFlag = (PackedField And 8) / 2 ^ 3
' NOTE - This value is meanless if GlobalColorFlag is 0
LSDLogicalScreenDescription.GlobalColorSize = PackedField And 7
LSDLogicalScreenDescription.GlobalColorSize = 3 * (2 ^ (LSDLogicalScreenDescription.GlobalColorSize + 1))
LSDLogicalScreenDescription.BackColor = Asc(Mid$(strLogicalScreenDescription, 6, 1))
LSDLogicalScreenDescription.PixelRadio = Asc(Mid$(strLogicalScreenDescription, 7, 1))
'
' Get Grafic Control
'
PackedField = Asc(Mid$(strFrame, 4, 1))
GCGraficControl.Disposal = (PackedField And 12) / 2 ^ 2
' ADDED BY JMS
GCGraficControl.UserInput = (PackedField And 2) / 2 ^ 1
' ADDED BY JMS
GCGraficControl.TransparentFlag = (PackedField And 1)
'
' Changed to * 10 from * 100 because you say it's more normal
'
GCGraficControl.Delay = (Asc(Mid(strFrame, 5, 1)) + Asc(Mid(strFrame, 6, 1)) * 256) * 10
' NOTE This value is meaningless if TransparentFlag is 0
GCGraficControl.TransparentColor = Asc(Mid$(strFrame, 7, 1))
'
' Get Image Description
'
IDImageDescription.FrameLeft = Asc(Mid(strFrame, 10, 1)) + Asc(Mid(strFrame, 11, 1)) * 256
IDImageDescription.FrameTop = Asc(Mid(strFrame, 12, 1)) + Asc(Mid(strFrame, 13, 1)) * 256
IDImageDescription.FrameWidth = Asc(Mid(strFrame, 14, 1)) + Asc(Mid(strFrame, 15, 1)) * 256
IDImageDescription.FrameHeight = Asc(Mid(strFrame, 16, 1)) + Asc(Mid(strFrame, 17, 1)) * 256
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
|