Changeset 4 for Common/Image.php


Ignore:
Timestamp:
Jan 9, 2016, 12:48:30 PM (9 years ago)
Author:
chronos
Message:
  • Added: New files AppModule, Config, Page and Base.
  • Modified: Some files were normalized to unix line ending characters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/Image.php

    r1 r4  
    1212  var $FileName;
    1313  var $Color;
    14  
    15   function __construct() 
     14
     15  function __construct()
    1616  {
    1717    $this->Color = COLOR_BLACK;
     
    2727  var $Y;
    2828
    29   function __construct() 
     29  function __construct()
    3030  {
    3131    $this->Color = COLOR_BLACK;
     
    4040  var $Color;
    4141
    42   function __construct() 
     42  function __construct()
    4343  {
    4444    $this->Color = COLOR_BLACK;
     
    4747}
    4848
    49 class Image 
     49class Image
    5050{
    51   var $Image; 
     51  var $Image;
    5252  var $Type;
    5353  var $Font;
    5454  var $Pen;
    55  
     55
    5656  function __construct()
    5757  {
     
    5959    $this->Type = IMAGETYPE_PNG;
    6060    $this->Pen = new Pen();
    61     $this->Font = new Font();   
    62     $this->Brush = new Brush();   
     61    $this->Font = new Font();
     62    $this->Brush = new Brush();
    6363  }
    64  
     64
    6565  function SaveToFile($FileName)
    6666  {
    67     if($this->Type == IMAGETYPE_JPEG) 
     67    if($this->Type == IMAGETYPE_JPEG)
    6868    {
    6969      imagejpeg($this->Image, $FileName);
    7070    } else
    71     if($this->Type == IMAGETYPE_GIF) 
     71    if($this->Type == IMAGETYPE_GIF)
    7272    {
    7373      imagegif($this->Image, $FileName);
    7474    } else
    75     if($this->Type == IMAGETYPE_PNG) 
     75    if($this->Type == IMAGETYPE_PNG)
    7676    {
    7777      imagepng($this->Image, $FileName);
    7878    }
    7979  }
    80  
     80
    8181  function LoadFromFile($FileName)
    8282  {
    8383    $ImageInfo = getimagesize($FileName);
    8484    $this->Type = $ImageInfo[2];
    85     if($this->Type == IMAGETYPE_JPEG) 
     85    if($this->Type == IMAGETYPE_JPEG)
    8686    {
    8787      $this->Image = imagecreatefromjpeg($FileName);
    8888    } else
    89     if($this->Type == IMAGETYPE_GIF) 
     89    if($this->Type == IMAGETYPE_GIF)
    9090    {
    9191      $this->Image = imagecreatefromgif($FileName);
    9292    } else
    93     if( $this->Type == IMAGETYPE_PNG) 
     93    if( $this->Type == IMAGETYPE_PNG)
    9494    {
    9595      $this->Image = imagecreatefrompng($FileName);
    96     } 
     96    }
    9797  }
    98  
     98
    9999  function Output()
    100100  {
     
    103103
    104104  function SetSize($Width, $Height)
    105   {     
     105  {
    106106    $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());
    108108    imagedestroy($this->Image);
    109109    $this->Image = $NewImage;
    110110  }
    111111
    112   function GetWidth() 
    113   { 
     112  function GetWidth()
     113  {
    114114    return(imagesx($this->Image));
    115115  }
    116  
    117   function GetHeight() 
     116
     117  function GetHeight()
    118118  {
    119119    return(imagesy($this->Image));
    120120  }
    121  
     121
    122122  function TextOut($X, $Y, $Text)
    123123  {
    124124    imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text);
    125125  }
    126  
     126
    127127  function ConvertColor($Color)
    128128  {
    129129    return(imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));
    130130  }
    131  
     131
    132132  function FillRect($X1, $Y1, $X2, $Y2)
    133133  {
    134134    imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color));
    135135  }
    136  
     136
    137137  function Line($X1, $Y1, $X2, $Y2)
    138138  {
Note: See TracChangeset for help on using the changeset viewer.