Exemple #1
0
 /// <summary>
 /// See base docs.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public override void DrawImage(VrsDrawing.IImage image, int x, int y)
 {
     if (image is ImageWrapper imageWrapper)
     {
         GdiPlusLock.EnforceSingleThread(() => {
             NativeDrawingContext.DrawImage(
                 imageWrapper.NativeImage,
                 x, y
                 );
         });
     }
 }
Exemple #2
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="drawAction"></param>
        /// <returns></returns>
        public VrsDrawing.IImage CloneAndDraw(VrsDrawing.IImage source, Action <VrsDrawing.IDrawing> drawAction)
        {
            VrsDrawing.IImage result = null;

            if (source is ImageWrapper sourceWrapper)
            {
                GdiPlusLock.EnforceSingleThread(() => {
                    result          = sourceWrapper.Clone();
                    var nativeClone = ((ImageWrapper)result).NativeImage;
                    using (var drawing = new Drawing(Graphics.FromImage(nativeClone))) {
                        drawAction(drawing);
                    }
                });
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// See base docs.
        /// </summary>
        /// <returns></returns>
        public override VrsDrawing.IImage Clone()
        {
            VrsDrawing.IImage result = null;

            GdiPlusLock.EnforceSingleThread(() => {
                // GDI+ version of clone is a bit dodgy. We need to create a brand-new
                // copy of the image instead.
                if (NativeImage is Bitmap bitmap)
                {
                    result = new ImageWrapper(new Bitmap(bitmap));
                }
                else
                {
                    throw new InvalidOperationException($"Cannot clone {NativeImage.GetType().FullName} image objects");
                }
            });

            return(result);
        }
Exemple #4
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public abstract void DrawImage(VrsDrawing.IImage image, int x, int y);