Page 1 of 1

transparency problems

Posted: Tue May 01, 2007 11:24 am
by izua
Hi guys, thanks for the forum!
Name's Richard, ~2 years experience in php (self taught, which means i mostly suck). I'm some random dude from romania.

I'm posting here cause i have some sort of problem with overlaying a shape over text. I'll try to explain as good as I can, sorry for bad english or repetitions - i'm not native english speaker. Basically, i write text out on a white background, and I overlay a shape from a PNG over it. Where that shape intersects text, text should change color. If it intersects with the background, it shouldn't do anything.

I've made this image http://izua.zephyrhosting.net/lighten.png that's supposed to be overlaid over random text. The end result should be the initial text, with the same colors, but where the higher alpha value exists, the text should be darker. Just the text!

This is what i get, though:
http://izua.zephyrhosting.net/gradient.png

I'm not sure what is wrong in my way of thinking, but definitely something is wrong. I believe I have to give a transparent color to compensate for the transparency in the mask layer? not sure.

Text is written on white, with imagettftext. Basically, whereever the initial image is white, the end image should be white. If there was text, that shape should be applied, to modify the color. I have used imagecopymerge to mix the two images.

Using php5 on my local server, btw

thanks!

Posted: Wed May 02, 2007 10:26 am
by dbevfat
I'm trying really hard to understand what you want to achieve. :wink: To my understanding, you're trying to brighten up a certain area of text, but not the background. Which means, you have to use a fully transparent background of the text. Before you write the text on the image, fill it with a newly created color (imagecolorallocatealpha) with alpha=127.