Source/OxyPlot.Avalonia/CanvasRenderContext.cs
/// <summary>
/// Draws a portion of the specified <see cref="OxyImage" />.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="srcX">The x-coordinate of the upper-left corner of the portion of the source image to draw.</param>
/// <param name="srcY">The y-coordinate of the upper-left corner of the portion of the source image to draw.</param>
/// <param name="srcWidth">Width of the portion of the source image to draw.</param>
/// <param name="srcHeight">Height of the portion of the source image to draw.</param>
/// <param name="destX">The x-coordinate of the upper-left corner of drawn image.</param>
/// <param name="destY">The y-coordinate of the upper-left corner of drawn image.</param>
/// <param name="destWidth">The width of the drawn image.</param>
/// <param name="destHeight">The height of the drawn image.</param>
/// <param name="opacity">The opacity.</param>
/// <param name="interpolate">interpolate if set to <c>true</c>.</param>
Draws a portion of the specified .
Draws a portion of the specified .
public void DrawImage(
            OxyImage source,
            double srcX,
            double srcY,
            double srcWidth,
            double srcHeight,
            double destX,
            double destY,
            double destWidth,
            double destHeight,
            double opacity,
            bool interpolate)
        {
            if (destWidth <= 0 || destHeight <= 0 || srcWidth <= 0 || srcHeight <= 0)
            {
                return;
            }
            var image = CreateAndAdd<Image>(destX, destY);
            var bitmapChain = GetImageSource(source);
            if (srcX == 0 && srcY == 0 && srcWidth == bitmapChain.PixelSize.Width && srcHeight == bitmapChain.PixelSize.Height)
            {
            }
            else
            {
                image.Clip = new RectangleGeometry(new Rect(srcX, srcY, srcWidth, srcHeight));
            }
            image.Opacity = opacity;
            image.Width = destWidth;
            image.Height = destHeight;
            image.Stretch = Stretch.Fill;
            Canvas.SetLeft(image, destX);
            Canvas.SetTop(image, destY);
            image.Source = bitmapChain;
            if (interpolate)
            {
                RenderOptions.SetBitmapInterpolationMode(image, global::Avalonia.Visuals.Media.Imaging.BitmapInterpolationMode.LowQuality);
            }
            else
            {
                RenderOptions.SetBitmapInterpolationMode(image, global::Avalonia.Visuals.Media.Imaging.BitmapInterpolationMode.Default);
            }
        }
public void DrawImage ( OxyImage source , double srcX , double srcY , double srcWidth , double srcHeight , double destX , double destY , double destWidth , double destHeight , double opacity , bool interpolate ) { if ( destWidth <= 0 || destHeight <= 0 || srcWidth <= 0 || srcHeight <= 0 ) { return ; } var image = CreateAndAdd < Image > ( destX , destY ) ; var bitmapChain = GetImageSource ( source ) ; if ( srcX == 0 && srcY == 0 && srcWidth == bitmapChain . PixelSize . Width && srcHeight == bitmapChain . PixelSize . Height ) { } else { image . Clip = new RectangleGeometry ( new Rect ( srcX , srcY , srcWidth , srcHeight ) ) ; } image . Opacity = opacity ; image . Width = destWidth ; image . Height = destHeight ; image . Stretch = Stretch . Fill ; Canvas . SetLeft ( image , destX ) ; Canvas . SetTop ( image , destY ) ; image . Source = bitmapChain ; if ( interpolate ) { RenderOptions . SetBitmapInterpolationMode ( image , global :: Avalonia . Visuals . Media . Imaging . BitmapInterpolationMode . LowQuality ) ; } else { RenderOptions . SetBitmapInterpolationMode ( image , global :: Avalonia . Visuals . Media . Imaging . BitmapInterpolationMode . Default ) ; } }
Draws a portion of the specified .
Draws a portion of the specified .
// ReSharper disable CompareOfFloatsByEqualityOperator // ReSharper restore CompareOfFloatsByEqualityOperator // do not crop // Set the position of the image //// alternative: image.RenderTransform = new TranslateTransform(destX, destY);
source
OxyImage
None
srcX
double
The x-coordinate of the upper-left corner of the portion of the source image to draw.
The x - coordinate of the upper - left corner of the portion of the source image to draw .
srcY
double
The y-coordinate of the upper-left corner of the portion of the source image to draw.
The y - coordinate of the upper - left corner of the portion of the source image to draw .
srcWidth
double
Width of the portion of the source image to draw.
Width of the portion of the source image to draw .
srcHeight
double
Height of the portion of the source image to draw.
Height of the portion of the source image to draw .
destX
double
The x-coordinate of the upper-left corner of drawn image.
The x - coordinate of the upper - left corner of drawn image .
destY
double
The y-coordinate of the upper-left corner of drawn image.
The y - coordinate of the upper - left corner of drawn image .
destWidth
double
The width of the drawn image.
The width of the drawn image .
destHeight
double
The height of the drawn image.
The height of the drawn image .
opacity
double
None
interpolate
bool
interpolate if set to true
interpolate if set to true