tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
3
ZUGRIFFE
902
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    fercules 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
     

  2. #2
    Registriert seit
    Aug 2002
    Ort
    Hessen
    Beiträge
    693
    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
    Code :
    1
    
    "text_colors" => "0 0 0", // RGB Seperated by spaces
    Weiß
    Code :
    1
    
    "text_colors" => "255 255 255", // RGB Seperated by spaces
    Blau
    Code :
    1
    
    "text_colors" => "0 0 255", // RGB Seperated by spaces
    Grün
    Code :
    1
    
    "text_colors" => "0 255 0", // RGB Seperated by spaces
    Gelb
    Code :
    1
    
    "text_colors" => "255 255 0", // RGB Seperated by spaces
    Rot
    Code :
    1
    
    "text_colors" => "255 0 0", // RGB Seperated by spaces
    usw.
    Ich hoffe, geholfen zu haben....
    Geändert von ludz (20.07.04 um 13:02 Uhr)
     
    "... the KKK took my baby away ..."

  3. #3
    Avatar von Claas M
    Claas M Claas M ist offline Mitglied Brokat
    Registriert seit
    May 2004
    Ort
    Nähe Kiel
    Beiträge
    285
    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.
     

  4. #4
    fercules 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

  1. onclick Textfarbe ändern
    Von Brauni im Forum Javascript & Ajax
    Antworten: 13
    Letzter Beitrag: 10.07.08, 14:11
  2. Textfarbe ändern
    Von Diddle im Forum Videoschnitt, Videotechnik & -produktion
    Antworten: 3
    Letzter Beitrag: 24.08.05, 20:38
  3. textfarbe mit enum ändern
    Von andreas_gierisch im Forum C/C++
    Antworten: 4
    Letzter Beitrag: 20.04.05, 10:47
  4. Textfarbe bei onmouseover ändern
    Von Chandini im Forum HTML & XHTML
    Antworten: 2
    Letzter Beitrag: 20.07.04, 14:45
  5. Textfarbe ändern usw...
    Von xamunrax im Forum Flash Plattform
    Antworten: 6
    Letzter Beitrag: 08.04.02, 19:56