private void PrepareViews() { inputBitmap = new UnsafeBitmap(pInput.Width, pInput.Height); inputGraphics = Graphics.FromImage(inputBitmap.Bitmap); outputBitmap = new UnsafeBitmap(pOutput.Width, pOutput.Height); outputGraphics = Graphics.FromImage(outputBitmap.Bitmap); }
private void LoadInputView(Bitmap bitmap) { int inSize = bitmap.Width; nInputSize.Value = inSize; ComputeInputScaleSquare(); inputImage = new ArrayImage(inSize); UnsafeBitmap bmp = new UnsafeBitmap(bitmap); inputGraphics.Clear(Color.Black); bmp.LockBitmap(); for (int y = 0; y < inSize; ++y) { for (int x = 0; x < inSize; ++x) { if (bmp.GetPixel(x, y).red < 50) { inputImage[x, y] = PixelMonoColorEnum.Black; inputGraphics.FillRectangle(Brushes.Black, (float)x * inputScaleSquare, (float)y * inputScaleSquare, inputScaleSquare, inputScaleSquare); } else { inputImage[x, y] = PixelMonoColorEnum.White; inputGraphics.FillRectangle(Brushes.White, (float)x * inputScaleSquare, (float)y * inputScaleSquare, inputScaleSquare, inputScaleSquare); } } } bmp.UnlockBitmap(); }