Here you can find the source of toColor(short rgb565)
Parameter | Description |
---|---|
rgb565 | the color in RGB565 format. |
public static Color toColor(short rgb565)
//package com.java2s; /**//w ww.ja va 2 s. c o m * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://robocode.sourceforge.net/license/epl-v10.html */ import java.awt.*; public class Main { /** * Return a Color based on a color in RGB565 format. * * @param rgb565 the color in RGB565 format. * @return a Color based on the specifed color in RGB565 format. */ public static Color toColor(short rgb565) { if (rgb565 == 0) { return null; } if (rgb565 == 0x20) { return Color.BLACK; } return new Color(255 * ((rgb565 & 0xF800) >> 11) / 31, 255 * ((rgb565 & 0x07e0) >> 5) / 63, 255 * (rgb565 & 0x001f) / 31); } }