I'm trying to just draw a string over an existing image loaded from disk.

I'm using the GD module from cpan.

I managed to draw the string fine, but the string shows in this weird transparent like color instead of plain black. I see the POD for colorAllocate and colorExact but I really don't get what theyr'e supposed to do, and how I should draw a black coloured string?

This is my code:

$to_print = "some string"; my $im = newFromJpeg GD::Image("somefile.jpg"); my $black = $im->colorExact(0,0,0); #also tried $im->colorAllocate(0,0,0); $im->stringFT($black, '/Open_Sans/OpenSans-Bold.ttf' ,12, 0, 100, 50, +$to_print);

The color returned is also a -1, So what is the right way to set black as a color?

It just prints a wierd transparent color, that looks a lot like the background of the image. (The background is a texture). And changing the RGB values doesn't help in any way!

Any help appreciated! :)


In reply to how can I set a real color while drawing text with GD by gideondsouza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.