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

Incorrect alpha treatment when RenderToImageBegin...End over transparent background #586

Open
eugeneloza2factor opened this issue Mar 27, 2024 · 0 comments

Comments

@eugeneloza2factor
Copy link

When using RenderToImageBegin...RenderToImageEnd and the image is transparent, alpha is treated incorrectly.

Expected result:

2024-03-27 07_26_04-Greenshot

Current result:

2024-03-27 07_25_48-Greenshot

Minimal reproduction (all code in Start):

offscreen-render-alpha.zip

BlackTransparentBackground := TRGBAlphaImage.Create(900, 300);
BlackTransparentBackground.Clear(Vector4(0, 0, 0, 0)); // using Vector4(0, 0, 0, 1) fixes the bug, but disallows transparent background
WhiteBox := TRGBAlphaImage.Create(200, 200);
WhiteBox.Clear(Vector4(1, 1, 1, 1));

BackgroundDrawable := TDrawableImage.Create(BlackTransparentBackground, true, true);
WhiteBoxDrawable := TDrawableImage.Create(WhiteBox, true, true);

BackgroundDrawable.RenderToImageBegin;
WhiteBoxDrawable.Color := Vector4(1, 1, 1, 0.9);
WhiteBoxDrawable.Draw(50, 50);
WhiteBoxDrawable.Color := Vector4(1, 1, 1, 0.6);
WhiteBoxDrawable.Draw(250, 50);
WhiteBoxDrawable.Color := Vector4(1, 1, 1, 0.4);
WhiteBoxDrawable.Draw(450, 50);
WhiteBoxDrawable.Color := Vector4(1, 1, 1, 0.1);
WhiteBoxDrawable.Draw(650, 50);
BackgroundDrawable.RenderToImageEnd;
@eugeneloza2factor eugeneloza2factor changed the title But when RenderToImageBegin...End over transparent background Incorrect alpha treatment when RenderToImageBegin...End over transparent background Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant