- string message = "Mon texte à afficher";
-
- // Création de l'image
- Bitmap b = new Bitmap(1, 1);
- Font f = new Font("Arial", 8);
- Graphics graphics = Graphics.FromImage(b);
- int width = (int) graphics.MeasureString(message,f).Width;
- int height = (int) graphics.MeasureString(message,f).Height;
- b = new Bitmap(b, new Size(height, width));
- graphics = Graphics.FromImage(b);
- graphics.Clear(Color.White);
- graphics.SmoothingMode = SmoothingMode.HighQuality;
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
-
- // Création du texte de l'image
- StringFormat sf = StringFormat.GenericTypographic;
- sf.FormatFlags = StringFormatFlags.DirectionVertical; // Position verticale
- graphics.DrawString(message, f, new SolidBrush(Color.FromArgb(62, 62, 62)), 0, 0, sf);
- graphics.Flush();
-
- // Enregistrement de l'image
- string directory = System.Configuration.ConfigurationSettings.AppSettings["installPath"];
- message = message.Replace(" ", "");
- directory += @"\Images\Generated\" + message + ".gif";
- b.Save(directory, System.Drawing.Imaging.ImageFormat.Gif);
string message = "Mon texte à afficher";
// Création de l'image
Bitmap b = new Bitmap(1, 1);
Font f = new Font("Arial", 8);
Graphics graphics = Graphics.FromImage(b);
int width = (int) graphics.MeasureString(message,f).Width;
int height = (int) graphics.MeasureString(message,f).Height;
b = new Bitmap(b, new Size(height, width));
graphics = Graphics.FromImage(b);
graphics.Clear(Color.White);
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.SmoothingMode = SmoothingMode.AntiAlias;
// Création du texte de l'image
StringFormat sf = StringFormat.GenericTypographic;
sf.FormatFlags = StringFormatFlags.DirectionVertical; // Position verticale
graphics.DrawString(message, f, new SolidBrush(Color.FromArgb(62, 62, 62)), 0, 0, sf);
graphics.Flush();
// Enregistrement de l'image
string directory = System.Configuration.ConfigurationSettings.AppSettings["installPath"];
message = message.Replace(" ", "");
directory += @"\Images\Generated\" + message + ".gif";
b.Save(directory, System.Drawing.Imaging.ImageFormat.Gif);