ERLEDIGT
NEIN
NEIN
ANTWORTEN
3
3
ZUGRIFFE
902
902
EMPFEHLEN
-
20.07.04 11:58 #1fercules Tutorials.de Gastzugang
ich bins mal wieder mit meinem image manipulation script. diesmal will ich die farbe des textes ändern, aber es funktioniert nicht:
FF0000 sollte eigentlich ein strahlendes rot sein, aber der text wird immer wieder schwarz *würg*
<?
/*
Pull in all the requirements
*/
class img_add_txt{
function img_add_txt($config){
// header
//header("Content-Type: image/gif");
$this->func_header($config['image_type']);
// set up image
$im = ImageCreateFromPNG($config['image_loc']);
// Set up text colors
$text_colors=explode(" ", $config['text_colors']);
$text_color = ImageColorAllocate($im, $text_colors['0'], $text_colors['1'], $text_colors['2']);
// get font dimensiona
$font_height = ImageFontHeight(3);
$font_width = ImageFontWidth(3);
// get image dimensiona
$image_height = ImageSY($im);
$image_width = ImageSX($im);
// get string length
$length = $font_width * strlen($config['text']);
// set the x, y cords of where the text will be placed
if(empty($config['x_pos'])){
// calculate start coordinates for string
$image_center_x = ($image_width/2)-($length/2);
}else{
$image_center_x = $config['x_pos'];
}
if(empty($config['y_pos'])){
// calculate start coordinates for string
$image_center_y = ($image_height/2)-($font_height/2);
}else{
$image_center_y = $config['y_pos'];
}
// write string
imagettftext($im, 12, 0, $image_center_x, $image_center_y, $text_color, $config['schriftart'], $config['text']);
// output to browser
$this->output_image($config['image_type'], $im);
}// End img_add_txt
/*
Output the correct header based
on file type
*/
function func_header($var){
switch($var){
case "PNG":
header("Content-Type: image/png");
break;
case "GIF":
header("Content-Type: image/gif");
break;
case "JPEG":
header("Content-Type: image/jpeg");
break;
}
}// End func_header
/*
Output the correct image type
based on type
*/
function output_image($var, $pointer){
switch($var){
case "PNG":
ImagePNG($pointer);
break;
case "GIF":
ImageGIF($pointer);
break;
case "JPEG":
ImageJPEG($pointer);
break;
}
} // End out output image
} // End of class
/*
coupon image
*/
$config=array(
"schriftart" => "fonts/$schriftartf",
"text" => "$schriftzug",
"text_colors" => "FF 00 00", // RGB Seperated by spaces
"image_loc" => "shirts/gross/$shirt.png",
"image_type" => "PNG", // PNG and GIF Supported
// Optional arguments; default is center area on image
"x_pos" => "105",
"y_pos" => "90",
);
$graphic=new img_add_txt($config);
?>
any ideas warums nicht klappt?
grüße
fercules
-
Das, was du dem Script als Farbe übergibst sind Hexadezimal-Werte, keine RGB-Farbangaben! Wenn du einen RGB-Wert angeben willst, dann müssen das drei Zahlen im Bereich von 0 bis 255 sein.
Beispiele:
Schwarz
WeißCode :1
"text_colors" => "0 0 0", // RGB Seperated by spaces
BlauCode :1
"text_colors" => "255 255 255", // RGB Seperated by spaces
GrünCode :1
"text_colors" => "0 0 255", // RGB Seperated by spaces
GelbCode :1
"text_colors" => "0 255 0", // RGB Seperated by spaces
RotCode :1
"text_colors" => "255 255 0", // RGB Seperated by spaces
usw.Code :1
"text_colors" => "255 0 0", // RGB Seperated by spaces
Ich hoffe, geholfen zu haben....Geändert von ludz (20.07.04 um 13:02 Uhr)
"... the KKK took my baby away ..."
-
Kann sein dass ich mich täusche aber ich fine eure Lösungen recht umständlcih. Mann kann doch auch die Farbwerte als Variable übergeben.
-
21.07.04 10:02 #4fercules Tutorials.de Gastzugang
natürlich, stimmt. vom ganzen html gedudel bin ich die hexadezimal geschichten derart gewohnt, dass ich auf RGB gar nicht gekommen bin. hexadezimale angaben sind ja auch die regel.... vielen dank jedenfalls
grüße
stephan
Ähnliche Themen
-
onclick Textfarbe ändern
Von Brauni im Forum Javascript & AjaxAntworten: 13Letzter Beitrag: 10.07.08, 14:11 -
Textfarbe ändern
Von Diddle im Forum Videoschnitt, Videotechnik & -produktionAntworten: 3Letzter Beitrag: 24.08.05, 20:38 -
textfarbe mit enum ändern
Von andreas_gierisch im Forum C/C++Antworten: 4Letzter Beitrag: 20.04.05, 10:47 -
Textfarbe bei onmouseover ändern
Von Chandini im Forum HTML & XHTMLAntworten: 2Letzter Beitrag: 20.07.04, 14:45 -
Textfarbe ändern usw...
Von xamunrax im Forum Flash PlattformAntworten: 6Letzter Beitrag: 08.04.02, 19:56





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren