Java HTML HTMLToTriplet(String color)

Here you can find the source of HTMLToTriplet(String color)

Description

HTML To Triplet

License

Open Source License

Declaration

private static byte[] HTMLToTriplet(String color) 

Method Source Code

//package com.java2s;

public class Main {
    private static byte[] HTMLToTriplet(String color) {
        final int offset = color.charAt(0) == '#' ? 1 : 0;
        final short red = Short.parseShort(color.substring(offset + 0, offset + 2), 16); //red
        final short green = Short.parseShort(color.substring(offset + 2, offset + 4), 16); //green
        final short blue = Short.parseShort(color.substring(offset + 4, offset + 6), 16); //blue
        final byte r = (byte) (red & 0xff);
        final byte g = (byte) (green & 0xff);
        final byte b = (byte) (blue & 0xff);
        return new byte[] { r, g, b };
    }/*ww w .  j  a  va 2  s .  c  om*/
}

Related

  1. htmlSafe(String value)
  2. htmlSize(String str)
  3. htmlString(String str)
  4. htmlText(String text)
  5. HTMLtoRGB(String htmlColor)
  6. htmlWrap(String text)
  7. htmlWrap(StringBuilder s)