Ignore:
Timestamp:
Jun 1, 2023, 12:18:18 AM (19 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Modified: Form types made as separate FormManager package.
  • Fixed: PHP 8.1 support.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Image.php

    r7 r8  
    99class Font
    1010{
    11   var $Size;
    12   var $FileName;
    13   var $Color;
     11  public int $Size;
     12  public string $FileName;
     13  public int $Color;
    1414
    1515  function __construct()
     
    2323class Pen
    2424{
    25   var $Color;
    26   var $X;
    27   var $Y;
     25  public int $Color;
     26  public int $X;
     27  public int $Y;
    2828
    2929  function __construct()
     
    3838class Brush
    3939{
    40   var $Color;
     40  public int $Color;
    4141
    4242  function __construct()
     
    4949class Image
    5050{
    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;
    5556
    5657  function __construct()
     
    6364  }
    6465
    65   function SaveToFile($FileName)
     66  function SaveToFile(string $FileName): void
    6667  {
    6768    if ($this->Type == IMAGETYPE_JPEG)
     
    7980  }
    8081
    81   function LoadFromFile($FileName)
     82  function LoadFromFile(string $FileName): void
    8283  {
    8384    $ImageInfo = getimagesize($FileName);
     
    8990    if ($this->Type == IMAGETYPE_GIF)
    9091    {
    91       $this->Image = imagecreatefromgif($FileName);
     92      $this->Image = imagecreatefromgif ($FileName);
    9293    } else
    9394    if ( $this->Type == IMAGETYPE_PNG)
     
    9798  }
    9899
    99   function Output()
    100   {
    101     $this->SaveToFile(NULL);
    102   }
    103 
    104   function SetSize($Width, $Height)
     100  function SetSize(int $Width, int $Height): void
    105101  {
    106102    $NewImage = imagecreatetruecolor($Width, $Height);
     
    110106  }
    111107
    112   function GetWidth()
     108  function GetWidth(): int
    113109  {
    114110    return imagesx($this->Image);
    115111  }
    116112
    117   function GetHeight()
     113  function GetHeight(): int
    118114  {
    119115    return imagesy($this->Image);
    120116  }
    121117
    122   function TextOut($X, $Y, $Text)
     118  function TextOut(int $X, int $Y, string $Text): void
    123119  {
    124120    imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text);
    125121  }
    126122
    127   function ConvertColor($Color)
     123  function ConvertColor(int $Color): int
    128124  {
    129125    return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff);
    130126  }
    131127
    132   function FillRect($X1, $Y1, $X2, $Y2)
     128  function FillRect(int $X1, int $Y1, int $X2, int $Y2): void
    133129  {
    134130    imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color));
    135131  }
    136132
    137   function Line($X1, $Y1, $X2, $Y2)
     133  function Line(int $X1, int $Y1, int $X2, int $Y2): void
    138134  {
    139135    imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color));
Note: See TracChangeset for help on using the changeset viewer.