• 读本地图像文件,在上面写一些文件,再传到WWW服务器上


      1   public class ImgExtends
      2 
      3     {
      4 
      5         /// <summary>
      6 
      7         /// 像本地图像文件上写字,并上传本地服务器
      8 
      9         /// </summary>
     10 
     11         /// <param name="imgserverurl">Web服务器上的图片路径</param>
     12 
     13         /// <param name="title">图片上的文字</param>
     14 
     15         /// <returns></returns>
     16 
     17         public static string GetImg(string imgserverurl, string title)
     18 
     19         {
     20 
     21             try
     22 
     23             {
     24 
     25                 if (!string.IsNullOrEmpty(imgserverurl))
     26 
     27                 {
     28 
     29                     string Path = System.Web.HttpContext.Current.Server.MapPath("/Upload/Product");
     30 
     31                     string FileName = "\\" + VCommons.Utils.GetNewGuid() + ".jpg";
     32 
     33  
     34 
     35                     Image img = Image.FromFile(imgserverurl);
     36 
     37                     int width = img.Width;
     38 
     39                     int height = img.Height;
     40 
     41  
     42 
     43                     Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
     44 
     45                     bitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
     46 
     47  
     48 
     49                     Graphics grap = Graphics.FromImage(bitmap);
     50 
     51                     grap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     52 
     53                     grap.DrawImage(img, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel);
     54 
     55  
     56 
     57                     Font font = new Font("微软雅黑", 24, FontStyle.Bold);
     58 
     59  
     60 
     61                     SolidBrush solid = new SolidBrush(Color.Turquoise);
     62 
     63  
     64 
     65                     StringFormat format = new StringFormat();
     66 
     67                     format.Alignment = StringAlignment.Near;
     68 
     69                     grap.DrawString(title, font, solid, 25, 18, format);
     70 
     71                     grap.Dispose();
     72 
     73  
     74 
     75                     bitmap.Save(Path + FileName, ImageFormat.Jpeg);
     76 
     77                     return "http://" + RequestHelper.GetHost() + "/Upload/Product" + FileName;
     78 
     79                 }
     80 
     81                 else
     82 
     83                 {
     84 
     85                     return string.Empty;
     86 
     87                 }
     88 
     89  
     90 
     91             }
     92 
     93             catch (Exception)
     94 
     95             {
     96 
     97                 return string.Empty;
     98 
     99             }
    100 
    101         }
    102 
    103     }
  • 相关阅读:
    datasnap 2010 为DataSnap系统服务程序添加描述
    uLanguage.pas
    cxgrid上如何取FOOTER上合计的值
    cxgrid经典用法
    datasnap 2010 DataSnap服务端和客户端发布分发方法
    php_network_getaddresses: getaddrinfo failed 原因
    查看crontab运行状态
    laravel 开启定时任务需要操作
    解决cron不执行的问题
    UPdate语句
  • 原文地址:https://www.cnblogs.com/lori/p/2092269.html
Copyright © 2020-2023  润新知