欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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)文章

  • .NET中如何將文本文件的內(nèi)容存儲到DataSet

    .NET中如何將文本文件的內(nèi)容存儲到DataSet

    大家在項(xiàng)目中比較多的會對文件進(jìn)行操作,例如文件的上傳下載,文件的壓縮和解壓等IO操作。而在.NET項(xiàng)目中較多的會使用DataSet,DataTable進(jìn)行數(shù)據(jù)的緩存。每一個(gè)DataSet都是一個(gè)或多個(gè)DataTable對象的集合,本文主要介紹的是如何將文本文件的內(nèi)容存儲到DataSet里去。
    2016-12-12
  • asp.net上傳execl文件后,在頁面上加載顯示(示例代碼)

    asp.net上傳execl文件后,在頁面上加載顯示(示例代碼)

    本篇文章主要是對asp.net上傳execl文件后,在頁面上加載顯示(示例代碼)進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-02-02
  • WPF實(shí)現(xiàn)左右移動(晃動)動畫效果

    WPF實(shí)現(xiàn)左右移動(晃動)動畫效果

    這篇文章主要為大家詳細(xì)介紹了WPF實(shí)現(xiàn)左右移動或晃動動畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • ASP.NET Core WebAPI實(shí)現(xiàn)本地化(單資源文件)

    ASP.NET Core WebAPI實(shí)現(xiàn)本地化(單資源文件)

    這篇文章主要介紹了ASP.NET Core WebAPI實(shí)現(xiàn)本地化(單資源文件),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • .NET 6開發(fā)TodoList應(yīng)用之實(shí)現(xiàn)查詢排序

    .NET 6開發(fā)TodoList應(yīng)用之實(shí)現(xiàn)查詢排序

    這篇文章主要介紹了如何通過.NET 6實(shí)現(xiàn)查詢排序功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí).NET 6有一定的幫助,感興趣的同學(xué)可以了解一下
    2022-01-01
  • ASP.NET小結(jié)之MVC, MVP, MVVM比較以及區(qū)別(二)

    ASP.NET小結(jié)之MVC, MVP, MVVM比較以及區(qū)別(二)

    上一篇得到大家的關(guān)注,非常感謝。由于自己對于這些模式的理解也是有限,對于MVC,MVP,MVVM這些模式的比較,是結(jié)合自己的理解,一些地方不一定準(zhǔn)確,需要的朋友可以參考下
    2014-05-05
  • 使用Aspose.Cells實(shí)現(xiàn)導(dǎo)入導(dǎo)出

    使用Aspose.Cells實(shí)現(xiàn)導(dǎo)入導(dǎo)出

    這篇文章主要為大家詳細(xì)介紹了如何使用Aspose.Cells實(shí)現(xiàn)導(dǎo)入導(dǎo)出,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • throw的一些用法

    throw的一些用法

    無論是.net還是java,在開發(fā)程序時(shí)都難免會用到throw關(guān)鍵字
    2013-02-02
  • asp.net服務(wù)器端指令include的使用及優(yōu)勢介紹

    asp.net服務(wù)器端指令include的使用及優(yōu)勢介紹

    將指定文件的內(nèi)容插入 ASP.NET 文件中,包括網(wǎng)頁(.aspx 文件)、用戶控件文件(.ascx 文件)和 Global.asax 文件
    2013-04-04
  • .Net插件框架Managed Extensibility Framework簡介

    .Net插件框架Managed Extensibility Framework簡介

    這篇文章介紹了.Net插件框架Managed Extensibility Framework,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07

最新評論