GD problem

Discussion in 'PHP' started by tautvys92, Apr 17, 2010.

  1. #1
    <?
    $bg = "0xFF 0xFF 0xFF";
    $bcg = explode(" ", $bg);
    $bg = imagecolorallocate($im, $bcg[0], $bcg[1], $bcg[2]);
    ?>
    What's wrong? I'm getting default black color instead of needed white. When putting 0xFF directly everything works fine.
     
    tautvys92, Apr 17, 2010 IP
  2. frank100

    frank100 Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    well i dont see definate advantage of coding that way ...
    any way for now,seems like explode is not taking space in proper way...
    whats about using - hypen
    and using pr to see what array $bcg has before send it to function
     
    frank100, Apr 17, 2010 IP
  3. Xuhybrid

    Xuhybrid Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You might be better off creating your own function. You could then send it "FFFFFF", then split it every 2 characters, and add "0x" to the start.

    By the way, imagecolorallocate does not set the background colour, it only sets a color resource. You would set the background colour by referencing the $bg variable in imagefill.
    imagefill($im, 0, 0, $bg);
    Code (markup):
    Try using var_export($bcg); to see what is is the array.
     
    Xuhybrid, Apr 18, 2010 IP
  4. tautvys92

    tautvys92 Peon

    Messages:
    246
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's only the part needed from the whole script.
     
    tautvys92, Apr 20, 2010 IP