|  | Posted by e_matthes on 04/17/07 15:55 
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($widthIn, $heightIn) {
 $this->imageRes = imageCreate($widthIn, $heightIn);
 }
 
 function colorImage($rIn,$gIn,$bIn) {
 $red = imagecolorallocate( $this->imageRes, $rIn,$gIn,$bIn );
 }
 
 function getImage() {
 return $this->imageRes;
 }
 
 }	// END class
 
 ?>
 
 Thanks for any help.
 -Eric
  Navigation: [Reply to this message] |