private FastBitmap ApplyMask(byte[] mask, FastBitmap img) { Bitmap result = new Bitmap(img.Width, img.Height); FastBitmap fb = new FastBitmap(result); fb.LockBits(); img.LockBits(); int n = 0; for (int j = 0; j < img.Height; j++) { for (int i = 0; i < img.Width; i++) { if (mask[n] > VibeModel.BackgroundByte) { fb.SetPixel(i, j, img.GetPixel(i, j)); } n++; } } img.UnlockBits(); fb.UnlockBits(); return fb; }