/** * Save the GD image to a file * * @param GdImage $gdImage The target GD image * @param integer $x The target X coordinate * @param integer $y The target Y coordinate * @param integer $width The target width * @param integer $height The target height * * @return static */ public function copyTo(self $gdImage, $x, $y, $width, $height) { imagecopyresampled($gdImage->getResource(), $this->gdResource, $x, $y, 0, 0, $width, $height, imagesx($this->gdResource), imagesy($this->gdResource)); return $this; }
/** * Tests the isSemitransparent() method. */ public function testIsSemitransparent() { $image = imagecreatetruecolor(100, 100); imagealphablending($image, false); $image = new GdImage($image); imagefill($image->getResource(), 0, 0, imagecolorallocatealpha($image->getResource(), 0, 0, 0, 0)); $this->assertFalse($image->isSemitransparent()); imagefill($image->getResource(), 0, 0, imagecolorallocatealpha($image->getResource(), 0, 0, 0, 127)); $this->assertFalse($image->isSemitransparent()); imagefill($image->getResource(), 0, 0, imagecolorallocatealpha($image->getResource(), 0, 0, 0, 126)); $this->assertTrue($image->isSemitransparent()); imagefill($image->getResource(), 0, 0, imagecolorallocatealpha($image->getResource(), 0, 0, 0, 1)); $this->assertTrue($image->isSemitransparent()); imagefill($image->getResource(), 0, 0, imagecolorallocatealpha($image->getResource(), 0, 0, 0, 0)); $this->assertFalse($image->isSemitransparent()); }