Hello everyone,
I'm trying to make a class that will generate images. I can get it to
work if the class and the instance of the class is in the same file.
However, I can't get it to work if I save the class as its own file,
and try to make an instance of it in another file. Any thoughts?
Here is the working version:
<?php
header("Content-type: image/png");
$imageRes = new Image(200, 300);
$imageRes->colorImage(255 ,0,0);
$image = $imageRes->getImage();
imagepng($image );
class Image {
private $imageRes;
function __construct($wi dthIn, $heightIn) {
$this->imageRes = imageCreate($wi dthIn, $heightIn);
}
function colorImage($rIn ,$gIn,$bIn) {
$red = imagecoloralloc ate( $this->imageRes, $rIn,$gIn,$bIn );
}
function getImage() {
return $this->imageRes;
}
} // END class
?>
Thanks for any help.
-Eric
I'm trying to make a class that will generate images. I can get it to
work if the class and the instance of the class is in the same file.
However, I can't get it to work if I save the class as its own file,
and try to make an instance of it in another file. Any thoughts?
Here is the working version:
<?php
header("Content-type: image/png");
$imageRes = new Image(200, 300);
$imageRes->colorImage(255 ,0,0);
$image = $imageRes->getImage();
imagepng($image );
class Image {
private $imageRes;
function __construct($wi dthIn, $heightIn) {
$this->imageRes = imageCreate($wi dthIn, $heightIn);
}
function colorImage($rIn ,$gIn,$bIn) {
$red = imagecoloralloc ate( $this->imageRes, $rIn,$gIn,$bIn );
}
function getImage() {
return $this->imageRes;
}
} // END class
?>
Thanks for any help.
-Eric
Comment