Potentially introduce a new PixelColorBlendingMode.And value #341
Replies: 2 comments 5 replies
-
To add to this, here's some examples:
|
Beta Was this translation helpful? Give feedback.
-
There's something not right about your results there as they do not match the expected output. Here's example code of mine which generates each entry. using Image<Rgba32> src = Image.Load<Rgba32>(@"C:\Users\james\Downloads\src.png");
using Image<Rgba32> dst = Image.Load<Rgba32>(@"C:\Users\james\Downloads\dst.png");
foreach (var mode in Enum.GetValues<PixelAlphaCompositionMode>())
{
GraphicsOptions options = new()
{
AlphaCompositionMode = mode
};
using Image<Rgba32> res = dst.Clone(x => x.DrawImage(src, options));
res.Save(@$"C:\Users\james\Downloads\341-porter-duff\{mode}.png");
} And here's the output. (Ignore Clear, Windows 11 has a bug where explorer thumbnails of fully clear PNG files sometimes display as black) Which matches the examples from this article on Porter-Duff Compositing Operators from the University of Auckland. https://www.stat.auckland.ac.nz/~paul/Reports/GraphicsEngine/compositing/compositing.html
|
Beta Was this translation helpful? Give feedback.
-
It seems that the functionality for does not currently exist for drawing onto an image and only keeping the overlapping sections of the image with a polygon, or similar.
For example, my use case is that I have an image where I wish to make it transparent in a certain area. However, the contents of this image have a stroke/outline, so the stroke needs to be repositioned.
My idea was to clone the image and draw a polygon onto the cloned image, only take the overlapping areas. I would then draw the overlapping areas (from the cloned image) onto the original image in a different colour.
In regards to a possible new PixelColorBlendingMode.And with my examples below, the image would only contain either a red or a blue right angled triangle where they overlap (potentially even choosing between new PixelColorBlendingMode.SrcAnd and PixelColorBlendingMode.DestAnd values for this)
Sorry if I'm wrong here, but I'm not sure if the current PixelColorBlendingMode values all work correctly? I might be wrong and misunderstanding them here though, but here is my testing:
Image:
Polygon that gets drawn onto the image:
Here are the results:
I thought you'd have received something very different for either DestAtop or DestIn:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions