Here you can find the source of rgbToShort(int rgb)
public static short rgbToShort(int rgb)
//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)); } }