public override void Draw(IDrawingGraphics drawingGraphics) { if (_image == null) return; switch (StretchType) { case StretchTypeOptions.None: drawingGraphics.DrawImage(_image, 0, 0); break; case StretchTypeOptions.Fill: drawingGraphics.DrawImage(_image, 0, 0, Size.Width, Size.Height); break; case StretchTypeOptions.Proportional: var scaleX = 1.0 * Size.Width / _image.Width; var scaleY = 1.0 * Size.Height / _image.Height; var scale = Math.Min(1, Math.Min(scaleX, scaleY)); drawingGraphics.DrawImage(_image, 0, 0, (int)Math.Round(_image.Width * scale), (int)Math.Round(_image.Height * scale)); break; } }
public override void Draw(IDrawingGraphics drawingGraphics) { if (drawingGraphics == null) return; if ((_buffer == null) || (_needRepaint)) { var newbuffer = new DoubleBuffer(Size); PaintBuffer(newbuffer.Graphics, new Rectangle(0, 0, Size.Width, Size.Height)); _buffer = newbuffer; _needRepaint = false; } drawingGraphics.DrawImage(_buffer.Image, 0, 0); // draw direct to graphic for speed //drawingGraphics.Graphics.DrawImage(_buffer.Image, drawingGraphics.CalculateX(0), drawingGraphics.CalculateY(0)); }
public override void Draw(IDrawingGraphics drawingGraphics) { drawingGraphics.DrawImage(this.image, 0, 0, Size.Width, Size.Height); }
// GIANNI Added public void DrawTransparent(IDrawingGraphics drawingGraphics) { if (_image == null) return; // Set the transparency color key based on the upper-left pixel of the image. var bmp = _image as Bitmap; var transparentKeyColor = Color.Black; // DEFAULT BLACK, IF IT IS NOT POSSIBLE TO READ FROM IMAGE if(bmp != null) transparentKeyColor = bmp.GetPixel(0, 0); drawingGraphics.DrawImage(_image, 0, 0, Size.Width, Size.Height, transparentKeyColor); }