예제 #1
0
        private async Task LoadInputVirtualBitmap()
        {
            ContentFrame_Reset();
            ContentFrameCollapse();

            if (InputVirtualBitmap != null)
            {
                InputVirtualBitmap.Dispose();
                InputVirtualBitmap = null;
            }

            //LoadedImageInfo = "";

            InputVirtualBitmap = await CanvasVirtualBitmap.LoadAsync(InputImageCanvas.Device, InputImageStream, CanvasVirtualBitmapOptions.None);

            if (InputImageCanvas == null)
            {
                // This can happen if the page is unloaded while LoadAsync is running
                return;
            }

            var size = InputVirtualBitmap.Size;

            InputImageCanvas.Width  = size.Width * (Zoom + 1);
            InputImageCanvas.Height = size.Height * (Zoom + 1);
            InputImageCanvas.Invalidate();

            //LoadedImageInfo = string.Format("{0}x{1} image, is {2}CachedOnDemand", size.Width, size.Height, virtualBitmap.IsCachedOnDemand ? "" : "not ");
        }
예제 #2
0
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            InputImageCanvas.RemoveFromVisualTree();
            OutputImageCanvas.RemoveFromVisualTree();

            InputImageCanvas  = null;
            OutputImageCanvas = null;
        }
예제 #3
0
        private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            InputImageCanvas.Invalidate();
            OutputImageCanvas.Invalidate();
            InputCanvasScrollViewer.MaxWidth  = double.MaxValue;
            InputCanvasScrollViewer.MaxHeight = double.MaxValue;

            OutputCanvasScrollViewer.MaxWidth  = double.MaxValue;
            OutputCanvasScrollViewer.MaxHeight = double.MaxValue;
        }
예제 #4
0
 private void InputImageCanvas_RegionsInvalidated(Microsoft.Graphics.Canvas.UI.Xaml.CanvasVirtualControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasRegionsInvalidatedEventArgs args)
 {
     foreach (var region in args.InvalidatedRegions)
     {
         using (var ds = InputImageCanvas.CreateDrawingSession(region))
         {
             if (InputVirtualBitmap != null)
             {
                 ds.DrawImage(InputVirtualBitmap,
                              new Rect(0, 0, InputVirtualBitmap.Bounds.Width * Zoom, InputVirtualBitmap.Bounds.Height * Zoom),
                              new Rect(0, 0, InputVirtualBitmap.Bounds.Width, InputVirtualBitmap.Bounds.Height),
                              1.0f,
                              CanvasImageInterpolation.NearestNeighbor);
             }
         }
     }
 }
예제 #5
0
 private void InputCanvasScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
 {
     InputImageCanvas.Invalidate();
     OutputCanvasScrollViewer.ChangeView(InputCanvasScrollViewer.HorizontalOffset, InputCanvasScrollViewer.VerticalOffset, null);
 }