Changeset 95 for trunk/Packages/Common/Image.php
- Timestamp:
- Dec 6, 2021, 11:33:48 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Image.php
r92 r95 9 9 class Font 10 10 { 11 var$Size;12 var$FileName;13 var$Color;11 public int $Size; 12 public string $FileName; 13 public int $Color; 14 14 15 15 function __construct() … … 23 23 class Pen 24 24 { 25 var$Color;26 var$X;27 var$Y;25 public int $Color; 26 public int $X; 27 public int $Y; 28 28 29 29 function __construct() … … 33 33 $this->Y = 0; 34 34 } 35 36 35 } 37 36 38 37 class Brush 39 38 { 40 var$Color;39 public int $Color; 41 40 42 41 function __construct() … … 44 43 $this->Color = COLOR_BLACK; 45 44 } 46 47 45 } 48 46 49 47 class Image 50 48 { 51 var $Image; 52 var $Type; 53 var $Font; 54 var $Pen; 49 public $Image; 50 public int $Type; 51 public Font $Font; 52 public Pen $Pen; 53 public Brush $Brush; 55 54 56 55 function __construct() … … 63 62 } 64 63 65 function SaveToFile( $FileName)64 function SaveToFile(string $FileName): void 66 65 { 67 66 if ($this->Type == IMAGETYPE_JPEG) … … 71 70 if ($this->Type == IMAGETYPE_GIF) 72 71 { 73 imagegif 72 imagegif($this->Image, $FileName); 74 73 } else 75 74 if ($this->Type == IMAGETYPE_PNG) … … 79 78 } 80 79 81 function LoadFromFile( $FileName)80 function LoadFromFile(string $FileName): void 82 81 { 83 82 $ImageInfo = getimagesize($FileName); … … 89 88 if ($this->Type == IMAGETYPE_GIF) 90 89 { 91 $this->Image = imagecreatefromgif ($FileName);90 $this->Image = imagecreatefromgif ($FileName); 92 91 } else 93 92 if ( $this->Type == IMAGETYPE_PNG) … … 97 96 } 98 97 99 function Output() 98 function Output(): void 100 99 { 101 $this->SaveToFile( NULL);100 $this->SaveToFile(''); 102 101 } 103 102 104 function SetSize( $Width, $Height)103 function SetSize(int $Width, int $Height): void 105 104 { 106 105 $NewImage = imagecreatetruecolor($Width, $Height); … … 110 109 } 111 110 112 function GetWidth() 111 function GetWidth(): int 113 112 { 114 113 return imagesx($this->Image); 115 114 } 116 115 117 function GetHeight() 116 function GetHeight(): int 118 117 { 119 118 return imagesy($this->Image); 120 119 } 121 120 122 function TextOut( $X, $Y, $Text)121 function TextOut(int $X, int $Y, string $Text): void 123 122 { 124 123 imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text); 125 124 } 126 125 127 function ConvertColor( $Color)126 function ConvertColor(int $Color): int 128 127 { 129 128 return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff); 130 129 } 131 130 132 function FillRect( $X1, $Y1, $X2, $Y2)131 function FillRect(int $X1, int $Y1, int $X2, int $Y2): void 133 132 { 134 133 imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color)); 135 134 } 136 135 137 function Line( $X1, $Y1, $X2, $Y2)136 function Line(int $X1, int $Y1, int $X2, int $Y2): void 138 137 { 139 138 imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color));
Note:
See TracChangeset
for help on using the changeset viewer.