unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
To: Steve Purcell <steve@sanityinc.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Bozhidar Batsov <bozhidar@batsov.com>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: sRGB color support in NS port [PATCH]
Date: Sat, 21 Dec 2013 17:16:00 +0100	[thread overview]
Message-ID: <3C0A35C3-5D2B-4E6A-9C63-9EE98056DC3A@swipnet.se> (raw)
In-Reply-To: <933E75DF-F665-46C0-8D82-111186A809B1@sanityinc.com>

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 <steve@sanityinc.com>:

> commit 3b63b2c6e9e93adab09eace60750ed981a8e528f
> Author: Steve Purcell <steve@sanityinc.com>
> 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];




  parent reply	other threads:[~2013-12-21 16:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 17:41 sRGB color support in NS port Bozhidar Batsov
2013-12-20 18:04 ` Steve Purcell
2013-12-20 18:13   ` Eli Zaretskii
2013-12-20 18:55     ` Jan Djärv
2013-12-20 20:19       ` Bozhidar Batsov
2013-12-21 14:10         ` sRGB color support in NS port [PATCH] Steve Purcell
2013-12-21 14:59           ` Bozhidar Batsov
2013-12-21 16:16           ` Jan Djärv [this message]
2013-12-21 17:37             ` Steve Purcell
2013-12-21 18:10               ` Jan Djärv
2013-12-21 19:59                 ` Steve Purcell
2013-12-21 20:26               ` David De La Harpe Golden
2013-12-21 21:11                 ` Steve Purcell
2013-12-22  0:31                 ` Stephen J. Turnbull
2013-12-22 13:55                   ` Steve Purcell
2013-12-22 21:20                   ` David De La Harpe Golden
2013-12-22 21:32                     ` Jan Djärv
2013-12-22 22:41                       ` David De La Harpe Golden
2013-12-22 23:52                         ` Jan Djärv
2013-12-23 12:42                     ` Stephen J. Turnbull
2013-12-24 10:56                       ` Steve Purcell
2013-12-26  9:45                         ` Julien Danjou
2013-12-26 12:12                           ` Steve Purcell
2013-12-26 18:07                             ` Steve Purcell
2013-12-20 20:21       ` sRGB color support in NS port Steve Purcell
2013-12-20 18:12 ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C0A35C3-5D2B-4E6A-9C63-9EE98056DC3A@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=bozhidar@batsov.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=steve@sanityinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).