C++ Learning Community Forum
September 09, 2010, 08:04:36 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Question about imagecreate  (Read 577 times)
Joel
Coding from an Igloo
Jr. Nerd
***
Posts: 47


Linux coder


View Profile WWW
« on: July 18, 2007, 02:49:05 PM »

This is my code:
$text_array = array("Joel""Almeida""García""Joel Almeida García");
$text $text_array[rand(0count($text_array)-1)];

$im imagecreate(5022);
$bgColor imagecolorallocate($im255255255);
$fgColor imagecolorallocate($im,   0,   00);
imagecolortransparent($im$bgColor);
imagestring($im200$text$fgColor);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
The above code, creates a png image from a random text....my question is: How can I calculate, by code, the corrrect values width and height of imagecreate, based on the returned text?

Thanks
Logged


* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Ubuntu 9.04; Kernel 2.6.28-15-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, gcj.
* Coming soon: Kubuntu 9.10 or Dragora 1.1
kccc
I think we have an answer to C-Man's question in his title.
Geek
*****
Posts: 147


View Profile
« Reply #1 on: July 19, 2007, 12:30:02 PM »

I don't understand what exactly you mean. Are you trying to get the width and height of the text as if it's a picture?
Logged
Joel
Coding from an Igloo
Jr. Nerd
***
Posts: 47


Linux coder


View Profile WWW
« Reply #2 on: July 19, 2007, 02:32:06 PM »

No, I want to create a image using the correct width and height values, without calculating in code time
Logged


* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Ubuntu 9.04; Kernel 2.6.28-15-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, gcj.
* Coming soon: Kubuntu 9.10 or Dragora 1.1
myork
Global Moderator
C++ guru
*****
Posts: 1147


View Profile
« Reply #3 on: July 19, 2007, 04:49:07 PM »

What language are you using?
You want to get the width and height of the some text?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!