Beispiel #1
0
        public void DrawImage(Chain.Model.Mem mem, string FromUserName)
        {
            Bitmap   smallWeiXin = new Bitmap(130, 130);
            Image    weixinImg   = QRCodeImage.CreateQRCode(mem.MemCard);
            Graphics g           = Graphics.FromImage(smallWeiXin);

            g.DrawImage(weixinImg, new Point(-35, -35));
            string savePath  = base.Server.MapPath("~/Upload/WeiXin/Images/" + FromUserName + ".jpg");
            Bitmap bigWeiXin = new Bitmap(200, 200);

            g = Graphics.FromImage(bigWeiXin);
            g.DrawImage(smallWeiXin, new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 130, 130), GraphicsUnit.Pixel);
            string bg     = base.Server.MapPath("~/Upload/WeiXin/Images/bg.jpg");
            Bitmap result = new Bitmap(bg);

            g = Graphics.FromImage(result);
            g.DrawImage(bigWeiXin, new RectangleF(50f, 60f, 200f, 200f), new RectangleF(0f, 0f, 200f, 200f), GraphicsUnit.Pixel);
            g.DrawString("NO:" + mem.MemCard, new Font("微软雅黑", 34f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 70f));
            g.DrawString("积分:" + mem.MemCard, new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 115f));
            g.DrawString("余额:" + mem.MemMoney.ToString("F2"), new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 160f));
            string pastStr = (mem.MemPastTime.ToString("yyyy-MM-dd") == "2900-01-01") ? "有效期:永久有效" : ("有效期:" + mem.MemPastTime.ToString("yyyy-MM-dd"));

            g.DrawString(pastStr, new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 205f));
            result.Save(savePath, ImageFormat.Jpeg);
        }
Beispiel #2
0
        public void DrawImage(Chain.Model.Mem mem, string FromUserName)
        {
            Bitmap   smallWeiXin = new Bitmap(130, 130);
            Image    weixinImg   = QRCodeImage.CreateQRCode(mem.MemCard);
            Graphics g           = Graphics.FromImage(smallWeiXin);

            g.DrawImage(weixinImg, new Point(-35, -35));
            string savePath  = this.Server.MapPath("~/Upload/WeiXin/Images/" + FromUserName + ".jpg");
            Bitmap bigWeiXin = new Bitmap(200, 200);

            g = Graphics.FromImage(bigWeiXin);
            g.DrawImage(smallWeiXin, new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 130, 130), GraphicsUnit.Pixel);
            string bg    = this.Server.MapPath("~/Upload/WeiXin/Images/bg.jpg");
            Image  bgImg = Image.FromFile(bg, true);
            Bitmap bmp   = new Bitmap(bgImg.Width, bgImg.Height, PixelFormat.Format32bppArgb);

            g = Graphics.FromImage(bmp);
            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode      = SmoothingMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.DrawImage(bgImg, new Rectangle(0, 0, bgImg.Width, bgImg.Height), new Rectangle(0, 0, bgImg.Width, bgImg.Height), GraphicsUnit.Pixel);
            g.DrawImage(bigWeiXin, new RectangleF(50f, 60f, 200f, 200f), new RectangleF(0f, 0f, 200f, 200f), GraphicsUnit.Pixel);
            g.DrawString("NO:" + mem.MemCard, new Font("微软雅黑", 34f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 70f));
            g.DrawString("积分:" + mem.MemCard, new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 115f));
            g.DrawString("余额:" + mem.MemMoney.ToString("F2"), new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 160f));
            string pastStr = (mem.MemPastTime.ToString("yyyy-MM-dd") == "2900-01-01") ? "有效期:永久有效" : ("有效期:" + mem.MemPastTime.ToString("yyyy-MM-dd"));

            g.DrawString(pastStr, new Font("微软雅黑", 30f, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new PointF(280f, 205f));
            bmp.Save(savePath, ImageFormat.Jpeg);
        }