一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

asp.net下GDI+的一些常用應用(水印,文字,圓角處理)技巧

public class MyGDI
{
    public static void CreateWatermark(string sSrcFilePath, string sDstFilePath, string sText1, string sColor1, string sSize1, string sFont1, string sText2, string sColor2, string sSize2, string sFont2, string sBgColor, string sTransparence)
    {
        System.Drawing.Image image = System.Drawing.Image.FromFile(sSrcFilePath);
        Graphics g = Graphics.FromImage(image);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
        g.CompositingQuality = CompositingQuality.HighQuality;
        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //文字抗鋸齒
        g.DrawImage(image, 0, 0, image.Width, image.Height);
        Font f1 = new Font(sFont1, float.Parse(sSize1));
        Font f2 = new Font(sFont2, float.Parse(sSize2));
        Brush brushfortext1 = new SolidBrush(ColorTranslator.FromHtml(sColor1));
        Brush brushfortext2 = new SolidBrush(ColorTranslator.FromHtml(sColor2));
        Brush brushforbg = new SolidBrush(Color.FromArgb(Convert.ToInt16(255 * float.Parse(sTransparence)), ColorTranslator.FromHtml(sBgColor)));
        g.RotateTransform(-20);
        Rectangle rect = new Rectangle(-image.Width/2-50, image.Height - 50, image.Width * 2, 40);
        g.DrawRectangle(new Pen(brushforbg), rect);
        g.FillRectangle(brushforbg, rect);
        Rectangle rectfortext1 = new Rectangle(-image.Width/2 + image.Width / 5, image.Height - 45, image.Width * 2, 60);
        for (int i = 0; i < 10; i++)
            g.DrawString(sText1, f1, brushfortext1, rectfortext1);
        Rectangle rectfortext2 = new Rectangle(-image.Width / 2 + image.Width / 5, image.Height -25, image.Width * 2, 60);
        for (int i = 0; i < 10; i++)
            g.DrawString(sText2, f2, brushfortext2, rectfortext2);
        image.Save(sDstFilePath, ImageFormat.Jpeg);
        image.Dispose();
    }
    public static void CreateRoundedCorner(string sSrcFilePath, string sDstFilePath, string sCornerLocation)
    {
        System.Drawing.Image image = System.Drawing.Image.FromFile(sSrcFilePath);
        Graphics g = Graphics.FromImage(image);
        g.SmoothingMode = SmoothingMode.HighQuality;
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
        g.CompositingQuality = CompositingQuality.HighQuality;
        Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
        GraphicsPath rectPath = CreateRoundRectanglePath(rect, image.Width / 10, sCornerLocation); //構建圓角外部路徑
        Brush b = new SolidBrush(Color.White);//圓角背景白色
        g.DrawPath(new Pen(b), rectPath);
        g.FillPath(b, rectPath);
        g.Dispose();
        image.Save(sDstFilePath, ImageFormat.Jpeg);
        image.Dispose();
    }
    public static void CreatePlainText(string sSrcFilePath, string sDstFilePath,string sText, string sColor, string sSize, string sFont)
    {
        System.Drawing.Image image = System.Drawing.Image.FromFile(sSrcFilePath);
        Graphics g = Graphics.FromImage(image);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
        g.CompositingQuality = CompositingQuality.HighQuality;
        g.DrawImage(image, 0, 0, image.Width, image.Height);
        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //文字抗鋸齒
        Font f = new Font(sFont,float.Parse(sSize));
        Brush b = new SolidBrush(ColorTranslator.FromHtml(sColor));
        Rectangle rect = new Rectangle(10, 5, image.Width, image.Height); //適當空開一段距離        
        for (int i = 0; i < 30; i++) //加強亮度
            g.DrawString(sText, f, b, rect);
        image.Save(sDstFilePath, ImageFormat.Jpeg);
        image.Dispose();
    }
    private static GraphicsPath CreateRoundRectanglePath(Rectangle rect, int radius, string sPosition)
    {
        GraphicsPath rectPath = new GraphicsPath();
        switch (sPosition)
        {
            case "TopLeft":
                {
                    rectPath.AddArc(rect.Left, rect.Top, radius * 2, radius * 2, 180, 90);
                    rectPath.AddLine(rect.Left, rect.Top, rect.Left, rect.Top + radius);
                    break;
                }
            case "TopRight":
                {
                    rectPath.AddArc(rect.Right - radius * 2, rect.Top, radius * 2, radius * 2, 270, 90);
                    rectPath.AddLine(rect.Right, rect.Top, rect.Right - radius, rect.Top);
                    break;
                }
            case "BottomLeft":
                {
                    rectPath.AddArc(rect.Left, rect.Bottom - radius * 2, radius * 2, radius * 2, 90, 90);
                    rectPath.AddLine(rect.Left, rect.Bottom - radius, rect.Left, rect.Bottom);
                    break;
                }
            case "BottomRight":
                {
                    rectPath.AddArc(rect.Right - radius * 2, rect.Bottom - radius * 2, radius * 2, radius * 2, 0, 90);
                    rectPath.AddLine(rect.Right - radius, rect.Bottom, rect.Right, rect.Bottom);
                    break;
                }
        }
        return rectPath;
    }
}

AspNet技術asp.net下GDI+的一些常用應用(水印,文字,圓角處理)技巧,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久精品国产亚洲综合色 | 国产午夜在线观看视频播放 | 成年美女黄网站色大片免费软件看 | 网红福利在线 | 波多野结衣在线影院 | 中文字幕在线视频一区 | 91免费影视| 亚洲乱人伦精品图片 | 日韩免费视频播放 | 国产视频一二区 | 国产一区高清 | 久久性视频 | 欧美中文字幕一二三四区 | 四虎影视永久在线精品免费 | 另类一区二区三区 | 激情视频激情小说激情图片 | 天天做天天爱夜夜爽女人爽宅 | 欧美日韩中文国产一区二区三区 | 成人午夜无人区一区二区 | 激情在线视频 | 欧美成人网7777视频 | 伊人久久国产精品 | 成人福利在线看 | 男人精品网站一区二区三区 | 香蕉免费一区二区三区在线观看 | 看全色黄大色黄大片大学生 | 色婷婷综合在线 | 黑人美国一级一级爰片 | 综合激情区视频一区视频二区 | 国产成人一区在线播放 | 性欧美zoz0另类xxxx | 特黄一级毛片 | 国产99er66在线视频 | 天天色天天干天天射 | 亚洲天堂五月天 | 日韩大胆人体 | 国产精品第100页 | 4k岛国精品午夜高清在线观看 | www.色婷婷.com| 亚洲国产成人最新精品资源 | 久久婷婷激情综合色综合也去 |