• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting an RGB color back into an 16-bit-per-channel color
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting an RGB color back into an 16-bit-per-channel color


  • Subject: Re: Converting an RGB color back into an 16-bit-per-channel color
  • From: Chris Page <email@hidden>
  • Date: Mon, 15 Aug 2011 01:25:54 -0700

On Aug 13, 2011, at 5:21 PM, Jim Thorton wrote:

Hola.  I know that I can use AppleScript to open the Color Picker window.  If the user picks a color, you will get a 16-bit-per-channel color like {52428, 54484, 45232}.  If you want to manually convert this color into an 8-bit-per-channel color for an RGB color, I guess you need to divide each component by 256.  Well, I would get RGB(204,212,176).  And that's what I get if I select RGB Sliders from the color sliders drop-down menu.  But you can never convert this RGB color back into what it was.  If you multiple each component by 256, you would get {52224,54272,45056}, which differs from the original color.

Is there any way to convert an RGB color back into the original 16-bit-per-channel color?

Well, you obviously can't recover information lost from the down-conversion to 8-bits, but the standard way to convert from 8- to 16-bits per component is to copy the byte into the high byte of the 16-bit value. e.g., 0x03 becomes 0x0303, 0xFE becomes 0xFEFE. The reason to do this is so that the 8-bit values 0 through 255 (0xFF) produce 16-bit values 0 to 65,535 (0xFFFF) with an even distribution of values.

Multiply the 8-bit value by 256 to shift it left by eight bits, then add it to the original 8-bit value to get the appropriate 16-bit value.

-- 
Chris Page

 The other, other AppleScript Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Converting an RGB color back into an 16-bit-per-channel color
      • From: Ron Hunsinger <email@hidden>
References: 
 >Converting an RGB color back into an 16-bit-per-channel color (From: Jim Thorton <email@hidden>)

  • Prev by Date: Re: Scrolling in Lion
  • Next by Date: Re: Converting an RGB color back into an 16-bit-per-channel color
  • Previous by thread: Re: Converting an RGB color back into an 16-bit-per-channel color
  • Next by thread: Re: Converting an RGB color back into an 16-bit-per-channel color
  • Index(es):
    • Date
    • Thread