Jump to content

Scratchsurface Alpha


JohnnyBlueBird

Recommended Posts

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?

Link to comment
Share on other sites

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.

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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 by JohnnyBlueBird
Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

28 minutes ago, JohnnyBlueBird said:

I was previously calling without the color specified.

 

Without the color argument, it clears the surface to (opaque) white.

Link to comment
Share on other sites

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.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...