[Novice] Graphics et Bitmap
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):
Code:
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"); |
Plus généralement, j'ai un peu de mal à cerner le lien entre ces 2 classes.
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