colour lib

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 2 10:25:31 PDT 2016


Am Fri, 2 Sep 2016 15:58:05 +1000
schrieb Manu via Digitalmars-d <digitalmars-d at puremagic.com>:

> On 2 September 2016 at 06:09, Marco Leise via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
> > I'd suspect #1 to be the best option, too. However, I don't
> > know when users will deal with these calculations.  
> 
> Neither do I, it's just that NormalizedInt is a type, it's a
> dependency, it exists, it needs an api, so it needs to be well defined
> I guess.

*nods*

> I wonder, should NormalizedInt be a module beneath the color package,
> or should it be a separate module in its own right?
> I don't know of uses for that type outside packed colours, but it
> could theoretically be used for anything...

I guess audio sample would be a perfect match for signed and
unsigned normalized integers.
 
> > Surely adding sRGB(22,22,22) + sRGB(11,11,11) gives sRGB(28, 28, 28),
> > with a higher precision while performing the addition and then
> > rounding back.  
> 
> Umm, no. I think operations should be within their own colourspace,
> otherwise what's the point of selecting your working colourspace?
> You need to be able to do operations in gamma space too. If you want
> to do a linear operation, cast to a linear type before doing the
> operation.

So it is not a library that unifies color spaces into working
with light intensities, but more of a library to perform
linear blending directly in the color-space.
That means when I add two HSV colors of the same ubyte hue
= 200, the result will have hue == 144, right ?
 
> > Anything requiring multiple operations on an
> > image should use a higher precision linear color space from
> > the start.  
> 
> Right, I think you would typically cast from the storage type to the
> working type before doing some work. But there are so many cases, and
> various levels of tradeoff between efficiency and correct-ness, the
> lib can't make presumptions.
> The way it is currently, the operations are done in the typed
> colourspace. Simple as that. If you want to do linear operations, cast
> to a linear type first.

Ok, might be worth it for people new to color spaces to
highlight the fact that RGB is not linear and what that means
for operations like brightness or contrast change. I've seen a
hobbyist write a 3D engine and after he had deferred
rendering, flash lights & shadows, scripting and animations,
he stumbled over an article about screen gamma and why it
matters. My first attempts at image manipulation show the same
ignorance.

-- 
Marco



More information about the Digitalmars-d mailing list