1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-16 02:44:01 +02:00

rewritten cloneResource method

This commit is contained in:
Oliver Vogel
2014-02-20 16:56:17 +01:00
parent aa75c42975
commit 6fd584686f
2 changed files with 17 additions and 3 deletions

View File

@@ -1758,9 +1758,10 @@ class Image
*/ */
private function cloneResource($resource) private function cloneResource($resource)
{ {
ob_start(); $clone = imagecreatetruecolor($this->width, $this->height);
imagegd2($resource); imagecopy($clone, $resource, 0, 0, 0, 0, $this->width, $this->height);
return imagecreatefromstring(ob_get_clean());
return $clone;
} }
/** /**

View File

@@ -1354,12 +1354,25 @@ class ImageTest extends PHPUnit_Framework_Testcase
$img = new Image(null, 800, 600, '#0000ff'); $img = new Image(null, 800, 600, '#0000ff');
$img->fill('#00ff00'); $img->fill('#00ff00');
$img->backup(); $img->backup();
$img->resize(200, 200);
$img->reset(); $img->reset();
$this->assertInternalType('int', $img->width); $this->assertInternalType('int', $img->width);
$this->assertInternalType('int', $img->height); $this->assertInternalType('int', $img->height);
$this->assertEquals($img->width, 800); $this->assertEquals($img->width, 800);
$this->assertEquals($img->height, 600); $this->assertEquals($img->height, 600);
$this->assertEquals('#00ff00', $img->pickColor(0, 0, 'hex')); $this->assertEquals('#00ff00', $img->pickColor(0, 0, 'hex'));
$img = new Image('public/tile.png');
$img->resize(10, 10);
$img->fill('#00ff00');
$img->backup();
$img->resize(5, 5);
$img->reset();
$this->assertInternalType('int', $img->width);
$this->assertInternalType('int', $img->height);
$this->assertEquals($img->width, 10);
$this->assertEquals($img->height, 10);
$this->assertEquals('#00ff00', $img->pickColor(0, 0, 'hex'));
} }
public function testLimitColors() public function testLimitColors()