zoukankan      html  css  js  c++  java
  • 小日本的图片处理C#类

        本来想写一个将图片处理成磨砂玻璃的函数,从网上找到一个C#的类,小日本的代码,功能较多,没有注释。处理出来的效果还可以,但不是我想要的
    ImageUtils.cs

    用这个类写的“磨砂玻璃”效果如下:

    代码:
            public static bool FrostedGlass(ref Bitmap bmp, Rectangle rect,
                
    int alphaPercent, int blurZone)
            {
                
    if (bmp.PixelFormat != PixelFormat.Format24bppRgb)
                    
    return false;

                
    int w = bmp.Width;
                
    int h = bmp.Height;

                Bitmap tmp 
    = new Bitmap(rect.Width, rect.Height,
                                             PixelFormat.Format24bppRgb);
                Graphics g 
    = Graphics.FromImage(tmp);
                g.DrawImage(bmp, 
    00, rect, GraphicsUnit.Pixel);
                g.Dispose();

                ImgUtils.GaussianBlur(
    ref tmp, blurZone);

                Bitmap tmp2 
    = tmp.Clone() as Bitmap;
                g 
    = Graphics.FromImage(tmp2);
                g.Clear(Color.FromArgb(
    244244244));
                ImgUtils.JAlphaBlend(g, tmp, (
    float)alphaPercent / 100f, 00);
                g.Dispose();

                tmp.Dispose();

                g 
    = Graphics.FromImage(bmp);
                g.DrawImageUnscaled(tmp2, rect.Left, rect.Top);
                g.Dispose();

                tmp2.Dispose();

                
    return true;
            }

            
    private void button1_Click(object sender, EventArgs e)
            {
                Bitmap bmp 
    = new Bitmap(@"C:¥Home¥img2¥reika1.png");

                Graphics g 
    = this.CreateGraphics();
                
    //g.DrawImageUnscaled(bmp, 5, 5);

                
    if (FrostedGlass(ref bmp, new Rectangle(8850219550), 503))
                {
                    g.DrawImageUnscaled(bmp, 
    55);
                    Clipboard.SetImage(bmp);
                }

                g.Dispose();
                bmp.Dispose();
            }


  • 相关阅读:
    2019-2020-1 20175228 实验四 外设驱动程序设计
    2019-2020-1 20175228 实验三 实时系统
    2019-2020-1-20175332 20175323 20175228 实验一开发环境的熟悉
    2018-2019-2 20175228实验五《Java网络编程》实验报告
    2018-2019-2 20175228实验四《Android开发基础》实验报告
    2018-2019-2 20175228实验三《敏捷开发与XP实践》实验报告
    MyCP
    2018-2019-2 20175228实验二《面向对象程序设计》实验报告
    2018-2019-2 20175228实验一《Java开发环境的熟悉》实验报告
    转()析构函数
  • 原文地址:https://www.cnblogs.com/yuanbao/p/953507.html
Copyright © 2011-2022 走看看