Click here to Skip to main content
6,822,123 members and growing! (17,691 online)
Email Password   helpLost your password?
Multimedia » General Graphics » General     Intermediate License: The Code Project Open License (CPOL)

Reader of SWF Header File in Pure C#

By zebulon75018

Reader of SWF header file in pure C# with a single class
C#2.0, Windows, .NET1.0, .NET2.0VS2005, Dev
Revision:2 (See All)
Posted:10 Aug 2007
Views:33,507
Bookmarked:21 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
7 votes for this article.
Popularity: 2.82 Rating: 3.33 out of 5
4 votes, 57.1%
1

2

3

4
3 votes, 42.9%
5
Screenshot - SwfHeaderReader.jpg

Introduction

It's my first article on The Code Project. Please excuse my English.

This article describes how to read the header of the flash file. (This file has the extension .swf )

The Format Header SWF is described in this link.

You can also read a good article on SWF which describes the library SwfDotNet.

I wrote this article for myself and for people who want small source code.
To read this header, I translate PHP code to C#. The original source code in PHP is at this address.

This is the code of a class which can provide information of the Swf Flash:

  • FrameRate
  • FrameCount
  • Width
  • Height
  • Version

Warning, this class doesn't work with the compressed Flash File.

Using the Code

The name of the class is FlashHeaderReader and takes for the constructor a parameter, the filename of the flash file.

It calls these methods:

  • ReadSignature();
  • mVersion=GetNextByte();
  • ReadFileLength();
  • ReadFrameSize();
  • ReadFrameRate();
  • ReadFrameCount();

Later, you can access the properties of the swf file :

FlashHeaderReader swfreader = new FlashHeaderReader(openFileDialog1.FileName);

listBox1.Items.Clear();
listBox1.Items.Add("Frames : " + swfreader.FrameCount);
listBox1.Items.Add("Width : " + swfreader.Width );
listBox1.Items.Add("Height : " + swfreader.Height);

Points of Interest

The method ReadFrameSize is complex because the swf format also compresses the header and information has a different size.

History

  • 10th August, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

zebulon75018


Member

Occupation: Software Developer (Senior)
Company: http://www.cmb-soft.com/
Location: France France

Other popular General Graphics articles:

  • A flexible charting library for .NET
    Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
  • CxImage
    CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
  • 3D Pie Chart
    A class library for drawing 3D pie charts.
  • Barcode Image Generation Library
    This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data.
  • ImageStone
    An article on a library for image manipulation.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 16 of 16 (Total in Forum: 16) (Refresh)FirstPrevNext
GeneralMy vote of 1 Pinmembergunjan9um2:36 13 Jul '09  
GeneralMy vote of 1 Pinmembercrayzeecoder22:45 25 Jun '09  
GeneralRead FLV and Real Media file meta data PinmemberVishal Dedaniya11:42 22 Dec '08  
GeneralRe: Read FLV and Real Media file meta data PinmemberMember 43871434:16 18 Feb '09  
GeneralCan we read Compressed SWF files PinmemberShikhardadhich21:31 17 Sep '08  
GeneralRe: Can we read Compressed SWF files Pinmemberzebulon7501810:09 1 Dec '08  
GeneralImproving read efficiency Pinmemberdssdss19:18 11 Oct '07  
GeneralRe: Improving read efficiency Pinmemberzebulon750183:34 12 Oct '07  
GeneralVector info? PinmemberX3m10:34 10 Oct '07  
GeneralRe: Vector info? Pinmemberzebulon750183:39 12 Oct '07  
GeneralRe: Vector info? PinmemberX3m23:49 14 Oct '07  
QuestionDoes this work with FLV files?? Pinmemberdclark14:01 12 Aug '07  
AnswerRe: Does this work with FLV files?? PinmemberSMStallings23:55 14 Aug '07  
GeneralRe: Does this work with FLV files?? Pinmembervidalc0:30 20 Aug '07  
AnswerRe: Does this work with FLV files?? I guess No :( Pinmembervidalc0:27 20 Aug '07  
GeneralRe: Does this work with FLV files?? Pinmemberzebulon750184:35 6 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 10 Aug 2007
Editor: Deeksha Shenoy
Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2010
Web22 | Advertise on the Code Project