emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sRGB color support in NS port [PATCH]


From: Jan Djärv
Subject: Re: sRGB color support in NS port [PATCH]
Date: Sat, 21 Dec 2013 17:16:00 +0100

Hello.

This has been done in another way in trunk.
Customize ns-use-srgb-colorspace to use sRGB.  Default is to use calibrated 
space.

Note that images still don't use sRGB color space.  Nor do they with the patch 
below.
Also, this is not what the documentation says is the right way to display 
colors on OSX.

        Jan D.


21 dec 2013 kl. 15:10 skrev Steve Purcell <address@hidden>:

> commit 3b63b2c6e9e93adab09eace60750ed981a8e528f
> Author: Steve Purcell <address@hidden>
> Date:   Sat Dec 21 11:44:12 2013 +0000
> 
>    Treat hex colors as sRGB under OS X >= 10.7
> 
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 733c05a..0c79186 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -1373,6 +1373,13 @@ ns_fullscreen_hook (struct frame *f)
>     Color management
> 
>    ========================================================================== 
> */
> +#if defined(NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 
> MAC_OS_X_VERSION_10_7
> +#define NS_COLOR_FROM_RGB(r, g, b) [NSColor colorWithSRGBRed: r green: g 
> blue: b alpha: 1.0]
> +#define NS_COLOR_AS_RGB(c) [c colorUsingColorSpace: [NSColorSpace 
> sRGBColorSpace]]
> +#else
> +#define NS_COLOR_FROM_RGB(r, g, b) [NSColor colorWithCalibratedRed: r green: 
> g blue: b alpha: 1.0]
> +#define NS_COLOR_AS_RGB(c) [c colorUsingColorSpaceName: 
> NSCalibratedRGBColorSpace]
> +#endif
> 
> 
> NSColor *
> @@ -1551,7 +1558,7 @@ ns_get_color (const char *name, NSColor **col)
> 
>   if (r >= 0.0F)
>     {
> -      *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0];
> +      *col = NS_COLOR_FROM_RGB(r, g, b);
>       unblock_input ();
>       return 0;
>     }
> @@ -1583,7 +1590,7 @@ ns_get_color (const char *name, NSColor **col)
>   }
> 
>   if (new)
> -    *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
> +    *col = NS_COLOR_AS_RGB(new);
>   unblock_input ();
>   return new ? 0 : 1;
> }
> @@ -1624,7 +1631,7 @@ ns_color_to_lisp (NSColor *col)
>           return build_string ((char *)str);
>         }
> 
> -    [[col colorUsingColorSpaceName: NSCalibratedRGBColorSpace]
> +      [NS_COLOR_AS_RGB(col)
>         getRed: &red green: &green blue: &blue alpha: &alpha];
>   if (red ==green && red ==blue)
>     {
> @@ -4252,10 +4259,9 @@ ns_term_init (Lisp_Object display_name)
>             name = SSDATA (XCAR (color));
>             c = XINT (XCDR (color));
>             [cl setColor:
> -                  [NSColor colorWithCalibratedRed: RED_FROM_ULONG (c) / 255.0
> -                                            green: GREEN_FROM_ULONG (c) / 
> 255.0
> -                                             blue: BLUE_FROM_ULONG (c) / 
> 255.0
> -                                            alpha: 1.0]
> +                  NS_COLOR_FROM_RGB(RED_FROM_ULONG (c) / 255.0,
> +                                    GREEN_FROM_ULONG (c) / 255.0,
> +                                    BLUE_FROM_ULONG (c) / 255.0)
>                   forKey: [NSString stringWithUTF8String: name]];
>           }
>         [cl writeToFile: nil];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]