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)
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?
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.
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
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.
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.
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)
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.
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.
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.
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.
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.
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?
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
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.
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
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?
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.
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.
I'll upload my project later so you can see how and what mine does.
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.
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.
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.
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)
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.
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.
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.
Last edited by jmsrickland; Sep 20th, 2012 at 09:57 AM.
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.
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
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.
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.
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?
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.
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.
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
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.
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.
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?
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.
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
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?
Last edited by jmsrickland; Sep 20th, 2012 at 03:34 PM.
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.
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
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.
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.
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
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.
Last edited by jmsrickland; Sep 21st, 2012 at 11:28 AM.
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.
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.
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.
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.
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.
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
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.
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?