/** * Save $im into the file (many format available) * * @param int $image_style * @param int $quality */ public function finish($image_style = self::IMG_FORMAT_PNG, $quality = 100) { $drawer = null; $im = $this->im; if ($this->rotateDegree > 0.0) { $im = imagerotate($this->im, $this->rotateDegree, $this->color->allocate($this->im)); } if ($image_style === self::IMG_FORMAT_PNG) { $drawer = new BCGDrawPNG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); } elseif ($image_style === self::IMG_FORMAT_JPEG) { $drawer = new BCGDrawJPG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); $drawer->setQuality($quality); } elseif ($image_style === self::IMG_FORMAT_GIF) { imagegif($im, $this->filename); } elseif ($image_style === self::IMG_FORMAT_WBMP) { imagewbmp($im, $this->filename); } if ($drawer !== null) { $drawer->draw(); } }
/** * Saves $im into the file (many format available). * * @param int $image_style * @param int $quality */ public function finish($image_style = self::IMG_FORMAT_PNG, $quality = 100) { $drawer = null; $im = $this->im; if ($this->rotateDegree > 0.0) { if (function_exists('imagerotate')) { $im = imagerotate($this->im, $this->rotateDegree, $this->color->allocate($this->im)); } else { throw new BCGDrawException('The method imagerotate doesn\'t exist on your server. Do not use any rotation.'); } } if ($image_style === self::IMG_FORMAT_PNG) { $drawer = new BCGDrawPNG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); } elseif ($image_style === self::IMG_FORMAT_JPEG) { $drawer = new BCGDrawJPG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); $drawer->setQuality($quality); } elseif ($image_style === self::IMG_FORMAT_GIF) { // Some PHP versions have a bug if passing 2nd argument as null. if ($this->filename === null || $this->filename === '') { imagegif($im); } else { imagegif($im, $this->filename); } } elseif ($image_style === self::IMG_FORMAT_WBMP) { imagewbmp($im, $this->filename); } if ($drawer !== null) { $drawer->draw(); } }
private static function make_crc_table() { for ($n = 0; $n < 256; $n++) { $c = $n; for ($k = 0; $k < 8; $k++) { if (($c & 1) == 1) { $c = 0xedb88320 ^ self::SHR($c, 1); } else { $c = self::SHR($c, 1); } } self::$crc_table[$n] = $c; } self::$crc_table_computed = true; }