+ Reply to Thread
Results 1 to 2 of 2

Thread: problem s imagecolorallocate()

  1. #1

    problem s imagecolorallocate()

    Zdravim uz dlhsiu dobu riesim v php natoceny text v obrazku.
    uz sa mi to podarilo ale mam problem s farbou textu...

    Ukážka je tu:
    Code:
    http://agae.sk/new/
    V index.php mam pod sebou 2 obrazky... jeden generovany z obr.php a druhy je png obrazok ktory si nacitava subor obr.php

    zdrojovy kod suboru obr.php

    Code:
    <?php
    header('Content-Type: image/png');
    $im = imagecreatefrompng('1.png');
    $text = 'Zľavy';
    $font = 'arial.ttf';
    $cerna = imagecolorallocate($im, 0, 0, 0); // chcam mat text ciernej farby
    imagettftext($im, 7, 10, 20, 20, $cerna, $font, $text);
    imagepng($im);
    imagedestroy($im);
    ?>
    A funguje mi vsetko az na farbu textu ktora sa mi nejako cudne meni...


    Viete mi pomocť s tým, aby tá farba bola čisto čierna ?

    Za odpovede ďakujem

  2. #2
    Už som to vyriešil tým ze som si zadefinoval nejakú farbu, potom som na tu premennú kde bola definovaná ta farba hodil funkciu
    imagecolordeallocate($obrazok, $farba);
    a potom som si zasa do premennej $farba zadefinoval tú čiernu a už to fachčí

    Code:
    <?php
    header('Content-Type: image/png');
    $im = imagecreatefrompng('1.png');
    $text = 'Zľavy';
    $font = 'arial.ttf';
    $cerna = imagecolorallocate($im, 0, 0, 0); //definovanie hociakej farby
    imagecolordeallocate($im, $cerna); //undefinovanie farby :D
    $cerna = imagecolorallocate($im, 0, 0, 0); // a znova defiovanie :D
    imagettftext($im, 7, 10, 20, 20, $cerna, $font, $text);
    imagepng($im);
    imagedestroy($im);
    ?>

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts