Reverse Animated GIF: 25 Projects in 25 Days

Posted on 2015-10-22 Greg

Open Gif File Save Reversed Gif Ping Pong Option

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD's depth of features and ease of use. Today's project comes from Aaron.

What it Does

This C# WinForms project will load a multi-page image and reverse the pages to create a reverse-playback GIF using LEADTOOLS Version 19.

Features Used

Development Progress Journal

Hello, my name is Aaron I am going to write a C# WinForms application that will load in a multi-page file (GIF, TIFF, Word, PDF, etc.), reverse the page order, and save the file as a GIF to play the image backwards. The application will also have the ability to "Ping Pong" which is to infinitely play the GIF image back and forth.

I will start with creating the main user interface for the application. I will use the LEADTOOLS RasterPictureBox control to easily allow me to play the animation.

Documentation: RasterPictureBox

I have completed created the main user interface. This took me about 30 minutes to complete. I will now begin implementing loading the GIF image into the RasterPictureBox control and starting the animation.

Documentation: PlayAnimation

I have now completed implementing the loading and playing of the GIF image. I have never used the RasterPictureBox control before so this took some time to research exactly how the control works. This took me about 45 minutes.

I will now begin implementing the reversing of the GIF image itself. To accomplish this I will use the RasterCodecs.Load method to load the pages of the image one-by-one in reverse. I will also be using the CombineCommand to combine the frames to create a "flattened" image for each frame using the GIF specification.

Documentation: CombineCommand

Then I will use the RasterImage.AddPage method to add the combined images to a new RasterImage object.

Documentation: RasterCodecs.Load
Documentation: RasterImage.AddPage

I have now completed implementing the reversal of the GIF image. This took me about 4 hours to complete. I will now begin to implement the "Ping Pong" feature of the application. To accomplish this task I will use the FrameChanged event for the RasterPictureBox control.

Documentation: OnFrameChanged

I have now completed implementing the "Ping Pong" feature of the application. Including fixing a few bugs that I found. This took me about an hour and a half to complete.

My application is nearing completion. I will now begin bug testing and adding clear comments into my code for easier reading.

I have now finished fixing some bugs that I found while bug testing and commenting my code for easier reading. This took me about an hour to complete. My application is now ready to deploy.

It took me a total of 7 hours and forty five minutes to complete my application. Without LEADTOOLS this would have taken weeks or even months to complete.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

LEADTOOLS Blog

LEADTOOLS Powered by Apryse,the Market Leading PDF SDK,All Rights Reserved