Skip to content

bitmaptools: alpha blend with mask #11023

@makermelissa

Description

@makermelissa

I've been thinking about this quite a bit and I have an idea that would be a very useful feature.

So, here's the problem. Let's say you have 2 images that you want to combine together and one has anti-aliasing. For this example, I'm going to use some images from chess.com. The 2 images that I'd like to combine are:

Image

and

Image

With the way the tools available are now, you could define a single index color to skip. So, let's say we assign the most apparent color white as #FF00FF for index skipping purposes and we get:

Image

When we blit (or blend) them with the ignore index set to the color of #FF00FF, we get the following result:

Image

Now, a big part of this limitation is the fact that CircuitPython displayio bitmaps can only have a single color of transparency. One workaround I've used with CircuitPython is pre-blending the images, but there's only so many variations you can make before the number of combinations grows exponentially.

Now, what my idea is (and this is something we used to do back when I was working with Pocket PCs) is to provide a grayscale mask image to represent the amount of opacity with 0 being fully transparent and 255 being fully opaque. This would look something like:

Image

By using the mask image in conjunction with the 2 other images, we can get a result that looks like this:

Image

I can probably write something up, but I wanted to open an issue with my idea in case anybody else would like to take it on.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions