Example #1
0
File: Tag.php Project: yoya/IO_SWF
 function getPNGData()
 {
     $tag_code = $this->code;
     if ($tag_code != 20 && $tag_code != 36) {
         // DefineBitsLossless2
         return false;
     }
     if (!$this->parseTagContent()) {
         return false;
     }
     $cid = $this->tag->_CharacterID;
     $format = $this->tag->_BitmapFormat;
     $width = $this->tag->_BitmapWidth;
     $height = $this->tag->_BitmapHeight;
     $lossless_bitmap_data = gzuncompress($this->tag->_ZlibBitmapData);
     if ($format == 3) {
         $palette_num = $this->tag->_BitmapColorTableSize;
         if ($tag_code == 20) {
             // DefineBisLossless
             $palette_bytesize = 3 * $palette_num;
         } else {
             $palette_bytesize = 4 * $palette_num;
         }
         $palette_data = substr($lossless_bitmap_data, 0, $palette_bytesize);
         $lossless_bitmap_data = substr($lossless_bitmap_data, $palette_bytesize);
     } else {
         $palette_num = 0;
         $palette_data = null;
     }
     $png_data = IO_SWF_Lossless::Lossless2PNG($tag_code, $format, $width, $height, $palette_num, $palette_data, $lossless_bitmap_data);
     return $png_data;
 }
Example #2
0
            $lossless_bitmap_data = gzuncompress($tag->tag->_ZlibBitmapData);
            if ($format == 3) {
                $palette_num = $tag->tag->_BitmapColorTableSize;
                if ($tag_code == 20) {
                    // DefineBisLossless
                    $palette_bytesize = 3 * $palette_num;
                } else {
                    $palette_bytesize = 4 * $palette_num;
                }
                $palette_data = substr($lossless_bitmap_data, 0, $palette_bytesize);
                $lossless_bitmap_data = substr($lossless_bitmap_data, $palette_bytesize);
            } else {
                $palette_num = 0;
                $palette_data = null;
            }
            $png_data = IO_SWF_Lossless::Lossless2PNG($tag_code, $format, $width, $height, $palette_num, $palette_data, $lossless_bitmap_data);
            $jpeg_tag = new IO_SWF_Tag_Jpeg();
            $jpeg_tag->code = 21;
            // DefineBitsJPEG2
            $jpeg_tag->_CharacterID = $cid;
            $jpeg_tag->_JPEGData = $png_data;
            // SWF8 spec
            $tag->code = 21;
            // DefineBitsJPEG2
            $tag->tag = $jpeg_tag;
            $tag->content = null;
        }
    }
}
echo $swf->build();
exit(0);