il y a pas mal de code, je laisse uniquement l'essentiel
ImageCreate.php
<?PHP
class ImageCreate
{
public function __construct($Width, $Height)
{
$this->Image = imagecreate($Width, $Height);
imagealphablending($this->Image, false);
imagesavealpha($this->Image, true);
$this->Width = $Width;
$this->Height = $Height;
}
public function getImage()
{
return $this->Image;
}
public function getWidth()
{
return $this->Width;
}
public function getHeight()
{
return $this->Height;
}
public function getColor($Hexadecimal)
{
return imagecolorallocate($this->Image, hexdec(substr($Hexadecimal, 1, 2)), hexdec(substr($Hexadecimal, 3, 2)), hexdec(substr($Hexadecimal, 5, 2)));
}
public function display()
{
header('Content-type: image/png');
imagepng($this->Image);
imagedestroy($this->Image);
}
public function save($Path)
{
imagepng($this->Image, $Path);
imagedestroy($this->Image);
}
private $Image;
private $Width;
private $Height;
}
?>
Image.php
<?PHP
class Image
{
public function __construct(ImageCreate $Image, $Source, $Width, $Height, $Position_X, $Position_Y)
{
$ImageSource = imagecreatefrompng($Source);
imagecopy($Image->getImage(), $ImageSource, $Position_X, $Position_Y, 0, 0, $Width, $Height);
}
}
?>
une partie d'une classe...
$this->Image = new ImageCreate($this->Width, $this->Height);
new Image($this->Image, $this->AvailableImages[$Background1], $this->Width, $this->Height, 0, 0);
new Image($this->Image, $this->AvailableImages[$Background2], 305, 118, 0, 0);
new Image($this->Image, $this->AvailableImages[$Background3], 305, 42, 0, 0);
new Text($this->Image, 215, 20, $Hotel1, '#3366FF', 14, $this->AvailableFonts['TIMES']);
new Text($this->Image, 180, 40, $Hotel2, '#3366FF', 14, $this->AvailableFonts['TIMES']);