SWFBitmap

(PHP 4 >= 4.0.5)

SWFBitmap -- Loads Bitmap object

Description

SWFBitmap swfbitmap ( mixed file [, mixed alphafile] )

警示

本函數是實驗性的。本函數的行為,內含函數名稱以及其它任何關於本函數的文件可能會在沒有知會的情況下隨 PHP 以後的發佈而改變。使用本函數風險自擔。

swfbitmap() creates a new SWFBitmap object from the Jpeg or DBL file in file. alphafile is a MSK file to be used as an alpha mask for a Jpeg image. Both parameters can be fopen() resources or binary strings.

注: We can only deal with baseline (frame 0) jpegs, no baseline optimized or progressive scan jpegs!

SWFBitmap has the following methods : swfbitmap->getwidth() and swfbitmap->getheight().

You can't import png images directly, though- have to use the png2dbl utility to make a dbl ("define bits lossless") file from the png. The reason for this is that I don't want a dependency on the png library in ming- autoconf should solve this, but that's not set up yet.

例子 1. Import PNG files

<?php
  $s 
= new SWFShape();
  
$f $s->addFill(new SWFBitmap(file_get_contents("png.dbl")));
  
$s->setRightFill($f);

  
$s->drawLine(320);
  
$s->drawLine(032);
  
$s->drawLine(-320);
  
$s->drawLine(0, -32);

  
$m = new SWFMovie();
  
$m->setDimension(3232);
  
$m->add($s);

  
header('Content-type: application/x-shockwave-flash');
  
$m->output();
?>

And you can put an alpha mask on a jpeg fill.

例子 2. swfbitmap() example

<?php

  $s 
= new SWFShape();

  
// .msk file generated with "gif2mask" utility
  
$f $s->addFill(new SWFBitmap(file_get_contents("alphafill.jpg"), file_get_contents("alphafill.msk")));
  
$s->setRightFill($f);

  
$s->drawLine(6400);
  
$s->drawLine(0480);
  
$s->drawLine(-6400);
  
$s->drawLine(0, -480);

  
$c = new SWFShape();
  
$c->setRightFill($c->addFill(0x990x990x99));
  
$c->drawLine(400);
  
$c->drawLine(040);
  
$c->drawLine(-400);
  
$c->drawLine(0, -40);

  
$m = new SWFMovie();
  
$m->setDimension(640480);
  
$m->setBackground(0xcc0xcc0xcc);

  
// draw checkerboard background
  
for ($y=0$y<480$y+=40) {
    for (
$x=0$x<640$x+=80) {
      
$i $m->add($c);
      
$i->moveTo($x$y);
    }

    
$y+=40;

    for (
$x=40$x<640$x+=80) {
      
$i $m->add($c);
      
$i->moveTo($x$y);
    }
  }

  
$m->add($s);

  
header('Content-type: application/x-shockwave-flash');
  
$m->output();
?>