I have a class that does some massive computations to compute a LOPA
(layout of passenger aircraft).
I currently render it in an HTML table with little seats. I want to now
make this using GD so I can show entire fleets of aircraft on one page.
Inside my LOPA.class.php I have this method:
public function render_image()
{
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, "Test Image", $text_colour
);
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );
header( "Content-type: image/png" );
header('Content-Length: ' . strlen($my_img));
imagepng( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
}
And I'm trying to call it from a PHP page like so:
<img src="<?php $my_lopa->render_image(); ?>" alt="Image created by a PHP
script" width="200" height="80">
But it doesn't show the picture. :\
If I take the contents of that function and dump it into a "gdtest.php"
file and call it like this however, it does work:
<img src="images/gdtest.php" alt="Image created by a PHP script"
width="200" height="80">
So what am I doing wrong above that I can't just call it from my class?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php