static void Main(string[] args)
{
//Picture to transform
string imgPath = "img.jpg";
//string imgPath = "Untitled-1.bmp";
//File name of the result swf file
string path = "test.swf";
//Load the picture to a GDI image
Image img = Image.FromFile(imgPath);
int posX = 0;
int posY = 0;
int imgWidth = img.Width + 100;
int imgHeight = img.Height + 100;
//Create a new Swf instance
Swf swf = new Swf();
swf.Size = new Rect(0, 0, (posX + imgWidth) * 20, (posY + imgHeight) * 20);
swf.Version = 5;
//Set the background color tag
swf.Tags.Add(new SetBackgroundColorTag(255, 255, 255));
//Set the jpeg tag
ushort jpegId = swf.GetNewDefineId();
//Load the jped from an image
swf.Tags.Add(DefineBitsJpeg2Tag.FromImage(jpegId, img));
//Define the picture's shape tag
DefineShapeTag shapeTag = new DefineShapeTag();
shapeTag.CharacterId = swf.GetNewDefineId();
shapeTag.Rect = new Rect(posX * 20 - 1, posY * 20 - 1, (posX + imgWidth) * 20 - 1, (posY + imgHeight) * 20 - 1);
FillStyleCollection fillStyles = new FillStyleCollection();
fillStyles.Add(new BitmapFill(FillStyleType.ClippedBitmapFill, ushort.MaxValue, new Matrix(0, 0, 20, 20)));
fillStyles.Add(new BitmapFill(FillStyleType.ClippedBitmapFill, jpegId, new Matrix(posX * 20 - 1, posY * 20 - 1, (20.0 * imgWidth) / img.Width, (20.0 * imgHeight) / img.Height)));
LineStyleCollection lineStyles = new LineStyleCollection();
ShapeRecordCollection shapes = new ShapeRecordCollection();
shapes.Add(new StyleChangeRecord(posX * 20 - 1, posY * 20 - 1, 2));
shapes.Add(new StraightEdgeRecord(imgWidth * 20, 0));
shapes.Add(new StraightEdgeRecord(0, imgHeight * 20));
shapes.Add(new StraightEdgeRecord(-imgWidth * 20, 0));
shapes.Add(new StraightEdgeRecord(0, -imgHeight * 20));
shapes.Add(new EndShapeRecord());
shapeTag.ShapeWithStyle = new ShapeWithStyle(fillStyles, lineStyles, shapes);
swf.Tags.Add(shapeTag);
//Place the picture
swf.Tags.Add(new PlaceObject2Tag(shapeTag.CharacterId, 1, 0, 0));
//Add a frame
swf.Tags.Add(new ShowFrameTag());
swf.Tags.Add(new EndTag());
//Write the swf to a file
SwfWriter writer = new SwfWriter(path);
writer.Write(swf);
writer.Close();
img.Dispose();
}