示例#1
0
 /**
  * ファイルのロード
  *
  * <pre>
  * $fileにはローカルファイルのパスまたはリモートファイルのURLを指定します。
  * リモートファイルの読み込みにはphp.iniでallow_url_fopen =Onの設定が必要です。
  * </pre>
  *
  * @param string $file ファイル名
  *
  * @return void
  */
 public function load($file)
 {
     //拡張子はpngチェック
     $this->file = $file;
     $tmpFile = $this->loadRemoteFile($file);
     $this->getImageInfo();
     $this->_log->log('$tmpFile', $tmpFile);
     BEAR_Img::$deleteFiles[] = $tmpFile;
     $this->surface = cairo_image_surface_create_from_png($tmpFile);
     if (!is_resource($this->surface)) {
         $fileSize = file_exists($file) ? filesize($file) : 'none';
         $this->_thisError("load", "cairo_image_surface_create_from_png filse_size=[{$fileSize}] file=[{$file}] ");
     }
     $this->image = cairo_create($this->surface);
     if (!is_resource($this->image)) {
         $this->_thisError('load', 'cairo_create');
     }
     cairo_paint_with_alpha($this->image, 0);
     $this->_srcWidth = cairo_image_surface_get_width($this->surface);
     $this->_srcHeight = cairo_image_surface_get_height($this->surface);
 }
示例#2
0
 /**
  * Mirrors the image horizontally.
  * Uses an affine transformation matrix to mirror the image.
  *
  * 123 -> 321
  *
  * @return void
  */
 function mirror()
 {
     $outputSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, $this->img_x, $this->img_y);
     $outputContext = cairo_create($outputSurface);
     //                            xx, yx, xy, yy, x0, y0
     $matrix = cairo_matrix_create(-1, 0, 0, 1, $this->img_x, 0);
     cairo_set_matrix($outputContext, $matrix);
     cairo_set_source_surface($outputContext, $this->surface, 0, 0);
     cairo_paint($outputContext);
     cairo_destroy($outputContext);
     cairo_surface_destroy($this->surface);
     $this->surface = $outputSurface;
 }
示例#3
0
 /**
  * Initilize cairo surface
  *
  * Initilize cairo surface from values provided in the options object, if
  * is has not been already initlized.
  * 
  * @return void
  */
 protected function initiliazeSurface()
 {
     // Immediatly exit, if surface already exists
     if ($this->surface !== null) {
         return;
     }
     $this->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, $this->options->width, $this->options->height);
     $this->context = cairo_create($this->surface);
     cairo_set_line_width($this->context, 1);
 }