1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| private void frmPicture_Paint(object sender, PaintEventArgs e)
{
putImage();
}
private void putImage()
{
#if DRAW_PB
Graphics cGraphics = pbPhoto.CreateGraphics();
#else
Bitmap bmp = new Bitmap(pbPhoto.Width, pbPhoto.Height);
Graphics cGraphics = Graphics.FromImage(bmp);
#endif
Rectangle dstRect = pbPhoto.Bounds;
Rectangle srcRect = new Rectangle(0, 0, img.Width, img.Height);
GraphicsUnit units = GraphicsUnit.Pixel;
cGraphics.DrawImage(img, dstRect, srcRect, units);
#if DRAW_PB
// rien a faire
#else
pbPhoto.Image = bmp;
#endif
pbPhoto.Invalidate();
return;
} |
Partager