dcgamers Posted February 1, 2008 Share Posted February 1, 2008 I can draw text over an image now but How can I draw a 50% semi-transparent object over the image, yet under the text? Link to comment https://forums.phpfreaks.com/topic/88917-gd-library-draw-transparent-rectangle-then-text-over-it/ Share on other sites More sharing options...
helraizer Posted February 1, 2008 Share Posted February 1, 2008 Well, create the image as you said you have then create a rectangle <?php ImageCreate(600,300); ?> fill it with colour etc.. then write the text onto that image. Then use <?php ImageCopyMerge($image, $im, dst_x, dst_y, src_x, src_y, src_w, src_h, 50); ?> Where $image is the original image and $im is the new rectangle. Hope that helps, Sam Link to comment https://forums.phpfreaks.com/topic/88917-gd-library-draw-transparent-rectangle-then-text-over-it/#findComment-455472 Share on other sites More sharing options...
dcgamers Posted February 1, 2008 Author Share Posted February 1, 2008 how is image copy merge going to help? And I said 50% transparent. I mean a rectangle inside an ALREADY created image, of course the image itself is a rectangle. Link to comment https://forums.phpfreaks.com/topic/88917-gd-library-draw-transparent-rectangle-then-text-over-it/#findComment-455482 Share on other sites More sharing options...
Barand Posted February 1, 2008 Share Posted February 1, 2008 Create a semi tranparent colour with imagecolorallocatealpha() then imagefilledrectangle() using that colour. Link to comment https://forums.phpfreaks.com/topic/88917-gd-library-draw-transparent-rectangle-then-text-over-it/#findComment-455533 Share on other sites More sharing options...
helraizer Posted February 1, 2008 Share Posted February 1, 2008 how is image copy merge going to help? And I said 50% transparent. I mean a rectangle inside an ALREADY created image, of course the image itself is a rectangle. Well, you first said "How can I draw a 50% semi-transparent object over the image" -therefore I assumed you meant a new object (a new image, a new rectangle!) which is where image create comes in.. then if you fill the rectangle with a colour you have the original image and that one.. then use image copy merge to have the new image over the old image. "And I said 50% transparent" - that's where the 50 at the end of the Image Copy Merge function I quoted. 100 will be solid colour just the object slap bang onto the image; 0 would be non-existant so 50 will be in between, it will be semi-transparent. But either way, try Barand's idea too. Sam Link to comment https://forums.phpfreaks.com/topic/88917-gd-library-draw-transparent-rectangle-then-text-over-it/#findComment-455564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.