Esempio n. 1
0
        CalculateImageCrc32(
            BitmapSource bitmapSource
            )
        {
            Crc32 crc32 = new Crc32();

            int       width  = bitmapSource.PixelWidth;
            int       height = bitmapSource.PixelHeight;
            int       stride = (width * bitmapSource.Format.BitsPerPixel + 7) / 8;
            Int32Rect rect   = new Int32Rect(0, 0, width, 1);

            byte[] pixels = new byte[stride];


            for (int i = 0; i < height; i += 1)
            {
                bitmapSource.CriticalCopyPixels(rect, pixels, stride, 0);
                rect.Y++;

                crc32.AddData(pixels);
            }

            return(crc32.Crc32Value);
        }