• 原图旋转/缩放 然后画布画图 ImageProcessor


                //旋转
                byte[] photoBytes = File.ReadAllBytes(HttpContext.Current.Server.MapPath(diyInfo.ImageUrl));
                ImageFactory imageFactory = new ImageFactory();
                imageFactory.Load(photoBytes);
                imageFactory.Rotate(diyInfo.RotationAngle);
                var ss = imageFactory.Image;
                //缩放
                Bitmap bm1 = new Bitmap(ss, Convert.ToInt32(ss.Width * diyInfo.TemplateZoom * diyInfo.PictureZoom), Convert.ToInt32(ss.Height * diyInfo.TemplateZoom * diyInfo.PictureZoom));
                //画布做图
                Bitmap huabu = new Bitmap(Convert.ToInt32(diyInfo.EditWidth), Convert.ToInt32(diyInfo.EditHeight));
                Graphics huabug = Graphics.FromImage(huabu);
                var neww = bm1.Width;
                var newh = bm1.Height;
                var x = Convert.ToInt32(diyInfo.CenterMarginLeft * diyInfo.TemplateZoom - neww / 2);
                var y = Convert.ToInt32(diyInfo.CenterMarginTop * diyInfo.TemplateZoom - newh / 2);
                Point ulCorner = new Point(x, y);
                huabug.DrawImage(bm1, ulCorner);
                huabu.Save(@"newbm.jpg");
      //创建一块指定大小的画布
                var bitmap = new Bitmap(200, 200);
                var huabug = Graphics.FromImage(bitmap);
                //在画布指定位置添加一张图片
                var ulCorner = new Point(50, 50);
                var newImage = Image.FromFile(@"C:\Users\wei.chen\Desktop\ConsoleApplication1\ConsoleApplication1\images\chrome.png");
                huabug.DrawImage(newImage, ulCorner);
                //在画布指定位置写文字
                //定义字体
                var frm = new PrivateFontCollection();
                frm.AddFontFile(@"C:\Users\wei.chen\Desktop\ConsoleApplication1\ConsoleApplication1\fonts\华康娃娃体.TTF");
                Font font = new Font(frm.Families[0], 11);
                //定义颜色
                SolidBrush sbrush = new SolidBrush(System.Drawing.ColorTranslator.FromHtml("#ff0000"));
                // 绘制围绕点旋转的文本
                PointF point = new PointF(50, 50);
                StringFormat format = new StringFormat();
                format.Alignment = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                Matrix mtxRotate = huabug.Transform;
                mtxRotate.RotateAt(90f, point); // 旋转角度和平移
                huabug.Transform = mtxRotate;
                huabug.DrawString("从前有座山", font, sbrush, point, format);
                bitmap.Save(@"newbm.jpg");
  • 相关阅读:
    MATLAB计算机视觉与深度学习实战
    硬件创业:从产品创意到成熟企业的成功路线图
    Xcode5 创建模板和UIView 关联XIB
    iOS Development: Proper Use of initWithNibName:bundle: Affects UITableViewController
    自定义UIViewController与xib文件关系深入分析
    UIViewController XIB/NIB加载过程
    ios多视图开发中:xib与UIViewController的关联
    UIAlertView、UIActionSheet兼容iOS8
    Xcode6中怎么添加空工程模板
    [OC Foundation框架
  • 原文地址:https://www.cnblogs.com/ideacore/p/6289570.html
Copyright © 2020-2023  润新知