mirror of
https://github.com/Intervention/image.git
synced 2025-08-15 18:34:03 +02:00
rewritten cloneResource method
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user