Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. if (IsPixelFormatIndexed(pb.Image.PixelFormat))
  2. {
  3. Bitmap bmp = new Bitmap(pb.Image.Width, pb.Image.Height, PixelFormat.Format32bppArgb);
  4. using (Graphics g = Graphics.FromImage(bmp))
  5. {
  6. g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  7. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  8. g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
  9. g.DrawImage(pb.Image, 0, 0);
  10.  
  11. string SITE_NAME = "TEST";// 繪製文字於圖像上
  12. g.DrawString(AVEID, new Font("Verdana", 20), new SolidBrush(Color.Tomato), 40, 40);
  13. g.DrawString(SITE_NAME, new Font("Verdana", 20), new SolidBrush(Color.Tomato), 40, 80);
  14.  
  15. }
  16. if (Directory.Exists(textBox2.Text + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\") == false)
  17. Directory.CreateDirectory(textBox2.Text + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\");
  18. bmp.Save(textBox2.Text + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + AVEID + "_new.jpg");
  19. }
  20. else
  21. {
  22. using (Graphics g = Graphics.FromImage(pb.Image))
  23. string SITE_NAME = "TEST";// dt_excel_new.Rows[0]["SITE_NAME"].ToString();// 繪製文字於圖像上
  24. g.DrawString(AVEID, new Font("Verdana", 20), new SolidBrush(Color.Tomato), 40, 40);
  25. g.DrawString(SITE_NAME, new Font("Verdana", 20), new SolidBrush(Color.Tomato), 40, 80);
  26.  
  27. //error here
  28. pb.Image.Save(textBox2.Text + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + AVEID + "_new.jpg");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement