Transform SWF分析、操作和生成 Flash 文件
Transform SWF 提供一套完整的,面向?qū)ο蟮?API 來分析、操作和生成 Flash 文件。
Transform SWF 是一個簡單易用的用戶庫,用來讀寫 Flash 的swf 和 Flash 視頻文件。它包含對應(yīng)每種tag和數(shù)據(jù)結(jié)構(gòu)的類。提供 C 語言和 Java 語言兩種版本。
Java 的示例代碼:
import java.awt.Font;
import java.io.IOException;
import com.flagstone.transform.*;
import com.flagstone.transform.util.*;
int width = 6000;
int height = 1000;
int border = 400;
int fontSize = 240;
try {
FSMovie movie = new FSMovie();
Font font = new Font("Arial", Font.PLAIN, 1);
String txt = "The quick, brown, fox jumped over the lazy dog.";
char[] characters = txt.toCharArray();
java.util.Arrays.sort(characters);
FSTextConstructor constructor = new FSTextConstructor(
movie.newIdentifier(), font);
constructor.willDisplay(characters);
FSDefineFont2 definition = constructor.defineFont();
FSDefineText2 text = constructor.defineText( movie.newIdentifier(), txt, fontSize, new FSColor(0,0,0));
movie.setFrameSize(new FSBounds(-border, -border, width, height));
movie.setFrameRate(1.0f);
movie.add(new FSSetBackgroundColor(FSColorTable.lightblue()));
movie.add(definition);
movie.add(text);
movie.add(new FSPlaceObject2(text.getIdentifier(), 1, 0 , 0));
movie.add(new FSShowFrame());
movie.encodeToFile("example.swf");
}
catch (IOException e) {
System.err.println("Cannot write to file");
}
