Bonjour à tous,
je sais copier un Bitmap dans un Graphics en utilisant Graphics.DrawImage(), mais comment obtenir un Bitmap représentant le contenu d'un Graphics ?
J'ai tenté le code suivant, mais sans succés (l'image est complètement noire):
Plus généralement, j'ai un peu de mal à cerner le lien entre ces 2 classes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 g = pictureBox1.CreateGraphics(); g.DrawLine(new Pen(Color.Red), new Point(0, 0), new Point(pictureBox1.Width - 1, pictureBox1.Height - 1)); saveBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); pictureBox1.DrawToBitmap(saveBitmap, pictureBox1.Bounds); saveBitmap.Save(@"c:\test.png");
Est-ce que qq'un aurait un lien présentant leurs interactions ?
Merci à tous,
Lucas
Bitmap: http://msdn.microsoft.com/fr-fr/library/4e7y164x.aspx
Graphics: http://msdn.microsoft.com/fr-fr/libr....graphics.aspx
Partager