private System.Drawing.Image SetPictureAtPoint(System.Drawing.Size FinalImageSize, System.Drawing.Image Image, System.Drawing.Point Location)
{
System.Drawing.Image TmpImg = new System.Drawing.Bitmap(FinalImageSize.Width, FinalImageSize.Height); // Image finale
System.Drawing.Graphics Graphics = System.Drawing.Graphics.FromImage(TmpImg); // Récupére un graphics de l'image
Graphics.DrawImage(Image, Location); // Dessine l'image sur le graphics
return TmpImg;
}
private System.Drawing.Image SetPictureAtPoint(System.Drawing.Image Image, System.Drawing.Point Location)
{
System.Drawing.Image TmpImg = new System.Drawing.Bitmap(Location.X + Image.Width, Location.Y + Image.Height); // Image finil avec la taille adapter
System.Drawing.Graphics Graphics = System.Drawing.Graphics.FromImage(TmpImg); // Récupére un graphics de l'image
Graphics.DrawImage(Image, Location); // Dessine l'image sur le graphics
return TmpImg;
}
Example d'utilisation: Placement d'une image a la position (10, 10) dans une PictureBox:
Bitmap Img = new Bitmap("LeChemin\\DeVotre\\FichierImage");
this.pictureBox1.Image = SetPictureAtPoint(img, new System.Drawing.Point(10, 10));