private void ProcessBytes(Span <int> dataSlice, Spectrum targetHue, Spectrum alterTo) { for (int i = 0; i < dataSlice.Length; i++) { //If this hue meets the correct profile, then change it to the requested hue. int pxl = dataSlice[i]; if (_IsTargeted(pxl, targetHue)) { dataSlice[i] = RecolorPixel.Recolor(pxl, alterTo); } } }
private static IsPixel GetTargetSelector(Spectrum targetedHue) { if ((int)targetedHue >= -15 && (int)targetedHue <= 360) { return((pxl, th) => { float b = Color.FromArgb(pxl).GetBrightness(); int h = RecolorPixel.GetHue(pxl); h = h > 345 ? h -= 360 : h; int bth = (int)th; int tth = (bth + 30) > 360 ? bth -= 330 : bth + 30; return (h >= bth && h <= tth && b < 0.95 && b > 0.05); }); } else { switch (targetedHue) { //TODO: Assign bools for special cases case Spectrum.Null: return((h, th) => { return false; }); case Spectrum.White: return((h, th) => { return false; }); case Spectrum.Black: return((h, th) => { return false; }); default: return((h, th) => { return false; }); } } }