feuerfalke Posted September 3, 2007 Share Posted September 3, 2007 Hey. Let me describe my situation briefly: I have a PNG image with a single RGB value present in it; the rest of the picture is transparent. The edges of the shape in the image are antialiased, so there are varying degrees of alpha in the picture. What I want to do is change the colour of the shape in the picture to a different RGB value. I want to leave the alpha channel alone, however. There are two approaches (so far) that I can use to handle this. The first approach I used was to loop through each pixel and edit its RGB values, leaving the alpha channel alone accordingly. As you might imagine this process puts an incredible strain on the server and it's a method I want to avoid. The second method is to use GDlibrary's flood fill function, somehow. When I used it I was hoping that it would fill on the basis of the RGB values alone, and that it would ignore the alpha value; apparently this is not the case. I'm wondering if there is a way to use flood fill to change the colour of all of the pixels, and preserve transparency at the same time. The image resource I am using has AlphaBlending and SaveAlpha enabled. I don't think providing the source code is necessary but I will if it is requested. My only other option, if using flood fill is not a possibility, is to modify the source code of gdlib to do what I want, I think. Quote Link to comment https://forums.phpfreaks.com/topic/67740-getting-gdlibs-floodfill-to-work-with-alpha/ Share on other sites More sharing options...
Barand Posted September 3, 2007 Share Posted September 3, 2007 Have you looked at changing the pallette instead of the image? Quote Link to comment https://forums.phpfreaks.com/topic/67740-getting-gdlibs-floodfill-to-work-with-alpha/#findComment-340336 Share on other sites More sharing options...
feuerfalke Posted September 3, 2007 Author Share Posted September 3, 2007 Just tried it using imagecolorexactalpha()/imagecolorexact() and imagecolorset(). Didn't work. Good idea, though... Quote Link to comment https://forums.phpfreaks.com/topic/67740-getting-gdlibs-floodfill-to-work-with-alpha/#findComment-340534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.