private static int CompareValue(ThemeBitmap oldValue, ThemeBitmap newValue) { BitmapImage oldImage = LoadImage(oldValue); BitmapImage newImage = LoadImage(newValue); int cmp = oldImage.PixelWidth.CompareTo(newImage.PixelWidth); if (cmp == 0) { cmp = oldImage.PixelHeight.CompareTo(newImage.PixelHeight); } if (cmp == 0) { cmp = oldImage.Format.BitsPerPixel.CompareTo(newImage.Format.BitsPerPixel); } if (cmp == 0) { int pixelWidth = oldImage.PixelWidth; int pixelHeight = oldImage.PixelHeight; int stride = pixelWidth * (oldImage.Format.BitsPerPixel + 7 / 8); int size = stride * pixelHeight; var oldPixels = new byte[size]; var newPixels = new byte[size]; oldImage.CopyPixels(Int32Rect.Empty, oldPixels, stride, 0); newImage.CopyPixels(Int32Rect.Empty, newPixels, stride, 0); cmp = CompareSequence(oldPixels, newPixels); } return(cmp); }
public ThemeBitmapViewModel(ThemeBitmap themeBitmap) { ThemeBitmap = themeBitmap; bitmap = new Lazy <BitmapImage>(LoadBitmap); }
private static BitmapImage LoadImage(ThemeBitmap oldValue) { using (var stream = oldValue.OpenStream()) return(ImagingUtils.LoadBitmapImageFromStream(stream)); }