Hi
Try the code bellow to zoom an image on a label...
[STAThread]
static void Main()
{
Application.Run(new ImageZoom1());
}
protected override void OnPaint(PaintEventArgs e)
{ ImageZoom(); }
protected void ImageZoom()
{
Graphics g1 = Graphics.FromHwnd(this.label1.Handle);
Graphics g2 = Graphics.FromHwnd(this.label2.Handle);
Rectangle rec;
Rectangle recPart;
if (this.checkBox1.Checked)
{
if (im == null) ReadImage();
rec = new Rectangle(0, 0, label1.Width, label1.Height);
g1.DrawImage(im, rec);
// Center part:
recPart = new Rectangle(im.Width/4, im.Height/4, im.Width/2,
im.Height/2);
if(this.radioButton1.Checked) // Left-Top part
recPart = new Rectangle(0, 0, im.Width/2, im.Height/2);
if(this.radioButton2.Checked) // Right-Top part
recPart = new Rectangle(im.Width/2, 0, im.Width/2, im.Height/2);
if(this.radioButton3.Checked) // Left-Down part
recPart = new Rectangle(0, im.Height/2, im.Width/2, im.Height/2);
if(this.radioButton4.Checked) // Right-Down part
recPart = new Rectangle(im.Width/2, im.Height/2, im.Width/2,
im.Height/2);
g2.DrawImage(im, rec, recPart, GraphicsUnit.Pixel);
}
else
{
Clear(g1);
Clear(g2);
}
g1.Dispose(); g2.Dispose();
}
protected void ReadImage()
{
string path = @"image.BMP";
im = Image.FromFile(path);
}
protected void Clear(Graphics g)
{
g.Clear(this.BackColor);
g.Dispose();
im = null;
im2 = null;
}
}
}