I have an image that's dynamically generated. I need to apply an alpha gradient to this image so that it 'fades out' at the edges. How can I do this?
To illustrate things a bit here are some pictures. Let's say I have an image and a background;
I need to fade in the edges of the image, and then draw it onto the background. If the background were, say, entirely white, then I could 'fake' this fading effect by drawing a pre-created white quad with a linear gradient over the image at each end, like this:
If the background is another image however then I obviously can't do this, because I end up with something like this:
What I'd like to be ending up with is this:
...but I don't know how I can manage that. I'm using LibGDX if that matters, but I suppose this is a framework-agnostic question really?