Witam.
Z problemem męczę się od wczoraj wieczór.
Mały wstęp:
Posiadam klasę (a raczej jej zalążek), która generuje tzw. cenówki (5cm x 3.5cm) - czyli jednym słowem tabelę o wymiarach 4x8 razem z tekstem i cyferkami na kartce formatu A4, która potem idzie do druku.
KOD:
CODE
<?php
class cenowki {
var $dpi;
var $x_mm;
var $y_mm;
var $x;
var $y;
var $image_resource;
var $bg_r, $bg_g, $bg_b;
var $background_color;
var $colors;
public function __construct() {
$this->dpi = 0;
$this->x_mm = 0;
$this->y_mm = 0;
$this->x = 0;
$this->y = 0;
$this->image_resource = NULL;
$this->bg_r = 0;
$this->bg_g = 0;
$this->bg_b = 0;
$this->background_color = 0;
$this->colors = array();
return true;
}
public function __destruct() {
return true;
}
function debug() {
print_r($this->colors)."<br>\n";
echo($this->background_color)."<br>";
echo($this->image_resource)."<br>";
echo($this->dpi)."<br>";
echo($this->x)."<br>";
echo($this->y)."<br>";
}
public function createimage($arguments) {
$this->x = ($arguments['x_mm'] / 25.4) * $arguments['dpi'];
$this->y = ($arguments['y_mm'] / 25.4) * $arguments['dpi'];
$this->x_mm = $arguments['x_mm'];
$this->y_mm = $arguments['y_mm'];
$this->dpi = $arguments['dpi'];
$this->image_resource = imagecreatetruecolor($this->x, $this->y);
return true;
}
public function background_color($r, $g, $b) {
//list($bg_r, $bg_g, $bg_b) = explode(":", $arguments['background']);
$im = $this->image_resource;
$this->background_color = imagecolorallocate($im, $r, $g, $b);
return true;
}
public function colors($arguments) {
$im = $this->image_resource;
foreach($arguments['colors'] as $key => $val) {
list($r, $g, $b) = explode(":", $val);
$this->colors[$key] = imagecolorallocate($im, $r, $g, $b);
}
return true;
}
public function drawbox($color) {
//if(!array_key_exists('black', $this->$colors))
// $this->$colors['black'] = imagecolorallocate($this->$image_resource, 0, 0, 0);
$im = $this->image_resource;
imageline($im,0,0,($this->x) - 1,0,$this->colors[$color]);
imageline($im,0,0,0,($this->y) - 1,$this->colors[$color]);
imageline($im,0,$this->y - 1,($this->x) - 1,($this->y) - 1,$this->colors[$color]);
imageline($im,$this->x - 1,0,($this->x) - 1,($this->y) - 1,$this->colors[$color]);
//imageline($im,0,0,($this->x) - 1,0,0);
//imageline($im,0,0,0,($this->y) - 1,0);
//imageline($im,0,($this->y) - 1,($this->x) - 1,($this->y) - 1,0);
//imageline($im,($this->x) - 1,0,($this->x) - 1,($this->y) - 1,0);
return true;
}
public function drawcell($rows, $cols, $color) {
$width = $this->x;
$height = $this->y;
$count_c = $width / $cols;
$count_r = $height / $rows;
for($i = 0; $i <= $width; $i += $count_c)
imageline($this->image_resource,$i,0,$i,$height,$this->colors[$color]);
for($i = 0; $i <= $height; $i += $count_r)
imageline($this->image_resource,0,$i,$width,$i,$this->colors[$color]);
return true;
}
function &getImg()
{
return $this->image_resource;
}
public function output() {
$im = $this->image_resource;
header('Content-type: image/png');
//return imagepng($im);
imagepng($im);
}
}
?>
Problem w tym, że po takim kodzie:
CODE
<?php
$arg = array(
'x_mm' => 210,
'y_mm' => 297,
'dpi' => 72,
'background' => '0:0:0',
'colors' => array(
'red' => '255:0:0',
'green' => '0:255:0',
'blue' => '0:0:255'
)
);
$test = new cenowki();
$test->createimage($arg);
$test->background_color(0,0,0);
$test->colors($arg);
$test->drawbox('red');
$test->drawcell(4,8,'green');
$test->output();
?>
W przeglądarce pisze, że:
Obrazek "http://localhost/prokom/test.php" nie może zostać wyświetlony, ponieważ zawiera błędy.
Zaznaczam, że używając normalnych funkcji, wszystko działało poprawnie, za to po przepisaniu TAK SAMO tych samych funkcji do klasy, właśnie wtedy problem się pojawił. :/
Używam Firefox'a 3, ale nie wiem czy ma to jakieś znaczenie.
Proszę o jakieś wskazówki, bo 'szef mnie zje'

Dzięki i pozdrawiam.
Witam.
Problem rozwiązany.
w kodzie między:
<?php
include_once("class.cenowki.php.");
?>
<?php
kod
?>
byla spacja