Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitmap on Bitmap Transparency #71

Open
sdreb3421 opened this issue Aug 29, 2021 · 3 comments
Open

Bitmap on Bitmap Transparency #71

sdreb3421 opened this issue Aug 29, 2021 · 3 comments

Comments

@sdreb3421
Copy link

When using the DrawBitmap method to draw one bitmap over another, all semi-transparent pixels show up as fully opaque.

g.DrawBitmap(backImage, this.ClientRectangle);
g.DrawBitmap(frontImage, new D2DRect(0, 0, frontImage.Width, frontImage.Height), 1, D2DBitmapInterpolationMode.Linear);

image

@jingwood
Copy link
Owner

Did you have try the alpha channel option?

If your backImage and frontImage are GDI bitmaps, call drawBitmap and pass true to enable alpha channel.

g.DrawGDIBitmap(..., alpha: true, ...);

If your backImage and frontImage are Direct2D Bitmaps, pass true to enable alpha channel when you convert them.

var d2dbmp = Device.CreateBitmapFromGDIBitmap(..., useAlphaChannel: true);

@sdreb3421
Copy link
Author

We are using Direct2D Bitmaps and the alpha channel is set to true.

If the alpha channel is set to false, all transparent pixels in the overlayed image are opaque. If set to true, the fully transparent pixels are transparent, but semi transparent pixels are fully opaque (incorrect layering).

For example, in the image above the coordinate system arrows are surrounded with semi transparent pixels that are showing up as fully opaque whitish pixels. When drawn with GDI+ these are not white.

@d2phap
Copy link

d2phap commented Jan 1, 2022

I also have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants