By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

PHP4 and graphics/transparency

P: n/a
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 ImageColorAllocate() 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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Michael Kochendoerfer wrote:
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.


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

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #2

P: n/a
Justin Koivisto <sp**@koivi.com> wrote in
news:2T*****************@news7.onvoy.net:
Michael Kochendoerfer wrote:
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.


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


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

Jul 17 '05 #3

P: n/a
On 18 Jun 2004 13:40:27 GMT, Michael Kochendoerfer <mk@isp.hem.de> wrote:
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 ImageColorAllocate() 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.


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 imagecolorallocate.

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

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.