Check if the color space has a wide color gamut and is consistent with the Bitmap config
163107
private static boolean hasColorGamutMismatch(final BitmapFactory.Options options) {
    return options.outColorSpace != null
        && options.outColorSpace.isWideGamut()
        && options.inPreferredConfig != Bitmap.Config.RGBA_F16;
  }
1117141
public static boolean uniform(Color color, Pixel[] pixels) {
        return Arrays.stream(pixels).allMatch(p -> p.toInt() == color.toRGB().toInt());
    }
129432
def valid_color(x: str) -> bool:
    
    if isinstance(x, str) and re.match(COLOR_PATTERN, x):
        return True
    else:
        return False
1132887
private static BufferedImage checkInputs(ImageBase src, BufferedImage dst) {
		if (dst != null) {
			if (dst.getWidth() != src.getWidth() || dst.getHeight() != src.getHeight()) {
				throw new IllegalArgumentException("image dimension are different. src="
						+src.width+"x"+src.height+"  dst="+dst.getWidth()+"x"+dst.getHeight());
			}
		} else {
			dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB);
		}
		return dst;
	}
573612
function checkColorize() {
	if (defaultColorizeArg !== undefined) {
		return defaultColorizeArg;
	}
	// default is to only colorize if we have a TTY and not running on TTY
	defaultColorizeArg = process.stdout.isTTY && !process.env.TRAVIS;
	for (let c = 1; c < process.argv.length; c++) {
		const arg = process.argv[c];
		if (arg === '--colorize' || arg === '--color' || arg === '--colors') {
			defaultColorizeArg = true;
			break;
		} else if (arg === '--no-colors' || arg === '--no-color') {
			defaultColorizeArg = false;
			break;
		}
	}
	return defaultColorizeArg;
}
1043310
public static void checkReshapeB(ImageMultiBand<?> imgA, ImageMultiBand<?> imgB) {
		if( imgA == imgB )
			throw new IllegalArgumentException("Image's can't be the same instance");
		imgB.reshape(imgA.width,imgA.height,imgA.getNumBands());
	}
1171076
private void validateIfdLW(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    if (p == 1) {
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{1});
    if (p == 0) {
      checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{4});
    } else {
      checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{8});
    }
    checkRequiredTag(metadata, "Compression", 1, new long[]{32896});
    checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {5});
    checkRequiredTag(metadata, "StripOffsets", 1);
    if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    checkRequiredTag(metadata, "StripBYTECount", 1);
    checkRequiredTag(metadata, "XResolution", 1);
    checkRequiredTag(metadata, "YResolution", 1);
    if (p == 1 || p == 2) {
      checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
      checkRequiredTag(metadata, "InkSet", 1, new long[]{1});
      checkRequiredTag(metadata, "NumberOfInks", 1, new long[]{4});
    }
    if (p == 1) {
      checkRequiredTag(metadata, "DotRange", 2, new long[]{0, 255});
    }
    checkRequiredTag(metadata, "ColorTable", -1);
  }
986405
def is_valid_rgb_color(value):
    
    if not value:
        return False

    regex = re.compile(RGB_COLOR_REGEX)
    return bool(regex.match(value))
192860
private void CheckRGBImage(IfdTags metadata, int n) {
    // Samples per Pixel
    long samples = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
    if (samples < 3)
      validation.addError("Invalid Samples per Pixel", "IFD" + n, samples);

    // Compression
    long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
    // if (comp != 1 && comp != 32773)
    if (comp < 1)
      validation.addError("Invalid Compression", "IFD" + n, comp);
  }
1167397
def rgbmap_cb(self, rgbmap, channel):
        
        if not self.gui_up:
            return
        fitsimage = channel.fitsimage
        if fitsimage != self.fv.getfocus_fitsimage():
            return False
        self.change_cbar(self.fv, channel)
195244
def ok(self):
        """"""
        rgb, hsv, hexa = self.square.get()
        if self.alpha_channel:
            hexa = self.hexa.get()
            rgb += (self.alpha.get(),)
        self.color = rgb, hsv, hexa
        self.destroy()
