/// <summary>
        /// Helper class to redraw the IImageSurface asynchronously
        /// </summary>
        /// <returns>Task</returns>
        private async Task RedrawSurfaceAsync()
        {
            // Cache the canvasBitmap to avoid reloading of the same image during Resize/Redraw operations
            _canvasBitmap = await _generator.RedrawImageSurfaceAsync(_surfaceLock, _surface, _uri, Options, _canvasBitmap);

            // If AutoResize is allowed and the image is successfully loaded into the canvasBitmap,
            // then update the Size property of the surface as the surface has been resized to match the canvasBitmap size
            if (Options.AutoResize)
            {
                // If the image is successfully loaded into the canvasBitmap, then update the Size property
                // of the surface as the surface has been resized to match the canvasBitmap size
                Size = _canvasBitmap?.Size ?? new Size(0, 0);
            }

            Status = _canvasBitmap != null ? ImageSurfaceLoadStatus.Success : ImageSurfaceLoadStatus.Error;

            // Get the canvasbitmap dimensions
            if (_canvasBitmap != null)
            {
                DecodedPhysicalSize = new Size(_canvasBitmap.SizeInPixels.Width, _canvasBitmap.SizeInPixels.Height);
                DecodedSize         = _canvasBitmap.Size;
            }
            // Raise the event
            if (_raiseLoadCompletedEvent)
            {
                LoadCompleted?.Invoke(this, Status);
                _raiseLoadCompletedEvent = false;
            }
        }
Пример #2
0
        /// <summary>
        /// Helper class to redraw the SurfaceImage asynchronously
        /// </summary>
        /// <returns>Task</returns>
        private async Task RedrawSurfaceImageInternalAsync()
        {
            // Cache the canvasBitmap to avoid reloading of the same image during Resize/Redraw operations
            _canvasBitmap = await _generator.RedrawImageSurfaceAsync(_surfaceLock, _surface, _uri, Options, _canvasBitmap);

            // If AutoResize is allowed and the image is successfully loaded into the canvasBitmap,
            // then update the Size property of the surface as the surface has been resized to match the canvasBitmap size
            if (Options.AutoResize)
            {
                // If the image is successfully loaded into the canvasBitmap, then update the Size property
                // of the surface as the surface has been resized to match the canvasBitmap size
                Size = _canvasBitmap?.Size ?? new Size(0, 0);
            }
        }