Bonjour,
En voulant insérer du texte dans une image bmp, je me retrouve confronter à un dilem.
mon image à la base elle du format bmp ( 8 bits par pixel = PixelFormat.Format8bppIndexed
).
le soucis ce que je peux pas creer un objet graphique à partir de
format indexé, donc je suis passé par un autre objet graphique pour
contourner le problème : mais quand j'enregistre l'image final (le
resultat) l'image passe à 32 bits par pixel (la taille de l'image est
multiplié par 4 ce qui fait un peu bcp).
Ma question, comment faire pour inserer du texte dans une image bmp au format = PixelFormat.Format8bppIndexed, sans modifier le format de l'image resultat:
voici mon bout de code:
int PositionX = 670;
int PositionY = 90;
int TaillePolice = 24;
string strNumCompte = "123456789012";
string strText = strNumCompte;
System.Drawing.Font font = new System.Drawing.Font("arial",
TaillePolice);
System.Drawing.Image Img =
System.Drawing.Bitmap.FromFile("C:\\tempo\\remise.bmp");
System.Drawing.Image TmpImg = new System.Drawing.Bitmap(Img, Img.Width,
Img.Height);
System.Drawing.Graphics Graphics =
System.Drawing.Graphics.FromImage(TmpImg);
Graphics.DrawString(strText, font, System.Drawing.Brushes.Black,new
System.Drawing.PointF(PositionX, PositionY));
TmpImg.Save("C:\\tempo\\new.bmp",
System.Drawing.Imaging.ImageFormat.Bmp);
Merci par avance à toute personne qui pourra m'aider.