function _flipPng() { $source = ImagecreateFromPng($this->_source); $width = imagesx($source); $height = imagesy($source); if ($this->_isPNG8($this->_source)) { $image = ImageCreate($height, $width); } else { $image = ImageCreateTrueColor($height, $width); imagealphablending($image, false); imagesavealpha($image, true); } if ($this->_hori) { for ($i = 0; $i < $width; $i++) { ImageCopyResampled($image, $source, $width - $i - 1, 0, $i, 0, 1, $height, 1, $height); } if ($this->_vert) { ImageCopyResampled($source, $image, 0, 0, 0, 0, $width, $height, $width, $height); } } if ($this->_vert) { for ($i = 0; $i < $height; $i++) { ImageCopyResampled($image, $source, 0, $height - $i - 1, 0, $i, $width, 1, $width, 1); } } ImageDestroy($source); $result = ImagePng($image, $this->_target); ImageDestroy($image); return $result; }
/** * Internal function for resizing png images. * @return Bool true or false depending on success or not. */ function _resizePng() { $source = ImagecreateFromPng($this->_source); $image = ImageCreate($this->_width, $this->_height); imagealphablending($image, true); imagesavealpha($image, true); $transparent = imagecolorallocatealpha($image, 255, 255, 255, 0); imagefilledrectangle($image, 0, 0, $this->_width, $this->_height, $transparent); imagecolortransparent($image, $transparent); ImageCopyResampled($image, $source, 0, 0, 0, 0, $this->_width, $this->_height, ImageSX($source), ImageSY($source)); $result = ImagePng($image, $this->_target); ImageDestroy($image); ImageDestroy($source); return $result; }