Skysworld Posted June 12, 2023 Share Posted June 12, 2023 (edited) This plugin will take the brightness of the pixels in an image, and make them transparent based on the values from the GUI. located in Effects > Transparency It was created to take different exposure images and combine them into a sort of HDR image. It's pretty simple in concept so I'll give an example of how I use the plugin. High, Mid, and Low exposure images: On the high-exposure image, I make the bright pixels transparent so that I have detail in the dark areas. And on the low-exposure image, I make the dark pixels transparent so that I have detail in the bright areas. Then I merge those layers (just "Normal" layer blend mode) onto the mid-exposure image. In the end, I have a photo with more dynamic range than what my basic phone camera could have gotten just on it's own. Download: SelectiveTransparency.zip CodeLabs Code: Spoiler // Name: Selective Transparency // Submenu: Transparency // Author: Skysworld // Title: Selective Transparency // Version: 1.0 // Desc: Make pixels transparent based on their brightness // Keywords: transparent|transparency // URL: https://forums.getpaint.net/profile/171721-skysworld/ // Help: https://forums.getpaint.net/profile/171721-skysworld/ #region UICode RadioButtonControl greatLess = 0; // Effect Pixels..|Greater Than|Less Than IntSliderControl intensity = 50; // [0,100,5] Brightness IntSliderControl thresh = 5; // [0,10] Threshold #endregion protected override void OnDispose(bool disposing) { if (disposing) { } base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { } void Render(Surface dst, Surface src, Rectangle rect) { //Loop through image's pixels for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { ColorBgra SrcPixel = src[x,y]; ColorBgra CurrentPixel; int newAlpha = SrcPixel.A; //===============Code Start=============== byte mostLumous; int pixelBrightness; mostLumous = SrcPixel.R; if (SrcPixel.G > mostLumous) { mostLumous = SrcPixel.G; } if (SrcPixel.B > mostLumous) { mostLumous = SrcPixel.B; } pixelBrightness = ((int)(mostLumous/2.55)); //===============Code Start=============== if (greatLess == 0) //Greater than { if (pixelBrightness > intensity) { newAlpha = (((int)SrcPixel.A) - Math.Abs(11-thresh)*((int)(pixelBrightness) - intensity)); if (newAlpha < 0) {newAlpha = 0;} } } else { //Less Than if (pixelBrightness < intensity) { newAlpha = (((int)SrcPixel.A) - Math.Abs(11-thresh)*(intensity - ((int)(pixelBrightness)))); if (newAlpha < 0) {newAlpha = 0;} } } //===============Code End=============== CurrentPixel = ColorBgra.FromBgra(SrcPixel.B, SrcPixel.G, SrcPixel.R, (byte)newAlpha); dst[x,y] = CurrentPixel; } } } Edited June 12, 2023 by Skysworld 7 1 Quote Link to comment Share on other sites More sharing options...
user.by Posted June 12, 2023 Share Posted June 12, 2023 Or with copy past 2 picture can be join in 1 picture at middle point, great job. Congrats. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted June 13, 2023 Share Posted June 13, 2023 18 hours ago, Skysworld said: protected override void OnDispose(bool disposing) { if (disposing) { } base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { } These two methods do literally nothing. You can just delete them from your source code. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.