= 64 to the stream. * * @rvalue returns headerstring * *****************************************************************************/ function WriteLongHeader($iTagId, $iLen){ return WriteWord(($iTagId << 6) + 0x3f) . WriteDWord($iLen); } /***************************************************************************** * * @class DBL * * reads a DBL file and returns its content as object * * @rvalue returns new DBL object * *****************************************************************************/ class DBL { var $data; var $datalen; var $width; var $height; var $type; var $filename; var $filesize; function DBL($filename){ $this->filename = $filename; $this->filesize = filesize($filename); $this->datalen = $this->filesize - 8; $filehandle = fopen($filename, "r"); $skip = fread($filehandle, 8); //check the format (next time :)) $this->data = fread($filehandle, $this->datalen); fclose($filehandle); $this->type = Ord($this->data[0]); $this->width = (Ord($this->data[2]) << 8) + Ord($this->data[1]); $this->height = (Ord($this->data[4]) << 8) + Ord($this->data[3]); } } /***************************************************************************** * * Prepare output * *****************************************************************************/ $img = new DBL($image . ".dbl"); $width = $img->width; $height = $img->height; initMinBits($width, $height); // 2nd footer $footer2 = WriteWord( 0x02 ); //characterId $footer2 .= WriteRect( getMinBits() + 1, 0, $width * SCoord1, 0, $height * SCoord1 ); // rect //ShapeWithStyle $footer2 .= WriteByte( 0x01 ); // FillStyleCount (1 style) $footer2 .= WriteByte( 0x41 ); // clipped bitmap fill $footer2 .= WriteWord( 1 ); // bitmap-id $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( 0, 1 ); // New styles flag $footer2 .= WriteBits( 0, 1 ); // Line style change flag $footer2 .= WriteBits( 1, 1 ); // Fill style 1 change flag $footer2 .= WriteBits( 0, 1 ); // Fill style 0 change flag $footer2 .= WriteBits( 1, 1 ); // Move to flag $footer2 .= WriteBits( getMinBits() + 1, 5 ); $footer2 .= WriteBits( $width * SCoord1, getMinBits() + 1 ); $footer2 .= WriteBits( $height * SCoord1, getMinBits() + 1 ); $footer2 .= WriteBits( 1, 1 ); // Fill 1 Style = 1 (this is our bitmap-style) $footer2 .= WriteLine( 0, -$width * SCoord1 ); $footer2 .= WriteLine( 1, -$height * SCoord1 ); $footer2 .= WriteLine( 0, $width * SCoord1 ); $footer2 .= WriteLine( 1, $height * SCoord1 ); $footer2 .= WriteBits( 0, 1 ); // Non-edge record flag $footer2 .= WriteBits( 0, 5 ); // End of shape 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 .= WriteBits(0, 1); //has name $footer3 .= WriteBits(0, 1); //has ratio $footer3 .= WriteBits(0, 1); //has color transform $footer3 .= WriteBits(1, 1); //has matrix $footer3 .= WriteBits(1, 1); //has character $footer3 .= WriteBits(0, 1); //move $footer3 .= WriteWord( 0x01 ); // depth = 1 $footer3 .= WriteWord( 0x02 ); // character-id $footer3 .= WriteByte( 0x00 ); // transformation matrix $footer3 .= WriteWord( 0x40 ); // eof marker ? $footer3 .= WriteWord( 0x00 ); // calculate entire file-size $filesize = 23 + $img->datalen + 2 + strlen( $footer1 ) + strlen( $footer2 ) + strlen( $footer3 ) + strlen( WriteRect( getMinBits() + 1, 0, SCoord1*$width, 0, SCoord1*$height )); /***************************************************************************** * * Actual output * *****************************************************************************/ header( "Content-type: application/x-shockwave-flash" ); // here comes swf //echo($img->width . " : " . $img->height . " : " . $filesize); //exit; echo "FWS"; // reversed SWF signature (little endian/big endian issue) echo WriteByte( 3 ); // file version, flash 3 is all we need echo WriteDWord( $filesize ); // length of entire file in bytes echo WriteRect( getMinBits() + 1, 0, SCoord1*$width, 0, SCoord1*$height ); // frame size in TWIPS echo WriteByte( 0 ); // this one is ignored! echo WriteByte( 12 ); // frame delay in 8.8 fixed number of frames per second echo WriteWord( 1 ); // total number of frames in movie echo WriteShortHeader( 9, 3 ); // setBackgroundColor echo WriteByte( 0xff ); // red echo WriteByte( 0xff ); // green echo WriteByte( 0xff ); // blue echo WriteLongHeader(36, $img->datalen + 2); //DefineBitsLosless2 echo WriteWord( 1 ); // character-id echo $img->data; // raw image data including bitmapFormat, width and heigth // as produced by png2dbl starting at byte 8 echo $footer1; echo $footer2; echo $footer3; /************************************ EOF ************************************/ ?>