Exemple #1
0
        /// <summary>
        /// Correctly creates a cropped bitmap
        /// </summary>
        private void CreateCroppedBitmap()
        {
            if (MainWindow.IsArmorLike(ItemType))
            {
                CroppedBitmap = new CroppedBitmap(SourceImage, ImageHandler.GetCropRect(Frames, CurrentFrame, SourceImage));
            }
            else
            {
                CroppedBitmap = new CroppedBitmap(SourceImage, new Int32Rect(0, 0, SourceImage.PixelWidth, SourceImage.PixelHeight));
            }

            try
            {
                ImageElement.Source = null;
                ImageElement.Source = CroppedBitmap;
            }
            catch (InvalidOperationException e)
            {
                CroppedBitmap tempBitmap = CroppedBitmap.Clone();
                tempBitmap.Freeze();

                App.Current.Dispatcher.Invoke(() =>
                {
                    ImageElement.Source = tempBitmap;
                });

                CroppedBitmap = tempBitmap;

                Console.WriteLine(e);
            }
        }