In this article we will see how to convert our JPEG images to .swf format. For this we are using a third party's DLL which will convert our images to a .swf movie. For viewing the movies you can download the swf player.
Background:
Actually the DLL to convert images to swf I found using a Google search. In this article I'm using DLL files as given below to do our work.
- log4net
- SwfDotNet
- SharpZipLib
Follow the steps given below to do our work.
Step 1:
Create a Windows Form application in C#. Add the reference to the DLLs that I have put in the bin folder of the attached source as well a "using" for this namespace in our using statements like:
using log4net;
using SwfDotNet.IO;
using SwfDotNet.IO.Tags;
using SwfDotNet.IO.Tags.Types;
Step 2:
Design the normal form for taking input filename and output path for our work with OpenFile Dialog and SaveFile Dialog.
Step 3:
In the click of the create button write the following code to convert the input file to .swf format and store it to the specified location.
try
{
if (File.Exists(inputfilename) == false)
{
MessageBox.Show("Can not open Image file" + inputfilename);
return;
}
//First load the picture as System.Drawing.Image
Image img = Image.FromFile(inputfilename);
int posX = 0;
int posY = 0;
int imgWidth = img.Width;
int imgHeight = img.Height;
//Create a new Swf instance
Swf swf = new Swf();
//Set size in inch unit (1 pixel = 20 inches)
swf.Size = new Rect(0, 0, (posX + imgWidth) * 20, (posY + imgHeight) * 20);
swf.Version = 7; //Version 7 (for compression, must be > 5)
swf.Header.Signature = "CWS"; //Set the signature to compress the swf
//Set the background color tag as white
swf.Tags.Add(new SetBackgroundColorTag(255, 255, 255));

prince rajPosted Jun 23, 2014, 9:02 AM
Hello Krishna, i want to create video file from 500-600 photo, you can say frame, how can i ?
harshal patilPosted Aug 9, 2013, 6:35 AM
Hi Krishna, Thanks for the code. I want to apply my click events of image to .swf image that I just have created using your code. Please help me in applying click event code of image to swf image