TODATODA
Messages postés13Date d'inscriptionjeudi 1 février 2007StatutMembreDernière intervention12 mai 2009
-
8 avril 2009 à 17:54
krimog
Messages postés1860Date d'inscriptionlundi 28 novembre 2005StatutMembreDernière intervention14 février 2015
-
9 avril 2009 à 12:01
bonjour tout le monde.
Je veux inserer une zone de texte dans une imege,comme microsoft
word's text box. l'utilisateur peut changer text's font,size,style,color . et sauvegarder l'image ceci sur une application web
est ce que ceci est possible avec silverlight, si oui comment.
merci pour votre aide
krimog
Messages postés1860Date d'inscriptionlundi 28 novembre 2005StatutMembreDernière intervention14 février 201549 9 avril 2009 à 10:22
Salut
Avec ça, tu devrais pouvoir y arriver (NB : je n'ai pas testé)
// On ouvre l'image
System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\mon image");
// On dessine le texte dedans
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
g.DrawString("Mon texte", new System.Drawing.Font("Arial", 14), new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 0, 0)), new System.Drawing.PointF(10, 20));
// On crée une bitmap à partir de l'image
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img);
// On crée une BitmapSource (WPF) à partir de la bitmap
IntPtr hBitmap = bmp.GetHbitmap();
System.Windows.Media.Imaging.BitmapSource bmpSrc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, System.Windows.Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
// On crée une image WPF avec cette BitmapSource
System.Windows.Controls.Image i = new System.Windows.Controls.Image();
i.Source = bmpSrc;