mirror of
https://github.com/Intervention/image.git
synced 2025-08-15 10:23:59 +02:00
rewritten cloneResource method
This commit is contained in:
@@ -1758,9 +1758,10 @@ class Image
|
||||
*/
|
||||
private function cloneResource($resource)
|
||||
{
|
||||
ob_start();
|
||||
imagegd2($resource);
|
||||
return imagecreatefromstring(ob_get_clean());
|
||||
$clone = imagecreatetruecolor($this->width, $this->height);
|
||||
imagecopy($clone, $resource, 0, 0, 0, 0, $this->width, $this->height);
|
||||
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1354,12 +1354,25 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$img = new Image(null, 800, 600, '#0000ff');
|
||||
$img->fill('#00ff00');
|
||||
$img->backup();
|
||||
$img->resize(200, 200);
|
||||
$img->reset();
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 800);
|
||||
$this->assertEquals($img->height, 600);
|
||||
$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()
|
||||
|
Reference in New Issue
Block a user