先来看一下所需文件的清单:
1、dbl2swf.php:显示swf图像的文件,稍后给出源代码。
2、flashwriter.php:实际上它不是一个文件,而是由许多文件组成的功能模块,他的作用是处理文件格式。下载地址是:
http://www.bronsonbeta.com/downloads/flashwriter.zip
2、ming-winutils:它是由五个exe文件组成:其中我们所需的程序是png2dbl.exe 他的作用是把png文件转换为dbl文件格式。下载地址是:
http://www.opaque.net/ming/ming-winutils.zip
操作方法:
1、由于是在服务器端运行的程序,所以需要安装php+iis 或者 php+apache 这两种配置的方法你可以任选。网上也有数不清的教程,可以搜搜
。
2、假如有一张png的图片,名字是vv.png,把它拖动到png2dbl.exe,这时候会在相同的目录下产生一个名字相同的dbl文件,即vv.dbl,复制此
文件到虚拟目录下。
3、复制以下代码到php文件当中,保存该文件到相同的虚拟目录下名为:dbl2swf.php 。
4、复制flashwriter所有的文件到相同的虚拟目录下,注意保持flashwriter.php和dbl2swf.php在相同的目录。
5、通过本地的虚拟路径访问php2swf.php文件,注意后面所根参数:我的路径是:http://localhost/site/php2swf.php?image=vv;
php2swf.php:
|
<?php require( "flashwriter.php" ); // include flashwriter-functions v1.02
class DBL { $ this->type = Ord($ this->data[0]); $ img = new DBL($ image . ".dbl"); $ width = $ img->width; initMinBits($ width, $ height); // 2nd footer //ShapeWithStyle $ footer2 .= WriteMatrix( true, 20*Fixed1, 20*Fixed1, false, 0, 0, 0, 0 ); $ footer2 .= WriteByte( 0x00 ); // LineStyleCount (no line) $ footer2 .= WriteByte( 0x10 ); // number of fill/line index bits $ footer2 .= WriteBits( 0, 1 ); // Non-edge record flag $ footer2 .= WriteBits( getMinBits() + 1, 5 ); $ footer2 .= WriteBits( 1, 1 ); // Fill 1 Style = 1 (this is our bitmap-style) $ footer2 .= WriteLine( 0, -$ width * SCoord1 ); $ footer2 .= WriteBits( 0, 1 ); // Non-edge record flag $ footer2 .= FlushBits(); // flush bits to keep byte aligned $ footer1 = WriteLongHeader(2, strlen( $ footer2 )); //DefineShape // 3rd footer $ footer3 = WriteShortHeader(26,6); //placeObject2 $ footer3 .= WriteBits(0, 2); //reserved bits $ footer3 .= WriteWord( 0x01 ); // depth = 1 $ footer3 .= WriteWord( 0x02 ); // character-id $ footer3 .= WriteByte( 0x00 ); // transformation matrix $ footer3 .= WriteWord( 0x40 ); // eof marker ? // calculate entire file-size
/***************************************************************************** header( "Content-type: application/x-shockwave-flash" ); // here comes swf echo "FWS"; // reversed SWF signature (little endian/big endian issue) echo WriteRect( getMinBits() + 1, echo WriteLongHeader(36, $ img->datalen + 2); //DefineBitsLosless2 echo $ img->data; // raw image data including bitmapFormat, width and heigth |
回复Comments
作者:
{commentrecontent}