Changeset 8 for trunk/Packages/Common/Image.php
- Timestamp:
- Jun 1, 2023, 12:18:18 AM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Image.php
r7 r8 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() … … 38 38 class Brush 39 39 { 40 var$Color;40 public int $Color; 41 41 42 42 function __construct() … … 49 49 class Image 50 50 { 51 var $Image; 52 var $Type; 53 var $Font; 54 var $Pen; 51 public $Image; 52 public int $Type; 53 public Font $Font; 54 public Pen $Pen; 55 public Brush $Brush; 55 56 56 57 function __construct() … … 63 64 } 64 65 65 function SaveToFile( $FileName)66 function SaveToFile(string $FileName): void 66 67 { 67 68 if ($this->Type == IMAGETYPE_JPEG) … … 79 80 } 80 81 81 function LoadFromFile( $FileName)82 function LoadFromFile(string $FileName): void 82 83 { 83 84 $ImageInfo = getimagesize($FileName); … … 89 90 if ($this->Type == IMAGETYPE_GIF) 90 91 { 91 $this->Image = imagecreatefromgif ($FileName);92 $this->Image = imagecreatefromgif ($FileName); 92 93 } else 93 94 if ( $this->Type == IMAGETYPE_PNG) … … 97 98 } 98 99 99 function Output() 100 { 101 $this->SaveToFile(NULL); 102 } 103 104 function SetSize($Width, $Height) 100 function SetSize(int $Width, int $Height): void 105 101 { 106 102 $NewImage = imagecreatetruecolor($Width, $Height); … … 110 106 } 111 107 112 function GetWidth() 108 function GetWidth(): int 113 109 { 114 110 return imagesx($this->Image); 115 111 } 116 112 117 function GetHeight() 113 function GetHeight(): int 118 114 { 119 115 return imagesy($this->Image); 120 116 } 121 117 122 function TextOut( $X, $Y, $Text)118 function TextOut(int $X, int $Y, string $Text): void 123 119 { 124 120 imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text); 125 121 } 126 122 127 function ConvertColor( $Color)123 function ConvertColor(int $Color): int 128 124 { 129 125 return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff); 130 126 } 131 127 132 function FillRect( $X1, $Y1, $X2, $Y2)128 function FillRect(int $X1, int $Y1, int $X2, int $Y2): void 133 129 { 134 130 imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color)); 135 131 } 136 132 137 function Line( $X1, $Y1, $X2, $Y2)133 function Line(int $X1, int $Y1, int $X2, int $Y2): void 138 134 { 139 135 imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color));
Note:
See TracChangeset
for help on using the changeset viewer.