Jump to content

ColorBgra.ToOpaqueInt32() can't take transparency... why?


Recommended Posts

System.InvalidOperationException: Alpha value must be 255 for this to work
  at PaintDotNet.ColorBgra.ToOpaqueInt32(ColorBgra color)

Seems silly to me. Doesn't the name imply that int32 returned will be of the opaque version of the input color? It doesn't make sense that it should require an already-opaque color. Maybe I'm just being naive... :roll:

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

The To/From Opaque functions were really only added for use with the IndirectUI color wheel control.

The reason it requires an alpha value of 255 is because that is the only unambiguous case for conversion. If alpha is 128, then there are different methods of transforming the R,G,B values ... do you pre-multiply or not, etc.? The end result is an opaque color but may not be the one that was desired. By requiring A=255, there is simply no ambiguity. If you need a different conversion method, it is easy enough to implement it yourself.

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

Normally I wouldn't have even bothered with a post about it; I'd just have written my own implementation and that would be that. In this case, though, I made a bad assumption, implemented it, didn't bother testing, and managed to have Ash make it crash :roll:

DOH!

See, c'mon man, there's usually a method to my madness :twisted:

...usually... ;)

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Moved to Effects API.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

But it isn't anymore! That's why I didn't chide you. :-)

EDIT: You done with this?

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

Please, pester on!

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

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...