Java RGB Color Convert To RGBtoBGR(String color)

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

Description

Converts RGB (ARBG) color to BGR (ABGR).

License

Apache License

Parameter

Parameter Description
color RGB/ARGB color string

Return

Converted color

Declaration

public static String RGBtoBGR(String color) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from   w w w.  ja  va  2  s .com*/
     * Converts RGB (ARBG) color to BGR (ABGR).
     * If color is without alpha - makes alpha "FF".
     *
     * @param color RGB/ARGB color string
     * @return Converted color
     */
    public static String RGBtoBGR(String color) {
        if (color.length() == 6) {
            color = "FF" + color;
        }
        if (color.length() == 8) {
            return color.substring(0, 2) + color.substring(6, 8) + color.substring(4, 6) + color.substring(2, 4);
        }
        return color;
    }
}

Related

  1. rgbaToColor(int r, int g, int b, int a)
  2. rgbaToHex(String color)
  3. RGBAtoI(byte r, byte g, byte b, byte a)
  4. rgbBitfieldToString(int rgb)
  5. rgbToBgr(final byte[] pixels)
  6. rgbToBlackWhite(int pix, int threshold)
  7. rgbToColor(int r, int g, int b)
  8. rgbToDecimal(int r, int g, int b)
  9. rgbToGray(int colorIn)