Java RGB Color Convert To rgbToShort(int rgb)

Here you can find the source of rgbToShort(int rgb)

Description

Converts a 24 bit RGB value to a 15 bit RGB value.

License

Apache License

Declaration

public static short rgbToShort(int rgb) 

Method Source Code

//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /**/*from  w ww. j a  v  a 2 s  . c o m*/
     * Converts a 24 bit RGB value to a 15 bit RGB value.
     * eg.
     * 111100001111000011110000 becomes 111101111011110
     */
    public static short rgbToShort(int rgb) {
        return (short) (((rgb & 0xf8) >> 3) | ((rgb & 0xf800) >> 6) | ((rgb & 0xf80000) >> 9));
    }
}

Related

  1. RGBToInt(float[] rgb)
  2. RGBtoInt(int r, int g, int b)
  3. RGBtoInt(int red, int green, int blue)
  4. RGBtoInt(String rgb)
  5. RGBToInteger(int red, int green, int blue)
  6. rgbToString(float r, float g, float b)
  7. rgbToText(int red, int green, int blue)
  8. rgbToUnscaledYUV(int[][] rgb)
  9. RGBtoXYZ(float r, float g, float b)