XverhelstX Well-Known Member Licensed User Longtime User Jul 15, 2012 #1 Hey! Create your own animated gif files with this library. The code is easy to use and to understand. The library files and sample are delivered in the attachments. RSAnimatedGifEncoder Properties: Delay As Sets the delay time between each frame, or changes it for subsequent frames (applies to last frame added). Dispose As Sets the GIF frame disposal code for the last added frame and any subsequent frames. Default is 0 if no transparent color has been set, otherwise 2. FrameRate As Sets frame rate in frames per second. Equivalent to <code>setDelay(1000/fps)</code>. Quality As Sets quality of color quantization (conversion of images to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors, but slow processing significantly. 10 is the default, and produces good color mapping at reasonable speeds. Values greater than 20 do not yield significant improvements in speed. Repeat As Sets the number of times the set of GIF frames should be played. Default is 1; 0 means play indefinitely. Must be invoked before the first image is added. Transparent As Sets the transparent color for the last added frame and any subsequent frames. Since all colors are subject to modification in the quantization process, the color in the final palette for each frame closest to the given color becomes the transparent color for that frame. May be set to null to indicate no transparent color. Methods: addFrame (im As Bitmap) As Boolean Adds next GIF frame. The frame is not written immediately, but is actually deferred until the next frame is received so that timing data can be inserted. Invoking <code>finish()</code> flushes all frames. If <code>setSize</code> was not invoked, the size of the first image is used for all subsequent frames. im: BufferedImage containing frame to write. Return type: @return:true if successful. finish As Boolean Flushes any pending data and closes output file. If writing to an OutputStream, the stream is not closed. setPosition (x As Int, y As Int) Sets the GIF frame position. The position is 0,0 by default. Useful for only updating a section of the image w: int frame width. h: int frame width. setSize (w As Int, h As Int) Sets the GIF frame size. The default size is the size of the first frame added if this method is not invoked. w: int frame width. h: int frame width. start (os As OutputStream) As Boolean Initiates GIF file creation on the given stream. The stream is not closed automatically. os: OutputStream on which GIF images are written. Return type: @return:false if initial write failed. Credits: As for the original version, code is free for any kind of usages, but you must refer to the Unisys LZW patent for restrictions on use of the associated LZWEncoder class. Click to expand... NOTE: My BitCloud library is not included. This is just used to write an bytearray to a file from the outputstream. There are some examples to write a bytearray to a file on the forums. Tomas Attachments GifEncoder.zip GifEncoder.zip 32.1 KB · Views: 1,491 Last edited: Jul 15, 2012
Hey! Create your own animated gif files with this library. The code is easy to use and to understand. The library files and sample are delivered in the attachments. RSAnimatedGifEncoder Properties: Delay As Sets the delay time between each frame, or changes it for subsequent frames (applies to last frame added). Dispose As Sets the GIF frame disposal code for the last added frame and any subsequent frames. Default is 0 if no transparent color has been set, otherwise 2. FrameRate As Sets frame rate in frames per second. Equivalent to <code>setDelay(1000/fps)</code>. Quality As Sets quality of color quantization (conversion of images to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors, but slow processing significantly. 10 is the default, and produces good color mapping at reasonable speeds. Values greater than 20 do not yield significant improvements in speed. Repeat As Sets the number of times the set of GIF frames should be played. Default is 1; 0 means play indefinitely. Must be invoked before the first image is added. Transparent As Sets the transparent color for the last added frame and any subsequent frames. Since all colors are subject to modification in the quantization process, the color in the final palette for each frame closest to the given color becomes the transparent color for that frame. May be set to null to indicate no transparent color. Methods: addFrame (im As Bitmap) As Boolean Adds next GIF frame. The frame is not written immediately, but is actually deferred until the next frame is received so that timing data can be inserted. Invoking <code>finish()</code> flushes all frames. If <code>setSize</code> was not invoked, the size of the first image is used for all subsequent frames. im: BufferedImage containing frame to write. Return type: @return:true if successful. finish As Boolean Flushes any pending data and closes output file. If writing to an OutputStream, the stream is not closed. setPosition (x As Int, y As Int) Sets the GIF frame position. The position is 0,0 by default. Useful for only updating a section of the image w: int frame width. h: int frame width. setSize (w As Int, h As Int) Sets the GIF frame size. The default size is the size of the first frame added if this method is not invoked. w: int frame width. h: int frame width. start (os As OutputStream) As Boolean Initiates GIF file creation on the given stream. The stream is not closed automatically. os: OutputStream on which GIF images are written. Return type: @return:false if initial write failed. Credits: As for the original version, code is free for any kind of usages, but you must refer to the Unisys LZW patent for restrictions on use of the associated LZWEncoder class. Click to expand... NOTE: My BitCloud library is not included. This is just used to write an bytearray to a file from the outputstream. There are some examples to write a bytearray to a file on the forums. Tomas
Highwinder Active Member Licensed User Longtime User Aug 22, 2012 #2 Source? Tomas, Thanks again for another library. What is the source that the animated GIF file is created from? Camera? Screen capture?
Source? Tomas, Thanks again for another library. What is the source that the animated GIF file is created from? Camera? Screen capture?
XverhelstX Well-Known Member Licensed User Longtime User Aug 22, 2012 #3 Highwinder said: Tomas, Thanks again for another library. What is the source that the animated GIF file is created from? Camera? Screen capture? Click to expand... What do you mean with "the source that the animated GIF file is created from?". The library encodes several bitmap images to a gif file. Tomas
Highwinder said: Tomas, Thanks again for another library. What is the source that the animated GIF file is created from? Camera? Screen capture? Click to expand... What do you mean with "the source that the animated GIF file is created from?". The library encodes several bitmap images to a gif file. Tomas
vb1992 Well-Known Member Licensed User Longtime User Aug 22, 2012 #4 It's from the photo's/images you supply to the library. You could take a few snap shots with the camera (in memory) to create these (motion) images and send it through this library... Sub Camera_PictureTaken (Data() As Byte) ' set the size of the camera to be small Dim in As InputStream in.InitializeFromBytesArray(Data) Dim bmp As Bitmap bmp.Initialize2(in) Gif89.addFrame (bmp) End Sub Click to expand... Last edited: Aug 22, 2012
It's from the photo's/images you supply to the library. You could take a few snap shots with the camera (in memory) to create these (motion) images and send it through this library... Sub Camera_PictureTaken (Data() As Byte) ' set the size of the camera to be small Dim in As InputStream in.InitializeFromBytesArray(Data) Dim bmp As Bitmap bmp.Initialize2(in) Gif89.addFrame (bmp) End Sub Click to expand...
M mcmanu Active Member Licensed User Longtime User Oct 4, 2012 #5 Hi is it possible to use an animation when Voice recognition is Listening? I tried it and the Animation stops when the voice recognition is listening. Is there a way to overcome this issue? Last edited: Oct 10, 2012
Hi is it possible to use an animation when Voice recognition is Listening? I tried it and the Animation stops when the voice recognition is listening. Is there a way to overcome this issue?
M malakie Member Licensed User Longtime User Dec 2, 2012 #6 New to this.. I am new to Android coding... I am trying to play and animated gif on my phone from Basic4Android. I downloaded your attached file. It shows up in the LIBS list on the right side of the screen.. How do I actually use it? I do not see any control or object to place on the design screen... any help?
New to this.. I am new to Android coding... I am trying to play and animated gif on my phone from Basic4Android. I downloaded your attached file. It shows up in the LIBS list on the right side of the screen.. How do I actually use it? I do not see any control or object to place on the design screen... any help?
T troarty New Member Licensed User Longtime User Jun 21, 2013 #7 I'd really like to be able to create animated gifs using basic4android...Can you point me to an example of writing they bytearray from the outputstream to a file? Tom
I'd really like to be able to create animated gifs using basic4android...Can you point me to an example of writing they bytearray from the outputstream to a file? Tom
S Sytek Active Member Licensed User Longtime User Jun 21, 2013 #8 malakie said: I am new to Android coding... I am trying to play and animated gif on my phone from Basic4Android. I downloaded your attached file. It shows up in the LIBS list on the right side of the screen.. How do I actually use it? I do not see any control or object to place on the design screen... any help? Click to expand... ..You can use it as follows E.G. Code: Copy Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim vvv As RSAnimatedGifEncoder End Sub ...Then you can call its properties vvv.start Please Read the Beginners Guide http://www.b4x.com/forum/basic4android-getting-started-tutorials/9578-beginners-guide.html#post53042
malakie said: I am new to Android coding... I am trying to play and animated gif on my phone from Basic4Android. I downloaded your attached file. It shows up in the LIBS list on the right side of the screen.. How do I actually use it? I do not see any control or object to place on the design screen... any help? Click to expand... ..You can use it as follows E.G. Code: Copy Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim vvv As RSAnimatedGifEncoder End Sub ...Then you can call its properties vvv.start Please Read the Beginners Guide http://www.b4x.com/forum/basic4android-getting-started-tutorials/9578-beginners-guide.html#post53042
T troarty New Member Licensed User Longtime User Jul 2, 2013 #9 Can anyone point me to an example of writing the bytearray from the outputstream to a file? I get confused because the bytearray is already on the outputstream and yet I need to read from it in order to write to an outputstream (the file) Tom
Can anyone point me to an example of writing the bytearray from the outputstream to a file? I get confused because the bytearray is already on the outputstream and yet I need to read from it in order to write to an outputstream (the file) Tom
Erel B4X founder Staff member Licensed User Longtime User Jul 3, 2013 #10 Code: Copy Dim out As OutputStream = File.OpenOutput(...) out.WriteBytes(...)
andymc Well-Known Member Licensed User Longtime User Jul 3, 2013 #11 Excellent work Erel, I already have an idea for an App which can use this.