-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
i all most put the "vampire bed" gif animation working;)
my problem is: why the picturebox show us the big frame on back(speaking on 1st frame)(when changes from method 2 or 3 to method 1)?
Code:
Case 0, 1 ' Leave
aimg(aimg.Count - 1).Cls
If fraFrame(i - 1).GCGraphicControl.Disposal = 2 Then
BitBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, aimg(i - 1).ScaleWidth, aimg(i - 1).ScaleHeight, aimg(i - 1).hdc, 0, 0, vbSrcCopy
Else
BitBlt aimg(aimg.Count - 1).hdc, 0, 0, aimg(i - 1).ScaleWidth, aimg(i - 1).ScaleHeight, aimg(i - 1).hdc, 0, 0, vbSrcCopy
End If
If fraFrame(i).GCGraphicControl.TransparentFlag <> 0 Then
TransparentBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, _
aimg(i).ScaleWidth, aimg(i).ScaleHeight, aimg(i).hdc, 0, 0, aimg(i).ScaleWidth, aimg(i).ScaleHeight, fraFrame(i).GCGraphicControl.TransparentColorIndex
Else
BitBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, _
aimg(i).ScaleWidth, aimg(i).ScaleHeight, aimg(i).hdc, 0, 0, vbSrcCopy
End If
aimg(i).Cls
aimg(i).Picture = aimg(aimg.Count - 1).Image
aimg(aimg.Count - 1).Cls
for me, these draw bug don't makes since:(
Are you paying any attention to what I have said to you many times? It doesn't look like you are. Go back and read my previous post again.
-
Re: [VB6] - animated gif function errors:(
i have found my problem:
Code:
Case 0, 1 ' Leave
aimg(aimg.Count - 1).Picture = Nothing
If fraFrame(i - 1).GCGraphicControl.Disposal = 2 Or fraFrame(i - 1).GCGraphicControl.Disposal = 3 Then
Else
BitBlt aimg(aimg.Count - 1).hdc, 0, 0, aimg(i - 1).ScaleWidth, aimg(i - 1).ScaleHeight, aimg(i - 1).hdc, 0, 0, vbSrcCopy
End If
If fraFrame(i).GCGraphicControl.TransparentFlag <> 0 Then
TransparentBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, _
aimg(i).ScaleWidth, aimg(i).ScaleHeight, aimg(i).hdc, 0, 0, aimg(i).ScaleWidth, aimg(i).ScaleHeight, fraFrame(i).GCGraphicControl.TransparentColorIndex
Else
BitBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, _
aimg(i).ScaleWidth, aimg(i).ScaleHeight, aimg(i).hdc, 0, 0, vbSrcCopy
End If
aimg(i).Picture = Nothing
aimg(i).Picture = aimg(aimg.Count - 1).Image
i have 1 question about CLS method: only clean what picturebox show us or everything that it's in picturebox?
can you tell me how can i calculate the Interlace(and what is in Packed Field) on Image Description?
thanks for all
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
i have 1 question about CLS method: only clean what picturebox show us or everything that it's in picturebox?
CLS clears only what you have painted onto the picturebox. It does not clear the picture property.
Quote:
Originally Posted by
joaquim
can you tell me how can i calculate the Interlace
Interlace? Are you going to try and use the image data from the file?
The interlace is quite complicated and I do not believe that I could explain it to you so that you would understand what I am saying but go to the link below and see if you can understand what is being said.
http://en.wikipedia.org/wiki/Graphic...rchange_Format
Quote:
Originally Posted by
joaquim
(and what is in Packed Field) on Image Description?
l
Code:
Image Descriptor
'
' <---X---> <---Y---> <-Width-> <-Height->
' +----+----+----+----+----+----+----+----+----+----+
' | 2C | xx | xx | xx | xx | xx | xx | xx | xx | xx |
' +----+----+----+----+----+----+----+----+----+----+
' |
' +----------- Local Color Table ----------------+
' |
' | location of image within logical window
' | GIF Image Descriptor (packed byte)
' |
' Bit Pos: 7 6 5 4 3 2 1 0
' | | | | |
' | | | | Palette Bit Depth And with 0 0 0 0 0 1 1 1 = &H07 = 7
' | | | Reserver And with 0 0 0 1 1 0 0 0 = &H18 = 24
' | | Table Sorted And with 0 0 1 0 0 0 0 0 = &H20 = 32
' | Interlaced And with 0 1 0 0 0 0 0 0 = &H40 = 64
' Local Color Table used And with 1 0 0 0 0 0 0 0 = &H80 = 128
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
CLS clears only what you have painted onto the picturebox. It does not clear the picture property.
Interlace? Are you going to try and use the image data from the file?
The interlace is quite complicated and I do not believe that I could explain it to you so that you would understand what I am saying but go to the link below and see if you can understand what is being said.
http://en.wikipedia.org/wiki/Graphic...rchange_Format
Code:
Image Descriptor
'
' <---X---> <---Y---> <-Width-> <-Height->
' +----+----+----+----+----+----+----+----+----+----+
' | 2C | xx | xx | xx | xx | xx | xx | xx | xx | xx |
' +----+----+----+----+----+----+----+----+----+----+
' |
' +----------- Local Color Table ----------------+
' |
' | location of image within logical window
' | GIF Image Descriptor (packed byte)
' |
' Bit Pos: 7 6 5 4 3 2 1 0
' | | | | |
' | | | | Palette Bit Depth And with 0 0 0 0 0 1 1 1 = &H07 = 7
' | | | Reserver And with 0 0 0 1 1 0 0 0 = &H18 = 24
' | | Table Sorted And with 0 0 1 0 0 0 0 0 = &H20 = 32
' | Interlaced And with 0 1 0 0 0 0 0 0 = &H40 = 64
' Local Color Table used And with 1 0 0 0 0 0 0 0 = &H80 = 128
i was thinking(from what i read) that Interlaced is a flag for like '0' or '1'.... and for tells us that we need change the backcolor for draw the image better. and i have tested the backcolor and works.
but now i know how test if the image needs it;)
so: interlaced=(PackedField And 64)
thanks for all
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
i was thinking(from what i read) that Interlaced is a flag for like '0' or '1'.... and for tells us that we need change the backcolor for draw the image better. and i have tested the backcolor and works.
but now i know how test if the image needs it;)
so: interlaced=(PackedField And 64)
thanks for all
I don't know where you read that but it is not correct. The Interlaced flag tells you if the image is interlaced or not. It has absolutely nothing to do with changing the backcolor. Look at the following table and if you can understand it OK but what do you think you are going to do with it. It is only meaningfull if you decide to encode the graphics data to render your image instead of using the method you use now (loading re-made files with each frame).
Code:
Interlaced Images.
The rows of an Interlaced images are arranged in the following order:
Group 1 : Every 8th. row, starting with row 0. (Pass 1)
Group 2 : Every 8th. row, starting with row 4. (Pass 2)
Group 3 : Every 4th. row, starting with row 2. (Pass 3)
Group 4 : Every 2nd. row, starting with row 1. (Pass 4)
The Following example illustrates how the rows of an interlaced image are
ordered.
Row Number Interlace Pass
0 ----------------------------------------- ----> 1
1 ----------------------------------------- ----------------------> 4
2 ----------------------------------------- ----------------> 3
3 ----------------------------------------- ----------------------> 4
4 ----------------------------------------- ----------> 2
5 ----------------------------------------- ----------------------> 4
6 ----------------------------------------- ----------------> 3
7 ----------------------------------------- ----------------------> 4
8 ----------------------------------------- 1
9 ----------------------------------------- 4
10 ----------------------------------------- 3
11 ----------------------------------------- 4
12 ----------------------------------------- 2
13 ----------------------------------------- 4
14 ----------------------------------------- 3
15 ----------------------------------------- 4
16 ----------------------------------------- 1
17 ----------------------------------------- 4
18 ----------------------------------------- 3
19 ----------------------------------------- 4
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
see these image...
if backcolor is black, you see some squars arrow the image. but if it's white, the image is drawed correctly. these happens with very images and i thot that the right term was Interlaced.
(if my explication is confused, test it on that image and you see what i mean)
-
Re: [VB6] - animated gif function errors:(
The background color is not black; it is off-white. The color of the background is R=251, G=251, B=251 which is not quite pure white.
Here's a rule you should go by. If the 1st frame has transparency then do not use background color; use the color of the canvas instead. If the 1st frame does not have transparency then use the background color of the image as the color of your canvas.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
The background color is not black; it is off-white. The color of the background is R=251, G=251, B=251 which is not quite pure white.
Here's a rule you should go by. If the 1st frame has transparency then do not use background color; use the color of the canvas instead. If the 1st frame does not have transparency then use the background color of the image as the color of your canvas.
we have the GifBackColor:
Code:
LSDLogicalScreenDescription.BackgroundColor = Asc(Mid$(strLogicalScreenDescription, 6, 1))
and we have the frame transparent color:
Code:
fraFrame(i).GCGraphicControl.TransparentColorIndex = Asc(Mid$(GifImageString, 7, 1))
now how can calculate the frame backcolor?
-if it's in picturebox image, we use:
Code:
GetPixel(aimg(i).hdc,0,0)
heres how i change the backcolor:
Code:
'Now change the backcolor
If fraFrame(i).GCGraphicControl.TransparentFlag = 1 Then
aimg(i).BackColor = fraFrame(i).GCGraphicControl.TransparentColorIndex
Else
aimg(i).BackColor = GetPixel(aimg(i).hdc,0,0)
End If
If fraFrame(i).GCGraphicControl.Disposal = 2 Then aimg(i).BackColor = vbWhite
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
we have the GifBackColor:
Code:
LSDLogicalScreenDescription.BackgroundColor = Asc(Mid$(strLogicalScreenDescription, 6, 1))
No! That is not the background color. I have told you many times in my earlier posts about that. Go back and read my previous post #81, page 4
Quote:
Originally Posted by
joaquim
and we have the frame transparent color:
Code:
fraFrame(i).GCGraphicControl.TransparentColorIndex = Asc(Mid$(GifImageString, 7, 1))
Same thing as background color above
Quote:
Originally Posted by
joaquim
now how can calculate the frame backcolor?
-if it's in picturebox image, we use:
Code:
GetPixel(aimg(i).hdc,0,0)
No! You cannot use GetPixel(). I have also told you about that many times. It won't work
Quote:
Originally Posted by
joaquim
heres how i change the backcolor:
Code:
'Now change the backcolor
If fraFrame(i).GCGraphicControl.TransparentFlag = 1 Then
aimg(i).BackColor = fraFrame(i).GCGraphicControl.TransparentColorIndex
Else
aimg(i).BackColor = GetPixel(aimg(i).hdc,0,0)
End If
If fraFrame(i).GCGraphicControl.Disposal = 2 Then aimg(i).BackColor = vbWhite
No! Your code is wrong! I told you before that Disposal values have nothing to do with the color of anything.
If you are not going to pay attention to what I have been telling you then I see no point is continueing on because you keep asking questions based on incorrect logic and you will never get your code to work correctly for all gif files. Just because it has appeared to work on some, notice I said appeared to work, it doesn't work. If you do not obey the rules of gif specifications then what is your point?
Once you get it straight in your head how these things work and you start using the correct logic you will find that many of your previous problems will disappear. I'm not saying that all problems will be resolved but at least get it correct from what I have told you then we can go forward but as it is you are just standing still.
-
Re: [VB6] - animated gif function errors:(
i have update my code and now works for all method '0'(except the meter... i must do 1 exact for the '0') and '1'. but the '2' isn't 100% by 1 reason:
Code:
aimg(aimg.Count - 1).Picture = Nothing
BitBlt aimg(aimg.Count - 1).hdc, fraFrame(i).IDImageDescription.FrameLeft, fraFrame(i).IDImageDescription.FrameTop, _
fraFrame(i).IDImageDescription.FrameWidth, fraFrame(i).IDImageDescription.FrameHeight, aimg(i).hdc, 0, 0, vbSrcCopy
aimg(i).Picture = aimg(aimg.Count - 1).Image
the picturebox use, always the same size and i can't control the size correctly:(
any advice?
-
Re: [VB6] - animated gif function errors:(
There is no Method 2 in the meter.gif
Methods 0 and 1 can be treated as the same.
Meter.gif has 1st frame as Leave and all others are Undefined. No transparency in file. Each of the small meter rating pieces (frames 2 - 68) must be exactly the correct size and placed exactly correctly since they have no transparency they must overlay the 1st image in it's exact position.
I see no reason why your positions are incorrect if you extracted the correct positions from the file for frames 2 - 68
Just for testing check the positions of frames 2 - 6. They should be
2) 2,48,10,3
3) 16,48,10,3
4) 30,48,10,3
5) 44,48,10,3
6) 44,44,10,3
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
There is no Method 2 in the meter.gif
Methods 0 and 1 can be treated as the same.
Meter.gif has 1st frame as Leave and all others are Undefined. No transparency in file. Each of the small meter rating pieces (frames 2 - 68) must be exactly the correct size and placed exactly correctly since they have no transparency they must overlay the 1st image in it's exact position.
I see no reason why your positions are incorrect if you extracted the correct positions from the file for frames 2 - 68
Just for testing check the positions of frames 2 - 6. They should be
2) 2,48,10,3
3) 16,48,10,3
4) 30,48,10,3
5) 44,48,10,3
6) 44,44,10,3
thanks for explain to me the meter. i can see the frames(in files), but by some reason the frame it's the same. test the code using the 'i' on files temp and don't kill them. and you see what i mean.
but the ball.gif is give me a control size error:(
i know that is the method 2(all frames), but by some reason i can't see the other frames(only the first). i try control the control size, but seems not working:(
-
Re: [VB6] - animated gif function errors:(
joaquim,
since you have updated your project I need to test with your most recent version otherwise the output may be different so please include you most recent updated version
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
joaquim,
since you have updated your project I need to test with your most recent version otherwise the output may be different so please include you most recent updated version
heres my entire project. for test and see the frames delete the code line:
Code:
'destroy the temp file
Kill App.Path & "\Temp" & i & ".gif"
inside of loop;)
i see the error on 2 images:
meter.gif(something isn't correct with frames:()
(that halloween31.gif image is working fine;))
and the ball.gif... because i can't see the animation correctly. only because of control size:(
thanks for all
-
Re: [VB6] - animated gif function errors:(
One problem I see is that you are not making enough frames from meter. There are 68 frames. You only have 67 (0 to 66) should be 0 to 67. You have a missing frame. Has nothing to do with frame alignment however which I will see what is going on. Other gif files don't work either like ball.gif (which you already stated), down, left, right, and up have wrong backcolor (black is not correct, should be transparent) and star3 has error 50003 loading frame 6. Other gif files don't work that I have tested (ones you don't have in your collection).
First, I'll work on meter.gif
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
One problem I see is that you are not making enough frames from meter. There are 68 frames. You only have 67 (0 to 66) should be 0 to 67. You have a missing frame. Has nothing to do with frame alignment however which I will see what is going on. Other gif files don't work either like ball.gif (which you already stated), down, left, right, and up have wrong backcolor (black is not correct, should be transparent) and star3 has error 50003 loading frame 6. Other gif files don't work that I have tested (ones you don't have in your collection).
First, I'll work on meter.gif
when i create a a file, i do:
Code:
PictureBuffer = Mid$(FileBuffer, 1, FirstFrame - 1) & GifImageString & Chr(59) '3B
- Mid$(FileBuffer, 1, FirstFrame - 1): is the heather gif file(not heather frame)
- GifImageString: is the frame string....
the backcolor been incorrect is that in Mid$(FileBuffer, 1, FirstFrame - 1) give us the gif backcolor instead frame backcolor?
-
Re: [VB6] - animated gif function errors:(
It because you are not using the back color (and you are not using the transparent color either); you are using the index to those colors. In many cases the index will be 0 which is black but 0 means to use color 0 from the color table not the index 0.
-
Re: [VB6] - animated gif function errors:(
All image information are in the ImageDescriptor which is identified by 2C but your code does not get all 2C ImageDescriptors. Your code only searches for 21F9 and then assumes that the ImageDescriptor is at a fixed position beyond that but that is not always the case. Also, an ImageDescriptor can be in a field 21FF which your code does not even search for. For meter.gif the first frame is in a ImageDescriptor (2C) which is in a field marked by 21FF (the Netscape block). This caused 2 frames to be in one saved file; the first frame which is in the Netscape block and the 2nd frame which is in the 21F9 block. This why you are missing image frames from meter.gif and it is probably what is causing your weird problem in the animation; you are actually showing the first frame over and over again because it is in every file you make. I'm sure other gif files are made this way also so you need to re-vamp your code somewhat. Also, quit using the index as the color. It appears that since there is a frame in the 21FF block on all your saved files then all of your saved files will have two pictures in them. I'm surprised it worked the way it does but before I can't straighten out the alignment problem the first problem needs to be corrected and that is to in addition to looking for just 21F9 blocks for image data you also need to look for 21FF blocks and extract out the 1st image and then DO NOT include the 21FF in your other output files (that means you need to not include the 21FF block in the other files.
EDIT:
I looked at some of the output files you make for meter.gif and I see that they all have the first frame in them plus not only that they contain multiple 21F9 blocks
EDIT:
I looked at other output files you make from other gifs and I see that they too have more than one 21F9 block.
I thought the purpose of your code was to make a separate file, one for each frame but if that is so then why do these files have multiple 21F9 blocks in them? What are you doing?
-
Re: [VB6] - animated gif function errors:(
what i do is:
Header Block + Logical Screen Descriptor + Global Color Table + actualframe + Trailer
actualframe = Graphics Control Extension + Image Descriptor + Local Color Table + Image Data
the actual frame is what is in strFramestring.
if i need delete or avoid or change some blocks, i don't know:(
-
Re: [VB6] - animated gif function errors:(
What you do is search from one 21F9 to the next 21F9 and assume that is your images data you want and in some cases it will work but in other cases it will not work. Meter.gif is a good example of one that does not work using your method. When I try to use your output files in a Gif Image Viewer they are all invalid gif files but they are OK for just loading them back into a Picturebox because the Picturebox does not care if the file is invalid or not as long as there is an image in it. The fact that you are outputting invalid gif files tells you that your code is not right. I don't know where you got that code but who ever made it didn't understand the gif format completely. In the case of the meter.gif what is happening is you are displaying the same image over and over again but using the Left and Top values of the other frames and that is what is causing the flickering like results.
Here are some of the things you are doing incorrectly:
1) You search for the 1st 21F9 and assume that is the end of the Global Color Table. Then you make that your Header Block but that will not always work (meter.gif is an example). DO NOT use the 1st 21F9 as the end of the Color Table, use the exact length of the table.
2) You only search for 21F9 code and assume that is the image data you need but image data can also appear in a 21FF block so you ignore the image in these blocks and now you have an invalid gif file. This is what happened when you tried to animate the meter.gif; you actually put an image in the Header Block and then attached another image to it from your actualFrame data thus make a 2-image file. When you load that file back into a Picturebox only the 1st image is placed in the Picturebox which is the same image for all of the frames.
3) You are using the Index to the color table as the actual background color and this is incorrect. The Index points to the actual background color in the color table. In most cases you wind up with black because the Index is 0 and 0 is black.
4) You use GetPixel API to get the transparent color (or background color) from the 0,0 of the image and this is incorrect. The transparent color is in the color table and it has an Index to it just like the background color.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
What you do is search from one 21F9 to the next 21F9 and assume that is your images data you want and in some cases it will work but in other cases it will not work. Meter.gif is a good example of one that does not work using your method. When I try to use your output files in a Gif Image Viewer they are all invalid gif files but they are OK for just loading them back into a Picturebox because the Picturebox does not care if the file is invalid or not as long as there is an image in it. The fact that you are outputting invalid gif files tells you that your code is not right. I don't know where you got that code but who ever made it didn't understand the gif format completely. In the case of the meter.gif what is happening is you are displaying the same image over and over again but using the Left and Top values of the other frames and that is what is causing the flickering like results.
Here are some of the things you are doing incorrectly:
1) You search for the 1st 21F9 and assume that is the end of the Global Color Table. Then you make that your Header Block but that will not always work (meter.gif is an example). DO NOT use the 1st 21F9 as the end of the Color Table, use the exact length of the table.
2) You only search for 21F9 code and assume that is the image data you need but image data can also appear in a 21FF block so you ignore the image in these blocks and now you have an invalid gif file. This is what happened when you tried to animate the meter.gif; you actually put an image in the Header Block and then attached another image to it from your actualFrame data thus make a 2-image file. When you load that file back into a Picturebox only the 1st image is placed in the Picturebox which is the same image for all of the frames.
3) You are using the Index to the color table as the actual background color and this is incorrect. The Index points to the actual background color in the color table. In most cases you wind up with black because the Index is 0 and 0 is black.
4) You use GetPixel API to get the transparent color (or background color) from the 0,0 of the image and this is incorrect. The transparent color is in the color table and it has an Index to it just like the background color.
the size of table is expressed on Bytes?
(i can see the value, like you see on my code... but i don't know if it's in Bytes or other way)
-
Re: [VB6] - animated gif function errors:(
Tell you what. Instead of trying to explain things to you and trying to help you straighten out your code which as it is written you probably will spend many more weeks on getting it right, if ever, why don't I just re-write your project using my code which is correct and attaching it to your Form code. Would you want me to do that?
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Tell you what. Instead of trying to explain things to you and trying to help you straighten out your code which as it is written you probably will spend many more weeks on getting it right, if ever, why don't I just re-write your project using my code which is correct and attaching it to your Form code. Would you want me to do that?
but my objective is learn more that you teach me;)
thanks to you, i know:
1 - that binary files use blocks and 1 block is 1 Byte and 1 byte is a ascii char(then i must convert it);
2 - the gif struture.
i apreciate everything that you did for me, realy... and some parts i don't get them, for now, but i will.
if you write the all code:
1 - you have all the credits;);
2 - can i learn more from it?
i must understand what it's incorrect with my code. but not all manuals can tell us everything, but your experience can;)
can you tell me somethings that i need to know for correct my errors?
1 - i see that i can't think on gif ends, but where the color table ends. but for that i need to understand how calculate the size;)
2 - i understand that i need the use the frame Backcolor, instead the gif backcolor or the getpixel(), and the transparent color if is used... problem: i must understand how calculate the frame backcolor.
but, if i'm bored you, i'm realy sorry about that:(
-
Re: [VB6] - animated gif function errors:(
Well, there are two ways to learn, the right way and the wrong way. In my learning experience I have found that there comes a time that I simply need to scrap what I have done and start over with the more correct way of doing it. I have found that it is becomes pointless to continue on with what I have if what I have is more work to straighten out than it is to just start over again. Besides, trying to correct what you have isn't really going to teach you much since your logical approach is not the best way to handle this. If I am writing something and even though it may work some of the time and not work other times and I find that my whole approach is getting more and more complex and more and more complicated but still I just can't seem to get it to work I finally decide that it is time to look at some other appraoch. Most coding that I have learned I have learned from others who knew better ways than me. Why teach myself something the wrong way when someone else can teach me the right way even it it means throwing away what I have and get from them something that will teach me to understand better because their way is better and I really want to learn the better way than to keep fooling around with my own mess that I have made. Time is important and if I can get something done in a shorter time and not waste my time on something that I keep getting into blind spots then yes, give me the right way to do it, let me learn from it.
I have no problem taking my code and making it work for your project which will explain to you more about how to handle gif files better than I could explain things to you and how to fix it in your current code since your current code is really not the way to parse a gif file.
It's up to you. You can continue on fighting these problems with what you have or you can start learning the right way to handle gif logic.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Well, there are two ways to learn, the right way and the wrong way. In my learning experience I have found that there comes a time that I simply need to scrap what I have done and start over with the more correct way of doing it. I have found that it is becomes pointless to continue on with what I have if what I have is more work to straighten out than it is to just start over again. Besides, trying to correct what you have isn't really going to teach you much since your logical approach is not the best way to handle this. If I am writing something and even though it may work some of the time and not work other times and I find that my whole approach is getting more and more complex and more and more complicated but still I just can't seem to get it to work I finally decide that it is time to look at some other appraoch. Most coding that I have learned I have learned from others who knew better ways than me. Why teach myself something the wrong way when someone else can teach me the right way even it it means throwing away what I have and get from them something that will teach me to understand better because their way is better and I really want to learn the better way than to keep fooling around with my own mess that I have made. Time is important and if I can get something done in a shorter time and not waste my time on something that I keep getting into blind spots then yes, give me the right way to do it, let me learn from it.
I have no problem taking my code and making it work for your project which will explain to you more about how to handle gif files better than I could explain things to you and how to fix it in your current code since your current code is really not the way to parse a gif file.
It's up to you. You can continue on fighting these problems with what you have or you can start learning the right way to handle gif logic.
i wan't learn the right way... the correct logic. but can you tell me how or show the code?
(maybe, in time, i can avoid the temp files;))
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
Use below code for your modAniGif.bas module. I did not change you Form logic nor did I change your code logic for making the animation; I just gave you a correct way to parse a gif file. You will see that his works for 99.99% of all gif files (there's always those that don't conform to gif standards).
I think once you have this you will get a better understanding of gif files and see why this is the correct way to do it.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Use below code for your modAniGif.bas module. I did not change you Form logic nor did I change your code logic for making the animation; I just gave you a correct way to parse a gif file. You will see that his works for 99.99% of all gif files (there's always those that don't conform to gif standards).
I think once you have this you will get a better understanding of gif files and see why this is the correct way to do it.
thanks. i will test it.. thanks for all
-
Re: [VB6] - animated gif function errors:(
Here's some info
It uses a byte array instead of a string
Byte array is much faster than strings
You use a pointer to the byte in the array, In string you use Mid() function which is much slower.
A byte array is already in Ascii where a string is in Hex. Using a byte array you don't have to convert to Ascii
It uses a Select Case to find the blocks. Your code used Instr() which is much slower.
Your code scanned from one 21F9 to the next 21F9. Using the Select Case it picks up each block as it
appears in the file and processes it. This guarantees you won't miss any blocks.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Here's some info
It uses a byte array instead of a string
Byte array is much faster than strings
You use a pointer to the byte in the array, In string you use Mid() function which is much slower.
A byte array is already in Ascii where a string is in Hex. Using a byte array you don't have to convert to Ascii
It uses a Select Case to find the blocks. Your code used Instr() which is much slower.
Your code scanned from one 21F9 to the next 21F9. Using the Select Case it picks up each block as it
appears in the file and processes it. This guarantees you won't miss any blocks.
if the instr() is much slow... then how can i test the 21F9... using a For...next?
-
Re: [VB6] - animated gif function errors:(
Why do you want to test the 21F9 using For...Next? If you you use the module code as I gave it to you there is no reason why you need to be concerned about testing 21F9...it's all done for you in the Select Case
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by jmsrickland;******5
Why do you want to test the 21F9 using For...Next? If you you use the module code as I gave it to you there is no reason why you need to be concerned about testing 21F9...it's all done for you in the Select Case
yes.. thanks.
i see.. you use the selected case. and you use another loop for catch the block terminator frame. i must see more of your code. for correct my;)
and the frames are showed normaly... all that i have(speaking on methods).
thanks for all
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
yes.. thanks.
i see.. you use the selected case. and you use another loop for catch the block terminator frame. i must see more of your code. for correct my;)
and the frames are showed normaly... all that i have(speaking on methods).
thanks for all
Do you want me to send you the project from where I got the code I gave you yesterday?
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Do you want me to send you the project from where I got the code I gave you yesterday?
if you don't mine;)
thanks for all my friend
(anotherthing what tutorial you used for learn how read animated gif files?)
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
Here's a manual I learned from
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Here's a manual I learned from
thanks
-
Re: [VB6] - animated gif function errors:(
I'll upload my project later so you can see how and what mine does.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
I'll upload my project later so you can see how and what mine does.
i did 1 test. and i can see the metter.gif sub images:
Code:
GifImageStart = Chr(33) '& Chr(249) '& Chr(4)
but for other images don't works. but seems that ower error is in these line;)
can you advice me?
-
Re: [VB6] - animated gif function errors:(
What do you mean for other images it doesn't work? I tested it with all of your images and it works. The only images that don't come out right are down, left, right, and up and that's because you are using black as the background and they are not supposed to be on black but the code I gave you works.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
What do you mean for other images it doesn't work? I tested it with all of your images and it works. The only images that don't come out right are down, left, right, and up and that's because you are using black as the background and they are not supposed to be on black but the code I gave you works.
i mean that sub that i builded(not what you change it;))
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
i did 1 test. and i can see the metter.gif sub images:
Code:
GifImageStart = Chr(33) '& Chr(249) '& Chr(4)
but for other images don't works. but seems that ower error is in these line;)
can you advice me?
There is no GifImageStart = Chr(33) in the code I gave you.
-
Re: [VB6] - animated gif function errors:(
Well you need to make up your mind and tell me which module you are going to use. If you are not going to use the one I gave you then you are always going to have problems with yours and quite frankly I see no reason to fix it since it is wrong to begin with. If you test for just Chr(33) then you need to test the next byte as well and see if it is one of the ones that you need.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Well you need to make up your mind and tell me which module you are going to use. If you are not going to use the one I gave you then you are always going to have problems with yours and quite frankly I see no reason to fix it since it is wrong to begin with. If you test for just Chr(33) then you need to test the next byte as well and see if it is one of the ones that you need.
i use it... but i'm trying to see why i can't see the meter on my own sub. that's why;)
and i see that your pseudocode is diferent from mine and more cool;)
-
Re: [VB6] - animated gif function errors:(
You can't see the meter with your code because you capture the same image for all of your files. When you load the files back into your picturebox it's the same image, the first image, so all you see is the 1st image being played but they use the X and Y of the frames 2 - 67 and that is why it looks jitterly. Also, because you always have the same 1st frame your frame count is incorrect.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
You can't see the meter with your code because you capture the same image for all of your files. When you load the files back into your picturebox it's the same image, the first image, so all you see is the 1st image being played but they use the X and Y of the frames 2 - 67 and that is why it looks jitterly. Also, because you always have the same 1st frame your frame count is incorrect.
anotherthing that i need ask: for the real dimension, on control, we use the Gif dimension or frame dimension?
and how we change the control size. i try: control.width=imagewidth. but seems not be correct. the form is in pixels, but do i need use the screen properties for these?
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
Here's my project. I never finished it. The tabs are empty and the media control has no functionality. I decided to stop working on it and I went into a new version where the image is extracted out of the file and converted to a bitmap internally so it doesn't save and reload gif files like this version and yours does. Hope you like it.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
Here's my project. I never finished it. The tabs are empty and the media control has no functionality. I decided to stop working on it and I went into a new version where the image is extracted out of the file and converted to a bitmap internally so it doesn't save and reload gif files like this version and yours does. Hope you like it.
vey cool.. thanks.
you can see ball.gif without a problem... but my problem with these image is only the control size.
how can i control the control size?
(i'm speaking on last link(that is my sub updated by you))
PS: please see these thread: http://www.vbforums.com/showthread.p...51#post4239151
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
vey cool.. thanks.
you can see ball.gif without a problem... but my problem with these image is only the control size.
how can i control the control size?
(i'm speaking on last link(that is my sub updated by you))
PS: please see these thread:
http://www.vbforums.com/showthread.p...51#post4239151
I'm not sure I understand. What is control size?
The link to your post at the other thread....you save updated by me????? I don't think so.
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
I'm not sure I understand. What is control size?
The link to your post at the other thread....you save updated by me????? I don't think so.
sorry... on post #206. that code, with ball.gif, don't give me with right Width size. that's why i can't see the ball
-
Re: [VB6] - animated gif function errors:(
There are two ball gif files, ball1 and ball2 and they both look OK to me. I see that ball1 touches the edges of the picturebox but it does the same thing in my application (the one I just posted) so what is it that makes you think the width is incorrect?
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
There are two ball gif files, ball1 and ball2 and they both look OK to me. I see that ball1 touches the edges of the picturebox but it does the same thing in my application (the one I just posted) so what is it that makes you think the width is incorrect?
because i have test it;)
change the autosize to false and resize the control to more big and you see what i'm saying;)
my problem is use the big size of frame and continue with autosize true
-
Re: [VB6] - animated gif function errors:(
It still looks OK after I change to AutoSize = False and make it bigger. It's the same size image inside a bigger box which is exactly what should be expected.
Now do you want to make the Picturebox bigger, have it AutoSize = True and have the ball image be bigger?
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
It still looks OK after I change to AutoSize = False and make it bigger. It's the same size image inside a bigger box which is exactly what should be expected.
Now do you want to make the box bigger, AutoSize = True and have the ball image be bigger?
1 thing is the frame size and other is the gif size, right?
then what i want is use the AutoSize = True, but with gif size;)
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
1 thing is the frame size and other is the gif size, right?
then what i want is use the AutoSize = True, but with gif size;)
You use AutoSize = True if you want the Picturebox to be the same as the gif image size which is what you have been doing.
If you want the image to stay at gif size but you want the Picturebox to be bigger then you set AutoSize = False and then you should center the gif image in the Picturebox otherwise it will be positioned at the upper left corner.
I don't know what any of this has to do with you saying that the ball width is wrong. I tested both ball1 and ball2 and I see nothing wrong with them.
-
1 Attachment(s)
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
You use AutoSize = True if you want the Picturebox to be the same as the gif image size which is what you have been doing.
If you want the image to stay at gif size but you want the Picturebox to be bigger then you set AutoSize = False and then you should center the gif image in the Picturebox otherwise it will be positioned at the upper left corner.
I don't know what any of this has to do with you saying that the ball width is wrong. I tested both ball1 and ball2 and I see nothing wrong with them.
sorry i mean ball.gif file.
use the attachment file for see what i mean. for my Sprite2D isn't a problem because i can control the autosize manualy hehehe
but for another application can be a problem.
(do you want see my Sprite2D?)
thanks for all
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
joaquim
sorry i mean ball.gif file.
use the attachment file for see what i mean. for my Sprite2D isn't a problem because i can control the autosize manualy hehehe
but for another application can be a problem.
(do you want see my Sprite2D?)
thanks for all
Yes, I would like very much to see your Sprite2D project.
-
Re: [VB6] - animated gif function errors:(
I see what you mean. Your picturebox should be long but it appears to be the size of a single ball. I will see what I can do to figure out what is going on here.
-
Re: [VB6] - animated gif function errors:(
I see what you mean. Your picturebox should be long but it appears to be the size of a single ball. I will see what I can do to figure out what is going on here.
-
Re: [VB6] - animated gif function errors:(
OK, I believe if you add the following code (red) to your project it will correct the ball.gif problem or any other gif that does the same thing.
Code:
Public Function LoadGifFile(strFileName As String, aimg As Variant) As Long
'
'
'
Do
'
' load an image\picture control if the index is more than 0(zero)
'
If I > 0 Then
Load aimg(I)
End If
If I = 0 Then
aimg(I).Width = LSD.GifWidth + 4
aimg(I).Height = LSD.GifHeight + 4
aimg(I).AutoSize = False
Else
aimg(I).AutoSize = True
End If
'
' Now change the backcolor and load the image
'
aimg(I).Picture = LoadPicture(App.Path & "\GifPicture(" & I & ").gif")
If GCE(I + 1).TransparentFlag <> 0 Then
aimg(I).BackColor = GCE(I + 1).TransparentFlag '<-- TransparentFlag is not a transparent color
Else
aimg(I).BackColor = GetPixel(aimg(I).hdc, 0, 0) '<-- Why don't you use the real background color?
End If
If aimg(I).BackColor = 1 And GCE(I + 1).Disposal = 2 Then aimg(I).BackColor = vbWhite
aimg(I).Picture = LoadPicture(App.Path & "\GifPicture(" & I & ").gif")
'
'
'
End Function
-
Re: [VB6] - animated gif function errors:(
Quote:
Originally Posted by
jmsrickland
OK, I believe if you add the following code (red) to your project it will correct the ball.gif problem or any other gif that does the same thing.
Code:
Public Function LoadGifFile(strFileName As String, aimg As Variant) As Long
'
'
'
Do
'
' load an image\picture control if the index is more than 0(zero)
'
If I > 0 Then
Load aimg(I)
End If
If I = 0 Then
aimg(I).Width = LSD.GifWidth + 4
aimg(I).Height = LSD.GifHeight + 4
aimg(I).AutoSize = False
Else
aimg(I).AutoSize = True
End If
'
' Now change the backcolor and load the image
'
aimg(I).Picture = LoadPicture(App.Path & "\GifPicture(" & I & ").gif")
If GCE(I + 1).TransparentFlag <> 0 Then
aimg(I).BackColor = GCE(I + 1).TransparentFlag '<-- TransparentFlag is not a transparent color
Else
aimg(I).BackColor = GetPixel(aimg(I).hdc, 0, 0) '<-- Why don't you use the real background color?
End If
If aimg(I).BackColor = 1 And GCE(I + 1).Disposal = 2 Then aimg(I).BackColor = vbWhite
aimg(I).Picture = LoadPicture(App.Path & "\GifPicture(" & I & ").gif")
'
'
'
End Function
yes.. thanks... now i must do the same on my Sprite control.
let me ask 1 thing... when you need change a control, normaly, you use the screen properties?
-
Re: [VB6] - animated gif function errors:(
hehehe
now works fine
thanks
Code:
UserControl.Width = GifWidth * Screen.TwipsPerPixelX + IFF(UserControl.BorderStyle = 1, 4, 0) * Screen.TwipsPerPixelX
UserControl.Height = GifHeight * Screen.TwipsPerPixelY + IFF(UserControl.BorderStyle = 1, 4, 0) * Screen.TwipsPerPixelY
and from anigif code for show static gif images isn't correct:
Code:
If lFrameCount = 0 Then
aimg(0).Picture = LoadPicture(App.Path & "\GifPicture(0).gif")
aimg(0).BackColor = GetPixel(aimg(0).hDC, 0, 0)
LoadGifFile = 1
Kill App.Path & "\GifPicture(0).gif"
Exit Function
End If
you did with '1', but gives me a size problem, then i change it to '0' and works fine;)