Ejemplo n.º 1
0
 public void DoClear()
 {
     _scaler = new Scaler(panel1.Size,
                          new Size(_scaler.ImageWidth, _scaler.ImageHeight));
     using (var g = panel1.CreateGraphics())
     {
         g.Clear(DefaultBackColor);
     }
 }
Ejemplo n.º 2
0
        public void DoShowImage(Bitmap bitmap)
        {
            _scaler = new Scaler(panel1, bitmap);
            var width         = bitmap.Width;
            var height        = bitmap.Height;
            var panelPoint    = Point.Round(_scaler.ImageToScreen(0, 0));
            var panelEndPoint = Point.Round(_scaler.ImageToScreen(width, height));
            var panelSize     = new Size(panelEndPoint.X - panelPoint.X, panelEndPoint.Y - panelPoint.Y);

            using (var g = panel1.CreateGraphics())
            {
                g.Clear(DefaultBackColor);
                g.DrawImage(bitmap, new Rectangle(panelPoint, panelSize),
                            new Rectangle(0, 0, width, height), GraphicsUnit.Pixel);
            }
        }