This documentation is for the old version. Go to the latest Graphics Mill docs

SWF File Format

SWF format was developed by Macromedia Inc. It stands for "Shockwave File Format". The SWF file formats are ideal for vector graphics that may have audio and may even be interactive. To open the SWF file the web browser may use the flash plug-in. However Graphics Mill for .NET allows only import raster blocks to SWF. It is convenient if you need to pass images to applications based on the Macromedia Flash.

Graphics Mill for .NET allows saving several frames into one SWF file. It enables you to create animated Flash movies (which will have quite large size though).

Format Name

SWF

MIME Type

application/x-shockwave-flash

File Extensions

*.swf

Supported Pixel Formats

Description Read Write
1 bit palette-based No Yes
4 bit palette-based No Yes
8 bit palette-based No Yes
24 bit RGB No Yes
32 bit RGB No Yes
32 bit RGB with the alpha channel No Yes

Encoder Options

Name Default Value Comments
SwfEncoderOptions.BackgroundColor
SwfWriter.BackgroundColor
white Background color for the SWF movie.
SwfEncoderOptions.Compression
SwfFrame.Compression
CompressionType.Zip

CompressionType value that specifies necessary SWF compression type.

SwfEncoderOptions.Delay
SwfFrame.Delay
0

Number of hundredths (1/100) of a second to wait after rendering the frame.

SwfEncoderOptions.DisposalMethod
SwfFrame.DisposalMethod
DisposalMethod.None Codecs.DisposalMethod value that specifies a disposal method for the frame.
SwfEncoderOptions.Height
SwfWriter.Height
0 SWF movie height (in pixels). If 0, the height of the first frame will be used.
SwfEncoderOptions.Quality
SwfFrame.Quality
75 Value in range [0, 100] specifying JPEG quality
SwfEncoderOptions.Width
SwfWriter.Width
0 SWF movie width (in pixels). If 0, the width of the first frame will be used.

Examples

Saving an Image into SWF File Format

The code example below converts JPEG file into the SWF image frame.

Visual Basic
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg")

bitmap.Save("C:\Mountain.swf", _
    New Aurigma.GraphicsMill.Codecs.SwfEncoderOptions(30))

bitmap.Dispose()
C#
using (Aurigma.GraphicsMill.Bitmap bitmap = 
            new Aurigma.GraphicsMill.Bitmap(@"C:\Mountain.jpg"))
{
    bitmap.Save(@"C:\Mountain.swf", 
        new Aurigma.GraphicsMill.Codecs.SwfEncoderOptions(30));
}

Creating Animated SWF Movie

To create an animated SWF movie we need to use the SwfWriter class. The movie is created from the several JPEG files.

Visual Basic
Dim dir As String = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\"
Dim images As String() = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"}

Dim bitmap As New Aurigma.GraphicsMill.Bitmap

Dim writer As New Aurigma.GraphicsMill.Codecs.SwfWriter("C:\Mountain.swf")

For Each image As String In images
    bitmap.Load(dir & image)

    Dim frame As New Aurigma.GraphicsMill.Codecs.SwfFrame
    frame.Compression = Aurigma.GraphicsMill.Codecs.CompressionType.Jpeg
    frame.Quality = 30
    frame.Delay = 100
    frame.SetBitmap(bitmap)

    writer.AddFrame(frame)

    frame.Dispose()
Next

bitmap.Dispose()

writer.Dispose()
C#
string dir = @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\";
string[] images = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"};

using (Aurigma.GraphicsMill.Bitmap bitmap = 
           new Aurigma.GraphicsMill.Bitmap())
{
    using (Aurigma.GraphicsMill.Codecs.SwfWriter writer = 
               new Aurigma.GraphicsMill.Codecs.SwfWriter(@"C:\Mountain.swf"))
    {
        foreach (string image in images)
        {
            bitmap.Load(dir + image);

            using (Aurigma.GraphicsMill.Codecs.SwfFrame frame = 
                       new Aurigma.GraphicsMill.Codecs.SwfFrame())
            {
                frame.Compression = Aurigma.GraphicsMill.Codecs.CompressionType.Jpeg;
                frame.Quality = 30;
                frame.Delay = 100;
                frame.SetBitmap(bitmap);

                writer.AddFrame(frame);
            }
        }
    }
}