询问者
Write some words in picture(win8 metro)

问题
全部回复
-
Hi:)
no need to use API but just Graphics+Image can solve your problem!Have a try like this!
namespace MyTest { class Program { static void Main(string[] args) { Image img = Image.FromFile("d:\\Penguins.jpg"); Graphics g = Graphics.FromImage(img); g.DrawString("企 鹅", new Font("黑体", 40.5f), Brushes.YellowGreen, new PointF(img.Width / 2, img.Height / 2)); g.Save(); img.Save("C:\\企鹅.jpg", ImageFormat.Jpeg); Console.WriteLine("OK"); } } }
-
Hi Leo06053308,
如果你的图片来源于剪切板,那么下面这段代码或许适合你的场景:
try { Image bmap; IDataObject data = System.Windows.Forms.Clipboard.GetDataObject(); bmap = (Image)(data.GetData(typeof(System.Drawing.Bitmap))); Graphics g = Graphics.FromImage(bmap); SolidBrush drawBrush = new SolidBrush(Color.Red); Font drawFont = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Millimeter); int xPos = bmap.Height - (bmap.Height - 25); int yPos = 3; g.DrawString("test", drawFont, drawBrush, xPos, yPos); string sPicPath = "d:\\filename.jpg"; string sPreFix = "d:\\xxx"; Image smBmap; smBmap = bmap.GetThumbnailImage(bmap.Width, bmap.Height, null, System.IntPtr.Zero); smBmap.Save(sPicPath, System.Drawing.Imaging.ImageFormat.Jpeg); bmap.Save(sPreFix + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); bmap = null; smBmap = null; } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
如果要在win7下实现保存jpg的话,要右击鼠标开发环境选择Run as administrator。。。去实现权限提升之后就有对d盘的写权限。
orichisonic http://blog.csdn.net/orichisonic If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
- 已编辑 orichisonic 2012年3月14日 7:31
-
建议您在中文论坛上用中文发表问题,这样会有更多的人回复,也会帮住更多遇到类似问题的人。
以上我贴的是英文的论坛,下面的是中文相关的论坛,希望能帮得到您。
http://social.technet.microsoft.com/Forums/zh-cn/w8itprozhcn/threads
http://answers.microsoft.com/zh-hans/windows/forum/windows_8?tab=all
另外好像现在还没有公布一些API做类似的事。
Best Regards,
Rocky Yue[MSFT]
MSDN Community Support | Feedback to us