示例#1
0
文件: Image.php 项目: nsatvik/Sample
 function __construct($width, $height, $back_color, $fore_color)
 {
     $this->image = ImageCreate($width, $height);
     $this->width = $width;
     $this->height = $height;
     $color_codes = getColorCodes($back_color);
     $this->background_color = ImageColorAllocate($this->image, $color_codes['r'], $color_codes['g'], $color_codes['b']);
     $color_codes = getColorCodes($fore_color);
     $this->foreground_color = ImageColorAllocate($this->image, $color_codes['r'], $color_codes['g'], $color_codes['b']);
 }
示例#2
0
            //case 'magenta':
    }
}
$mysql_handler = new MySQlConnector("root", "chotu", "imagedb");
$mysql_handler->connect();
$id = $_GET['imageID'];
$query = "select * from image where imageID={$id};";
//echo $query; //Never Use echo and draw something.
$result = $mysql_handler->execute($query);
$row = mysql_fetch_array($result);
//$img = new Image((int)$row['width'], (int)$row['height'], $row['back_color'], $row['fore_color']);
//$img->drawImage('png');
$my_img = imagecreate((int) $row['width'], (int) $row['height']);
$bcolor = getColorCodes($row['back_color']);
$background = imagecolorallocate($my_img, $bcolor['r'], $bcolor['g'], $bcolor['b']);
$bcolor = getColorCodes($row['fore_color']);
$foreground = imagecolorallocate($my_img, $bcolor['r'], $bcolor['g'], $bcolor['b']);
/*
 *Display all the text related to this image.
 */
$query = "select * from text where imageId={$id};";
$result = $mysql_handler->execute($query);
while ($row = mysql_fetch_array($result)) {
    imagestring($my_img, $row['font'], $row['x'], $row['y'], $row['text'], $foreground);
}
/*
 *Display all the arcs related to this image.
 */
$query = "select * from arc where imageId={$id};";
$result = $mysql_handler->execute($query);
while ($row = mysql_fetch_array($result)) {