public Image MaxC(Image dst, uint color) { color &= this.MaxColor; if (color == 0) { // nothing to set - simple copy return(this.Copy(dst, true)); } // create a copy of this image dst = this.Copy(dst, false); if (color == this.MaxColor) { dst.SetToOne(); } else { unsafe { fixed(ulong *bitssrc = this.Bits, bitsdst = dst.Bits) { switch (this.BitsPerPixel) { case 8: Vectors.MaxC(this.Height * this.Stride8, (byte *)bitssrc, (byte)color, (byte *)bitsdst); break; case 16: Vectors.MaxC(this.Height * this.Stride8 / sizeof(ushort), (ushort *)bitssrc, (ushort)color, (ushort *)bitsdst); break; case 24: case 32: { byte *ptrsrc = (byte *)bitssrc; byte *ptrdst = (byte *)bitsdst; int stride8 = this.Stride8; fixed(ulong *mask = this.ColorScanline(this.Stride, color)) { for (int i = 0, ii = this.Height; i < ii; i++, ptrsrc += stride8, ptrdst += stride8) { Vectors.Max(stride8, ptrsrc, (byte *)mask, ptrdst); } } } break; default: throw new NotSupportedException(string.Format( CultureInfo.InvariantCulture, Properties.Resources.E_UnsupportedDepth, this.BitsPerPixel)); } } } } return(dst); }