Esempio n. 1
0
 public ImageDrawCommand(AM.IImage?source, A.Rect sourceRect, A.Rect destRect, AVMI.BitmapInterpolationMode bitmapInterpolationMode)
 {
     Source     = source;
     SourceRect = sourceRect;
     DestRect   = destRect;
     BitmapInterpolationMode = bitmapInterpolationMode;
 }
Esempio n. 2
0
        private static InterpolationMode GetInterpolationMode(BitmapInterpolationMode interpolationMode)
        {
            switch (interpolationMode)
            {
            case BitmapInterpolationMode.LowQuality:
                return(InterpolationMode.NearestNeighbor);

            case BitmapInterpolationMode.MediumQuality:
                return(InterpolationMode.Linear);

            case BitmapInterpolationMode.HighQuality:
                return(InterpolationMode.HighQualityCubic);

            case BitmapInterpolationMode.Default:
                return(InterpolationMode.Linear);

            default:
                throw new ArgumentOutOfRangeException(nameof(interpolationMode), interpolationMode, null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Draws a bitmap image.
        /// </summary>
        /// <param name="source">The bitmap image.</param>
        /// <param name="opacity">The opacity to draw with.</param>
        /// <param name="sourceRect">The rect in the image to draw.</param>
        /// <param name="destRect">The rect in the output to draw to.</param>
        /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
        public void DrawBitmap(IRef <IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode)
        {
            using (var d2d = ((BitmapImpl)source.Item).GetDirect2DBitmap(_deviceContext))
            {
                var interpolationMode = GetInterpolationMode(bitmapInterpolationMode);

                // TODO: How to implement CompositeMode here?

                _deviceContext.DrawBitmap(
                    d2d.Value,
                    destRect.ToSharpDX(),
                    (float)opacity,
                    interpolationMode,
                    sourceRect.ToSharpDX(),
                    null);
            }
        }