886439
private static long getRgbFromColorConst( String str ) {
        long rgb;
        switch( str ) {
            case "aliceblue":
                rgb = 0xf000_f800_ff00L;
                break;
            case "antiquewhite":
                rgb = 0xfa00_eb00_d700L;
                break;
            case "aqua":
                rgb = 0xff00_ff00L;
                break;
            case "aquamarine":
                rgb = 0x7f00_ff00_d400L;
                break;
            case "azure":
                rgb = 0xf000_ff00_ff00L;
                break;
            case "beige":
                rgb = 0xf500_f500_dc00L;
                break;
            case "bisque":
                rgb = 0xff00_e400_c400L;
                break;
            case "black":
                rgb = 0x00;
                break;
            case "blanchedalmond":
                rgb = 0xff00_eb00_cd00L;
                break;
            case "blue":
                rgb = 0xFF00L;
                break;
            case "blueviolet":
                rgb = 0x8a00_2b00_e200L;
                break;
            case "brown":
                rgb = 0xa500_2a00_2a00L;
                break;
            case "burlywood":
                rgb = 0xde00_b800_8700L;
                break;
            case "cadetblue":
                rgb = 0x5f00_9e00_a000L;
                break;
            case "chartreuse":
                rgb = 0x7f00_ff00_0000L;
                break;
            case "chocolate":
                rgb = 0xd200_6900_1e00L;
                break;
            case "coral":
                rgb = 0xff00_7f00_5000L;
                break;
            case "cornflowerblue":
                rgb = 0x6400_9500_ed00L;
                break;
            case "cornsilk":
                rgb = 0xff00_f800_dc00L;
                break;
            case "crimson":
                rgb = 0xdc00_1400_3c00L;
                break;
            case "cyan":
                rgb = 0x0000_ff00_ff00L;
                break;
            case "darkblue":
                rgb = 0x0000_0000_8b00L;
                break;
            case "darkcyan":
                rgb = 0x0000_8b00_8b00L;
                break;
            case "darkgoldenrod":
                rgb = 0xb800_8600_0b00L;
                break;
            case "darkgray":
            case "darkgrey": //British
                rgb = 0xa900_a900_a900L;
                break;
            case "darkgreen":
                rgb = 0x0000_6400_0000L;
                break;
            case "darkkhaki":
                rgb = 0xbd00_b700_6b00L;
                break;
            case "darkmagenta":
                rgb = 0x8b00_0000_8b00L;
                break;
            case "darkolivegreen":
                rgb = 0x5500_6b00_2f00L;
                break;
            case "darkorange":
                rgb = 0xff00_8c00_0000L;
                break;
            case "darkorchid":
                rgb = 0x9900_3200_cc00L;
                break;
            case "darkred":
                rgb = 0x8b00_0000_0000L;
                break;
            case "darksalmon":
                rgb = 0xe900_9600_7a00L;
                break;
            case "darkseagreen":
                rgb = 0x8f00_bc00_8f00L;
                break;
            case "darkslateblue":
                rgb = 0x4800_3d00_8b00L;
                break;
            case "darkslategray":
            case "darkslategrey": //British
                rgb = 0x2f00_4f00_4f00L;
                break;
            case "darkturquoise":
                rgb = 0x0000_ce00_d100L;
                break;
            case "darkviolet":
                rgb = 0x9400_0000_d300L;
                break;
            case "deeppink":
                rgb = 0xff00_1400_9300L;
                break;
            case "deepskyblue":
                rgb = 0x0000_bf00_ff00L;
                break;
            case "dimgray":
            case "dimgrey": //British
                rgb = 0x6900_6900_6900L;
                break;
            case "dodgerblue":
                rgb = 0x1e00_9000_ff00L;
                break;
            case "firebrick":
                rgb = 0xb200_2200_2200L;
                break;
            case "floralwhite":
                rgb = 0xff00_fa00_f000L;
                break;
            case "forestgreen":
                rgb = 0x2200_8b00_2200L;
                break;
            case "fuchsia":
                rgb = 0xff00_0000_ff00L;
                break;
            case "gainsboro":
                rgb = 0xdc00_dc00_dc00L;
                break;
            case "ghostwhite":
                rgb = 0xf800_f800_ff00L;
                break;
            case "gold":
                rgb = 0xff00_d700_0000L;
                break;
            case "goldenrod":
                rgb = 0xda00_a500_2000L;
                break;
            case "gray":
            case "grey": //British
                rgb = 0x8000_8000_8000L;
                break;
            case "green":
                rgb = 0x0000_8000_0000L;
                break;
            case "greenyellow":
                rgb = 0xad00_ff00_2f00L;
                break;
            case "honeydew":
                rgb = 0xf000_ff00_f000L;
                break;
            case "hotpink":
                rgb = 0xff00_6900_b400L;
                break;
            case "indianred":
                rgb = 0xcd00_5c00_5c00L;
                break;
            case "indigo":
                rgb = 0x4b00_0000_8200L;
                break;
            case "ivory":
                rgb = 0xff00_ff00_f000L;
                break;
            case "khaki":
                rgb = 0xf000_e600_8c00L;
                break;
            case "lavender":
                rgb = 0xe600_e600_fa00L;
                break;
            case "lavenderblush":
                rgb = 0xff00_f000_f500L;
                break;
            case "lawngreen":
                rgb = 0x7c00_fc00_0000L;
                break;
            case "lemonchiffon":
                rgb = 0xff00_fa00_cd00L;
                break;
            case "lightblue":
                rgb = 0xad00_d800_e600L;
                break;
            case "lightcoral":
                rgb = 0xf000_8000_8000L;
                break;
            case "lightcyan":
                rgb = 0xe000_ff00_ff00L;
                break;
            case "lightgoldenrodyellow":
                rgb = 0xfa00_fa00_d200L;
                break;
            case "lightgray":
            case "lightgrey": //British
                rgb = 0xd300_d300_d300L;
                break;
            case "lightgreen":
                rgb = 0x9000_ee00_9000L;
                break;
            case "lightpink":
                rgb = 0xff00_b600_c100L;
                break;
            case "lightsalmon":
                rgb = 0xff00_a000_7a00L;
                break;
            case "lightseagreen":
                rgb = 0x2000_b200_aa00L;
                break;
            case "lightskyblue":
                rgb = 0x8700_ce00_fa00L;
                break;
            case "lightslategray":
            case "lightslategrey": //British
                rgb = 0x7700_8800_9900L;
                break;
            case "lightsteelblue":
                rgb = 0xb000_c400_de00L;
                break;
            case "lightyellow":
                rgb = 0xff00_ff00_e000L;
                break;
            case "lime":
                rgb = 0x0000_ff00_0000L;
                break;
            case "limegreen":
                rgb = 0x3200_cd00_3200L;
                break;
            case "linen":
                rgb = 0xfa00_f000_e600L;
                break;
            case "magenta":
                rgb = 0xff00_0000_ff00L;
                break;
            case "maroon":
                rgb = 0x8000_0000_0000L;
                break;
            case "mediumaquamarine":
                rgb = 0x6600_cd00_aa00L;
                break;
            case "mediumblue":
                rgb = 0x0000_0000_cd00L;
                break;
            case "mediumorchid":
                rgb = 0xba00_5500_d300L;
                break;
            case "mediumpurple":
                rgb = 0x9300_7000_d800L;
                break;
            case "mediumseagreen":
                rgb = 0x3c00_b300_7100L;
                break;
            case "mediumslateblue":
                rgb = 0x7b00_6800_ee00L;
                break;
            case "mediumspringgreen":
                rgb = 0x0000_fa00_9a00L;
                break;
            case "mediumturquoise":
                rgb = 0x4800_d100_cc00L;
                break;
            case "mediumvioletred":
                rgb = 0xc700_1500_8500L;
                break;
            case "midnightblue":
                rgb = 0x1900_1900_7000L;
                break;
            case "mintcream":
                rgb = 0xf500_ff00_fa00L;
                break;
            case "mistyrose":
                rgb = 0xff00_e400_e100L;
                break;
            case "moccasin":
                rgb = 0xff00_e400_b500L;
                break;
            case "navajowhite":
                rgb = 0xff00_de00_ad00L;
                break;
            case "navy":
                rgb = 0x8000L;
                break;
            case "oldlace":
                rgb = 0xfd00_f500_e600L;
                break;
            case "olive":
                rgb = 0x8000_8000_0000L;
                break;
            case "olivedrab":
                rgb = 0x6b00_8e00_2300L;
                break;
            case "orange":
                rgb = 0xff00_a500_0000L;
                break;
            case "orangered":
                rgb = 0xff00_4500_0000L;
                break;
            case "orchid":
                rgb = 0xda00_7000_d600L;
                break;
            case "palegoldenrod":
                rgb = 0xee00_e800_aa00L;
                break;
            case "palegreen":
                rgb = 0x9800_fb00_9800L;
                break;
            case "paleturquoise":
                rgb = 0xaf00_ee00_ee00L;
                break;
            case "palevioletred":
                rgb = 0xd800_7000_9300L;
                break;
            case "papayawhip":
                rgb = 0xff00_ef00_d500L;
                break;
            case "peachpuff":
                rgb = 0xff00_da00_b900L;
                break;
            case "peru":
                rgb = 0xcd00_8500_3f00L;
                break;
            case "pink":
                rgb = 0xff00_c000_cb00L;
                break;
            case "plum":
                rgb = 0xdd00_a000_dd00L;
                break;
            case "powderblue":
                rgb = 0xb000_e000_e600L;
                break;
            case "purple":
                rgb = 0x8000_0000_8000L;
                break;
            case "red":
                rgb = 0xFF00_0000_0000L;
                break;
            case "rosybrown":
                rgb = 0xbc00_8f00_8f00L;
                break;
            case "royalblue":
                rgb = 0x4100_6900_e100L;
                break;
            case "saddlebrown":
                rgb = 0x8b00_4500_1300L;
                break;
            case "salmon":
                rgb = 0xfa00_8000_7200L;
                break;
            case "sandybrown":
                rgb = 0xf400_a400_6000L;
                break;
            case "seagreen":
                rgb = 0x2e00_8b00_5700L;
                break;
            case "seashell":
                rgb = 0xff00_f500_ee00L;
                break;
            case "sienna":
                rgb = 0xa000_5200_2d00L;
                break;
            case "silver":
                rgb = 0xc000_c000_c000L;
                break;
            case "skyblue":
                rgb = 0x8700_ce00_eb00L;
                break;
            case "slateblue":
                rgb = 0x6a00_5a00_cd00L;
                break;
            case "slategray":
            case "slategrey": //British
                rgb = 0x7000_8000_9000L;
                break;
            case "snow":
                rgb = 0xff00_fa00_fa00L;
                break;
            case "springgreen":
                rgb = 0x0000_ff00_7f00L;
                break;
            case "steelblue":
                rgb = 0x4600_8200_b400L;
                break;
            case "tan":
                rgb = 0xd200_b400_8c00L;
                break;
            case "teal":
                rgb = 0x0000_8000_8000L;
                break;
            case "thistle":
                rgb = 0xd800_bf00_d800L;
                break;
            case "tomato":
                rgb = 0xff00_6300_4700L;
                break;
            case "turquoise":
                rgb = 0x4000_e000_d000L;
                break;
            case "violet":
                rgb = 0xee00_8200_ee00L;
                break;
            case "wheat":
                rgb = 0xf500_de00_b300L;
                break;
            case "white":
                rgb = 0xFF00_FF00_FF00L;
                break;
            case "whitesmoke":
                rgb = 0xf500_f500_f500L;
                break;
            case "yellow":
                rgb = 0xff00_ff00_0000L;
                break;
            case "yellowgreen":
                rgb = 0x9a00_cd00_3200L;
                break;
            default:
                rgb = -1;
        }
        return rgb;
    }
