we can create a swf movie in at least 3 way
1) by adobe flash, created from *.fla
2) by flex create from *.mxml
3) and we can create *.swf file by a backend controller, say, php or perl.
We now focus on 3). All we want is the open source swf library, named "Ming". It's a api to create swf file.
Here is what I think it can be used for:
1) protect your private image, you want to hide the url of your image and don't want others to say it as a local image file:
$path = "my_movie_dir"; //relative path to the jpg/png or bmp files
$frame_rate=30; //frame rate of the flash movie
$quality=50; //image quality during conversion (only valid if not jpeg)
$skip_rate=5; //how many frames to skip
set_time_limit("600"); //this could take some time
$converter=new images_to_swf($path,$frame_rate,$skip_rate);
//$converter->convert_images(70); //Use this if using non jpeg files or decreasing the quality
$converter->make_movie();//Make the movie
//Do two things with it
$converter->save_movie("my_movie_dir/my_movie.swf");
$converter->output_movie();
class images_to_swf {
var $path; //path to the image files
var $skip_rate;
var $movie;
var $images=array();
function images_to_swf($path,$frame_rate=30,$skip_rate=5) {
$this->path=$path;
$this->skip_rate=$skip_rate;
$this->movie=new swfmovie ();
$this->movie->setrate ($frame_rate);
}
function convert_images($quality=80,$delete_old_files=1) {
$main = opendir($this->path);
rewinddir($main);
//first convert to jpeg (if we have to)
//also change the quality
while($filename = readdir($main)) {
//only use valid file types
if (ereg("(png|bmp|jpg|jpeg)\$",$filename)) {
$file_path=$this->path."/".$filename;
if (ereg("png\$",$filename)) $temp_img=imagecreatefrompng ($file_path);
else if (ereg("bmp\$",$filename)) $temp_img=imagecreatefrompng ($file_path);
else if (ereg("(jpg|jpeg)\$",$filename)) $temp_img=imagecreatefromjpeg ($file_path);
if (ereg("(png|bmp)\$",$filename)) {
if ($delete_old_files) unlink($file_path);
$new_file_path=$file_path.".jpg";
}
else $new_file_path=$file_path;
ImageJPEG($temp_img,$new_file_path,$quality);
//echo "Converted $filename to $new_file_path at quality $quality<br />";
}
}
}
function make_movie() {
$main = opendir($this->path);
rewinddir($main);
//Get all valid jpegs
while($filename = readdir($main)) {
if (ereg("(jpg|jpeg)\$",$filename)) {
$file_path=$this->path."/".$filename;
$valid_paths[]=$file_path;
}
}
//Put jpegs in order
sort($valid_paths);
//then create the movie
for ($a=0; $a<count($valid_paths); $a=$a+$this->skip_rate) {
$fp = fopen($valid_paths[$a],"rb");
$this->images[$a] = fread($fp,999999);
fclose($fp);
$this->movie->add(new swfbitmap($this->images[$a]));
$this->movie->nextframe();
//echo "Added ".$valid_paths[$a]." to the movie<br />\n";
}
}
function save_movie($file_name) {
$this->movie->save($file_name);
}
function output_movie() {
header('Content-type: application/x-shockwave-flash');
$this->movie->output();
}
2) construct a complex flash componet according to your backend database
More sample can be reached at: http://www.gazbming.com/
分享到:
相关推荐
* How many ways are there to draw a line? * Let’s learn. How can we do it? 我们可以怎么做?We can do it with ... 我们可以通过…… 5. Think and answer: * How many ways are there to draw a line? *...
* How can we draw a line?:回答绘画方法 * How can we read fast?:回答快速阅读方法 * Can you sing and dance?:回答是否能够唱歌和跳舞 * How can we get up early?:回答早晨起床方法 知识点:本部分考查学生...
如果不可数名词前有计量单位,如 "a piece of","a glass of" 等,那么就可以用 "how many" 来提问。例如,"How many pieces of bread do you eat?"(你吃了多少片面包?) 此外,"how much" 还有一个额外的用法,...
【Lesson 9 How Many】是针对儿童或者初学者设计的一份英语学习材料,主要目标是教授和练习如何用英语询问和表达数量。这份文档包含了数数、填空和选择题等练习,旨在帮助学习者掌握"How many"这个句型的使用。 在...
Product Description The first book to use the unexpected discoveries of neuroscience to help us make the best decisions. Since Plato, philosophers ... And how can we make those decisions better?
How to Create a Database in Python using SQL Lite 3 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
【人教版九年级英语Unit 1 How can we become good learners知识点整理】 一、介词by的用法 1. 表示“通过,用(某种方式或手段)”,常接名词或动名词形式,回答how引导的问题。例如: - How does the boy ...
Unit 3 How Many单元测试题及答案2.doc
—— How many bananas do we need? 2. 我们需要三只香蕉。 —— We need three bananas. 3. 我们需要多少酸奶? —— How much yogurt do we need? 4. 我们需要一杯酸奶。 —— We need a cup of yogurt. 5. 我们...
1.14 How can I find a process' executable file? 1.14.1 So where do I put my configuration files then? 1.15 Why doesn't my process get SIGHUP when its parent dies? 1.16 How can I kill all ...
这篇内容是针对四年级学生的一堂英语课,主要学习如何用"How many"句型询问数量以及数字的拼写。在教学单元"Module 3 Unit 6 How many classrooms are there in your school?"中,孩子们将学习如何用英语询问并回答...
How to run a JAR file
这篇内容是关于新人教PEP版三年级下册英语教材中的第六单元 "How many" 的一套完整课件。这个单元主要教授学生如何询问和回答可数名词的数量,特别是使用"How many"这一疑问词。 首先,"Warm-up"部分复习了复数形式...
在小学英语语法中,"how many" 和 "how much" 是两个非常重要的概念,它们用于询问数量,但针对的对象不同。 1. **how many** 主要用来修饰**可数名词的复数形式**。它的基本句型是:"How many + 复数名词 + 一般...
扩展矩阵leetcode interview-algorithm leetCode 待解决 上楼梯问题 how many ways to decode this message @leetCode 91
这篇文档是针对小学四年级(4A Unit 3)学习的练习材料,主要涉及英语基础知识,包括词汇短语翻译、连词成句、填空以及纠正语法错误等环节,旨在帮助学生掌握“数量询问”(How many)的句型及与之相关的词汇。...
You'll get a complete picture of the many possible ways to package and deploy NW.js applications on Microsoft Windows, Mac OS X, and Linux. So, get ready to explore NW.js and build a real, and complex...
Charts I- How to create a chart.xlt
How to Create a Healthy Plate - English.srt