PHP4 and graphics/transparency

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Kochendoerfer

    PHP4 and graphics/transparency

    Hi,
    I'm pretty new to PHP but I learnt how to build button-like graphics from
    graphic fragments (buttons adjusting themselves automatically on text
    size).
    All the fragments (left, right and middle parts of the button) I have are
    ..png or .jpg files since PHP doesn't support .gif any longer. But here's my
    problem. There's an area within each graphic having to be transparent when
    it is displayed. For example, the buttons are slightly rounded, and the
    reminder of the rectangular area should get the colour of the current
    background. I seem I can't accomplish it without help from an expert.

    Second question in this regard: How can I pass a HTML-like colour value
    (i.e. "0xA030BF" or "#A030BF") to the function ImageTTFText()? Docs say
    that I have to use ImageColorAlloc ate() for each one colour in the graphic.
    But it should be easier to pass a text colour along with the text itself to
    the button creation function.

    Thanks for all your help - any answer is greatly appreciated!

    Michael
  • Justin Koivisto

    #2
    Re: PHP4 and graphics/transparency

    Michael Kochendoerfer wrote:[color=blue]
    > All the fragments (left, right and middle parts of the button) I have are
    > .png or .jpg files since PHP doesn't support .gif any longer. But here's my
    > problem. There's an area within each graphic having to be transparent when
    > it is displayed. For example, the buttons are slightly rounded, and the
    > reminder of the rectangular area should get the colour of the current
    > background. I seem I can't accomplish it without help from an expert.[/color]

    I haven't dealt with this stuff yet, but I have done some reading a
    while back. Take a look at this function:


    --
    Justin Koivisto - spam@koivi.com
    PHP POSTERS: Please use comp.lang.php for PHP related questions,
    alt.php* groups are not recommended.

    Comment

    • Michael Kochendoerfer

      #3
      Re: PHP4 and graphics/transparency

      Justin Koivisto <spam@koivi.com > wrote in
      news:2TCAc.1901 $m3.98245@news7 .onvoy.net:
      [color=blue]
      > Michael Kochendoerfer wrote:[color=green]
      >> All the fragments (left, right and middle parts of the button) I have
      >> are .png or .jpg files since PHP doesn't support .gif any longer. But
      >> here's my problem. There's an area within each graphic having to be
      >> transparent when it is displayed. For example, the buttons are
      >> slightly rounded, and the reminder of the rectangular area should get
      >> the colour of the current background. I seem I can't accomplish it
      >> without help from an expert.[/color]
      >
      > I haven't dealt with this stuff yet, but I have done some reading a
      > while back. Take a look at this function:
      > http://www.php.net/manual/en/functio...ransparent.php[/color]

      Justin,

      thanks very much - there are several helpful hints. I have to normalize the
      color palette of my graphics first :)

      Do you have also an idea to my second question?

      Thx,
      Michael

      Comment

      • Andy Hassall

        #4
        Re: PHP4 and graphics/transparency

        On 18 Jun 2004 13:40:27 GMT, Michael Kochendoerfer <mk@isp.hem.d e> wrote:
        [color=blue]
        >Second question in this regard: How can I pass a HTML-like colour value
        >(i.e. "0xA030BF" or "#A030BF") to the function ImageTTFText()? Docs say
        >that I have to use ImageColorAlloc ate() for each one colour in the graphic.
        >But it should be easier to pass a text colour along with the text itself to
        >the button creation function.[/color]

        substr and hexdec would cover splitting the hex string into RGB components.
        You could then use imagecolorexact to get a palette entry.
        If it returns -1, then actually allocate a new one with imagecoloralloc ate.

        Or have an array somewhere acting as a cache for the last couple of steps.
        Then just wrap that in a function.

        --
        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

        Comment

        Working...