JohnnyBlueBird Posted June 9, 2020 Posted June 9, 2020 If I check a transparent pixel in PDN, it shows the correct value of 255, 255, 255, 0. However, the alpha returned by scratchSurface[x, y].A is 255. Is there something simple I'm missing? Quote
toe_head2001 Posted June 9, 2020 Posted June 9, 2020 Your scratchSurface Surface probably doesn't contain the same values as the src Surface. Did you copy the values over? You'll need to post your code to get any further help. Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab
JohnnyBlueBird Posted June 9, 2020 Author Posted June 9, 2020 (edited) Sorry, I should have included more detail - this is for a custom FileType plugin which loads the image just fine, it's when attempting to save I'm having trouble. I set the pixel like this: layer.Surface[x_pos, y_pos] = ColorBgra.Transparent; Which both displays and 'eye drops' correctly. if (scratchSurface[x, y].A == 0) This just returns 255, despite PDN clearly showing and displaying A=0 I'm also iterating through multiple layers so not sure if this is the right way to do so? foreach (Layer layer in input.Layers) Edited June 9, 2020 by JohnnyBlueBird Quote
MJW Posted June 9, 2020 Posted June 9, 2020 I think you probably need to post more of the code than those two unconnected snippets. Perhaps it's just my lack of experience with FileType plugins, but the relationship between layer.Surface and scratchSurface isn't apparent. EDIT: A search reveals that scratchSurface is a pre-allocated surface for the programmer's convenience. However, that's all that it is: just a temporary surface to be used as the programmer wishes. Perhaps you are incorrectly assuming it will be modified if the layer surface is modified. If you haven't specially written into scatchSurface, it will contain whatever it happened to contain when it was allocated for you. 1 Quote
JohnnyBlueBird Posted June 9, 2020 Author Posted June 9, 2020 Perhaps an actual help document would help but this solved the issue for me: args.Surface.Clear(ColorBgra.Transparent); I was previously calling without the color specified. Quote
MJW Posted June 9, 2020 Posted June 9, 2020 28 minutes ago, JohnnyBlueBird said: I was previously calling without the color specified. Without the color argument, it clears the surface to (opaque) white. Quote
Rick Brewster Posted June 9, 2020 Posted June 9, 2020 Please don't use scratchSurface if you can. It's been deprecated and you should not rely on its existence, or that it's been pre-filled with anything in particular. The FileType class* will be evolving over time to reflect this. It's not like you can't use it (scratchSurface), I just would prefer plugins to pretend like it doesn't exist. * or whatever it evolves into, or whatever replaces it, etc. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
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.