[PHP] Pear::Image_Text - how to change background color from black

2004-09-24 Thread Chris Dowell
Guys
Without hacking the pear library, does anyone know of any way (using the 
API) to change the background color of an image created with Image_Text 
from black?

The bg is black because the image resource is created using 
imagecreatetruecolor() which returns a black image - this is on some of 
lines 550-569 in the pear source. I could change this, but I'm sure 
Tobias must have written in some way for this to be changed - the docs 
are of course minimal, and I can't find anything in the source.

The text is nice and yellow, as specified in the code below, the only 
problem is changing the background from the lovely black default.

Can anyone help me out? Code follows:
Cheers
Chris
-

require_once 'Image/Text.php';
$options = array( 'image_type' => IMAGETYPE_JPEG,
  'font_file' => 'flc.ttf',
  'width' => 100,
  'height' => 200,
  'font_path' => '/path/to/font/file/',
  'max_lines' => 1,
  'x' => 2,
  'y' => 2,
  'font_size' => 12,
);
$hImage =& Image_Text::construct("hello world", $options);
$hImage->setColor('#00', 0);
$hImage->init();
$hImage->render();
$hImage->display();
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [SOLVED] [PHP] Pear::Image_Text - how to change background color from black

2004-09-24 Thread Chris Dowell
Just FYI
I figured it out - there is an $options['canvas'] option which accepts, 
amongst other things, a handle to an image resource. Trivial then to use 
imagecreate() and imagecolorallocate() to create a white-background 
starting point.

Sorry for wasting everyone's time
Cheers
Chris
Chris Dowell wrote:
Guys
Without hacking the pear library, does anyone know of any way (using 
the API) to change the background color of an image created with 
Image_Text from black?

The bg is black because the image resource is created using 
imagecreatetruecolor() which returns a black image - this is on some 
of lines 550-569 in the pear source. I could change this, but I'm sure 
Tobias must have written in some way for this to be changed - the docs 
are of course minimal, and I can't find anything in the source.

The text is nice and yellow, as specified in the code below, the only 
problem is changing the background from the lovely black default.

Can anyone help me out? Code follows:
Cheers
Chris
-

require_once 'Image/Text.php';
$options = array( 'image_type' => IMAGETYPE_JPEG,
  'font_file' => 'flc.ttf',
  'width' => 100,
  'height' => 200,
  'font_path' => '/path/to/font/file/',
  'max_lines' => 1,
  'x' => 2,
  'y' => 2,
  'font_size' => 12,
);
$hImage =& Image_Text::construct("hello world", $options);
$hImage->setColor('#00', 0);
$hImage->init();
$hImage->render();
$hImage->display();
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php