Changeset 69 for trunk/Packages/Common/Image.php
- Timestamp:
- Feb 28, 2016, 10:54:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Image.php
r55 r69 12 12 var $FileName; 13 13 var $Color; 14 15 function __construct() 14 15 function __construct() 16 16 { 17 17 $this->Color = COLOR_BLACK; … … 27 27 var $Y; 28 28 29 function __construct() 29 function __construct() 30 30 { 31 31 $this->Color = COLOR_BLACK; … … 40 40 var $Color; 41 41 42 function __construct() 42 function __construct() 43 43 { 44 44 $this->Color = COLOR_BLACK; … … 47 47 } 48 48 49 class Image 49 class Image 50 50 { 51 var $Image; 51 var $Image; 52 52 var $Type; 53 53 var $Font; 54 54 var $Pen; 55 55 56 56 function __construct() 57 57 { … … 59 59 $this->Type = IMAGETYPE_PNG; 60 60 $this->Pen = new Pen(); 61 $this->Font = new Font(); 62 $this->Brush = new Brush(); 61 $this->Font = new Font(); 62 $this->Brush = new Brush(); 63 63 } 64 64 65 65 function SaveToFile($FileName) 66 66 { 67 if($this->Type == IMAGETYPE_JPEG) 67 if($this->Type == IMAGETYPE_JPEG) 68 68 { 69 69 imagejpeg($this->Image, $FileName); 70 70 } else 71 if($this->Type == IMAGETYPE_GIF) 71 if($this->Type == IMAGETYPE_GIF) 72 72 { 73 73 imagegif($this->Image, $FileName); 74 74 } else 75 if($this->Type == IMAGETYPE_PNG) 75 if($this->Type == IMAGETYPE_PNG) 76 76 { 77 77 imagepng($this->Image, $FileName); 78 78 } 79 79 } 80 80 81 81 function LoadFromFile($FileName) 82 82 { 83 83 $ImageInfo = getimagesize($FileName); 84 84 $this->Type = $ImageInfo[2]; 85 if($this->Type == IMAGETYPE_JPEG) 85 if($this->Type == IMAGETYPE_JPEG) 86 86 { 87 87 $this->Image = imagecreatefromjpeg($FileName); 88 88 } else 89 if($this->Type == IMAGETYPE_GIF) 89 if($this->Type == IMAGETYPE_GIF) 90 90 { 91 91 $this->Image = imagecreatefromgif($FileName); 92 92 } else 93 if( $this->Type == IMAGETYPE_PNG) 93 if( $this->Type == IMAGETYPE_PNG) 94 94 { 95 95 $this->Image = imagecreatefrompng($FileName); 96 } 96 } 97 97 } 98 98 99 99 function Output() 100 100 { … … 103 103 104 104 function SetSize($Width, $Height) 105 { 105 { 106 106 $NewImage = imagecreatetruecolor($Width, $Height); 107 imagecopy($NewImage, $this->Image, 0, 0, 0, 0, $this->GetWidth(), $this->GetHeight()); 107 imagecopy($NewImage, $this->Image, 0, 0, 0, 0, $this->GetWidth(), $this->GetHeight()); 108 108 imagedestroy($this->Image); 109 109 $this->Image = $NewImage; 110 110 } 111 111 112 function GetWidth() 113 { 112 function GetWidth() 113 { 114 114 return(imagesx($this->Image)); 115 115 } 116 117 function GetHeight() 116 117 function GetHeight() 118 118 { 119 119 return(imagesy($this->Image)); 120 120 } 121 121 122 122 function TextOut($X, $Y, $Text) 123 123 { 124 124 imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text); 125 125 } 126 126 127 127 function ConvertColor($Color) 128 128 { 129 129 return(imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff)); 130 130 } 131 131 132 132 function FillRect($X1, $Y1, $X2, $Y2) 133 133 { 134 134 imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color)); 135 135 } 136 136 137 137 function Line($X1, $Y1, $X2, $Y2) 138 138 {
Note:
See TracChangeset
for help on using the changeset viewer.