Exemple #1
0
        /*
         * Sets the picture to show from a file path
         */
        private void SetImage(string sFilePath, Rotation iRotation)
        {
            //Initialize the new image as a bitmap
            BitmapImage bitmap = new BitmapImage();

            //Set the bitmap source
            bitmap.BeginInit();
            bitmap.UriSource   = new Uri(sFilePath, UriKind.Relative);
            bitmap.CacheOption = BitmapCacheOption.OnLoad;

            //Release the bitmap for it to be accessed
            bitmap.EndInit();
            bitmap.Freeze();

            //Initialize a transformed bitmap for rotation
            TransformedBitmap transBitmap = new TransformedBitmap();

            transBitmap.BeginInit();
            transBitmap.Source = bitmap.Clone();

            //Set the orientation of the transformed bitmap
            switch (iRotation)
            {
            case Rotation.Left:
                transBitmap.Transform = new RotateTransform(270);
                break;

            case Rotation.Right:
                transBitmap.Transform = new RotateTransform(90);
                break;

            case Rotation.Full:
                transBitmap.Transform = new RotateTransform(180);
                break;

            case Rotation.None:
                transBitmap.Transform = new RotateTransform(0);
                break;
            }

            //Release the transformed bitmap for it to be accessed
            transBitmap.EndInit();
            transBitmap.Freeze();

            //Set the grid background color
            gridPicture.Background = new SolidColorBrush(Colors.Black);

            //Set the map visibility
            mapPicture.Visibility = Visibility.Visible;

            //Set the new image
            imgPicture.Source = transBitmap.Clone();
        }
 private void storeTransformedBitmap()
 {
     storedTransformedBitmap = (Bitmap)TransformedBitmap.Clone();
 }