Jump to content

Getting gdlib's floodfill to work with alpha?


feuerfalke

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.