You are here: Class to generate images « PHP Programming Language « IT news, forums, messages
Class to generate images

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация