Esempio n. 1
0
        static void refreshBlankImage(ImageSource templateImage, ref BitmapSource blankImage)
        {
            if (blankImage != null)
            {
                if (blankImage.Height == templateImage.Height &&
                    blankImage.Width == templateImage.Width)
                {
                    return;
                }
            }

            int stride = BitmapUtilities.CalculateStride(PixelFormats.Bgra32, (int)templateImage.Width);

            byte[] pixelValues = new byte[(int)templateImage.Height * stride];
            for (int i = 0; i < pixelValues.Length; i = i + 4)
            {
                pixelValues[i]     = 0;
                pixelValues[i + 1] = 0;
                pixelValues[i + 2] = 0;
                pixelValues[i + 3] = 255;
            }
            blankImage = BitmapSource.Create((int)templateImage.Width, (int)templateImage.Height, 96, 96, PixelFormats.Bgra32, null, pixelValues, stride);
        }