1081983
def get_colors(n):
        """"""
        cb_palette = ["#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00",
                      "#CC79A7","#001F3F", "#0074D9", "#7FDBFF", "#39CCCC", "#3D9970", "#2ECC40",
                       "#01FF70", "#FFDC00", "#FF851B", "#FF4136", "#F012BE", "#B10DC9",
                       "#85144B", "#AAAAAA", "#000000"]

        whole = int(n/22)
        extra = (n % 22)
        cols = cb_palette * whole
        if extra >= 0:
            cols.extend(cb_palette[0:extra])
        return cols
777522
def check_color(c):
    

    c = asarray(c)
    if c.ndim == 1:
        c = c.flatten()
        c = c[newaxis, :]
        if c.shape[1] != 3:
            raise Exception("Color must have three values per point")
    elif c.ndim == 2:
        if c.shape[1] != 3:
            raise Exception("Color array must have three values per point")
    return c
131602
public static int scanright(Color color, int height, int width, int col, PixelsExtractor f, int tolerance) {
        if (col == width || !PixelTools.colorMatches(color, tolerance, f.apply(new Area(col, 0, 1, height))))
            return col;
        else
            return scanright(color, height, width, col + 1, f, tolerance);
    }
587893
def color_is_allowed():
    ''' 
    '''
    result = True  # generally yes - env.CLICOLOR != '0'

    if color_is_disabled():
        result = False

    log.debug('%r', result)
    return result
994478
def looks_like?(color_to_check = nil, delta = 8)
      color_to_check = color_to_check.converted_color if color_to_check.is_a?(SchemeColor)
      color_to_check = color_to_check.pattern_fill.foreground_folor if color_to_check.is_a?(Fill)
      color_to_check = color_to_check.color.converted_color if color_to_check.is_a?(PresentationFill)
      color_to_check = Color.parse(color_to_check) if color_to_check.is_a?(String)
      color_to_check = Color.parse(color_to_check.to_s) if color_to_check.is_a?(Symbol)
      color_to_check = Color.parse(color_to_check.value) if color_to_check.is_a?(DocxColor)
      return true if none? && color_to_check.nil?
      return true if none? && color_to_check.none?
      return false if none? && color_to_check.any?
      return false if !none? && color_to_check.none?
      return true if self == color_to_check

      red = color_to_check.red
      green = color_to_check.green
      blue = color_to_check.blue
      (self.red - red).abs < delta && (self.green - green).abs < delta && (self.blue - blue).abs < delta ? true : false
    end