最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2007年03月12日 00:00:00   作者:  
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); //構(gòu)建圓角外部路徑
        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); //適當(dāng)空開一段距離        
        for (int i = 0; i < 30; i++) //加強(qiáng)亮度
            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;
    }
}

相關(guān)文章

  • 基于NVelocity的幾種內(nèi)容生成方式匯總

    基于NVelocity的幾種內(nèi)容生成方式匯總

    這篇文章主要介紹了基于NVelocity的幾種內(nèi)容生成方式匯總的相關(guān)資料,需要的朋友可以參考下
    2016-08-08
  • IIS上部署Asp.net core Webapi的實(shí)現(xiàn)步驟

    IIS上部署Asp.net core Webapi的實(shí)現(xiàn)步驟

    ASP.NET Core Web API是構(gòu)建RESTful應(yīng)用程序的理想平臺(tái),本文主要介紹了IIS上部署Asp.net core Webapi的實(shí)現(xiàn)步驟,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-07-07
  • ASP.NET?MVC下拉框中顯示枚舉項(xiàng)

    ASP.NET?MVC下拉框中顯示枚舉項(xiàng)

    這篇文章介紹了ASP.NET?MVC下拉框中顯示枚舉項(xiàng)的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-07-07
  • ASP.Net中的Server.MapPath()用法

    ASP.Net中的Server.MapPath()用法

    Server.MapPath(string path)作用是返回與Web服務(wù)器上的指定虛擬路徑相對(duì)應(yīng)的物理文件路徑,這篇文章主要介紹了ASP.Net中的Server.MapPath()用法,需要的朋友可以參考下
    2023-08-08
  • Asp.Net修改上傳文件大小限制方法

    Asp.Net修改上傳文件大小限制方法

    本文主要分享了Asp.Net修改上傳文件大小限制的方法--修改web.config,需要的朋友可以看下
    2016-12-12
  • 在ASP.NET Core中用HttpClient發(fā)送POST, PUT和DELETE請(qǐng)求

    在ASP.NET Core中用HttpClient發(fā)送POST, PUT和DELETE請(qǐng)求

    這篇文章主要介紹了在ASP.NET Core中用HttpClient發(fā)送POST, PUT和DELETE請(qǐng)求的方法,幫助大家更好的理解和學(xué)習(xí)使用ASP.NET Core,感興趣的朋友可以了解下
    2021-03-03
  • asp.net全局變量的實(shí)例方法

    asp.net全局變量的實(shí)例方法

    在本篇文章里小編給大家整理的是關(guān)于asp.net全局變量的實(shí)例方法和實(shí)例,需要的朋友們可以學(xué)習(xí)下。
    2020-02-02
  • NET Core TagHelper實(shí)現(xiàn)分頁(yè)標(biāo)簽

    NET Core TagHelper實(shí)現(xiàn)分頁(yè)標(biāo)簽

    這篇文章主要介紹了NET Core TagHelper實(shí)現(xiàn)分頁(yè)標(biāo)簽,講述實(shí)現(xiàn)一個(gè)簡(jiǎn)單分頁(yè)和總要注意步奏,感興趣的小伙伴們可以參考一下
    2016-07-07
  • asp.net mvc自定義pager封裝與優(yōu)化

    asp.net mvc自定義pager封裝與優(yōu)化

    這篇文章主要為大家詳細(xì)介紹了asp.net mvc自定義pager封裝與優(yōu)化,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • .Net獲取IP地址的方法

    .Net獲取IP地址的方法

    這篇文章主要介紹了.Net獲取IP地址的方法,本文給大家介紹的非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01

最新評(píng)論

荔波县| 永城市| 大荔县| 扎鲁特旗| 苍溪县| 阿拉善盟| 乐都县| 敦煌市| 涟源市| 杭锦旗| 皮山县| 大洼县| 勃利县| 大余县| 兖州市| 深水埗区| 沂水县| 乌鲁木齐县| 修文县| 定西市| 禄丰县| 阿克| 灵石县| 云梦县| 比如县| 舟曲县| 剑川县| 龙陵县| 金堂县| 贺州市| 泗阳县| 班戈县| 墨江| 华亭县| 静海县| 公安县| 邢台县| 奉贤区| 沈阳市| 淳化县| 仪征市|