原文:图像滤镜艺术----Brannan滤镜

    作为第一篇文章,本人将介绍Instagram中Brannan 滤镜的实现过程,当然,是自己的模拟而已,结果差异敬请谅解。

    先看下效果图:

1 PS实现步骤:

1.1 打开测试图像,复制图层,命名为图层a;

1.2 对图层a进行去色操作,然后,打开色阶-绿色-调整如下:

1.3对当前图层a选择图层混合模式-滤色;

1.4新建图层b,填充颜色RGB(36,1, 34),选择图层混合模式-柔光,不透明度60%:

1.5新建图层c,填充颜色RGB(253,253,241),选择图层混合模式-正片叠底:

1.6合并所有图层,即可得到相应的效果图了;

2,程序实现:

<span style="font-size:14px;">public static Bitmap DoGrayEffect(Bitmap srcBitmap, int pxMode)
{
Bitmap src = new Bitmap(srcBitmap);
int w = src.Width;
int h = src.Height;
PixelFormat format = (pxMode == 0 ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, format);
Desaturate((byte*)srcData.Scan0, w, h, srcData.Stride, pxMode);
src.UnlockBits(srcData);
return src;
}</span>
<span style="font-size:14px;"> //色阶调整
public static Bitmap DoLevelAdjust(Bitmap srcBitmap, int DestChannel, int InputLeftLimit, int InputMiddle, int InputRightLimit, int OutputLeftLimit, int OutputRightLimit, int pxMode)
{
Bitmap src = new Bitmap(srcBitmap);
int w = src.Width;
int h = src.Height;
PixelFormat format = (pxMode == 0 ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, format);
LevelAdjust((byte*)srcData.Scan0, w, h, srcData.Stride, DestChannel, InputLeftLimit, InputMiddle, InputRightLimit, OutputLeftLimit, OutputRightLimit, pxMode);
src.UnlockBits(srcData);
return src;
}</span>
<span style="font-size:14px;">//图层混合模式
        public static Bitmap DoEffect(Bitmap srcBitmap, Bitmap mxBitmap, int pxMode, int effectMode)
        {
            Bitmap src = new Bitmap(srcBitmap);
            Bitmap mx = new Bitmap(mxBitmap);
            int w = src.Width;
            int h = src.Height;
            PixelFormat format = (pxMode == 0 ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
            BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, format);
            BitmapData mxData = mx.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, format);
            DoSpecialEffect((byte*)srcData.Scan0, (byte*)mxData.Scan0, w, h, srcData.Stride, pxMode, effectMode);
            src.UnlockBits(srcData);
            mx.UnlockBits(mxData);
            return src;
        }
        //单色图层混合模式
        public static Bitmap DoSingleColorEffect(Bitmap srcBitmap, int r, int g, int b, int pxMode, int effectMode)
        {
            Bitmap src = new Bitmap(srcBitmap);
            int w = src.Width;
            int h = src.Height;
            PixelFormat format = (pxMode == 0 ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
            BitmapData srcData = src.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, format);
            byte* p = (byte*)srcData.Scan0;
            int seg = (pxMode == 0 ? 3 : 4);
            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    DoPixelEffect(p, r, g, b, effectMode);
                    p += seg;
                }
                p += srcData.Stride - w * seg;
            }
            src.UnlockBits(srcData);
            return src;
        }</span>
<span style="font-size:14px;">        //Brannan 滤镜
public static Bitmap BrannanFilter(Bitmap srcBitmap, int pxMode)
{
Bitmap temp = DoGrayEffect(srcBitmap, 0);//去色
Bitmap leBmp = DoLevelAdjust(temp, 2, 0, 128, 232, 0, 250, 0);//绿色色阶调整
Bitmap filterBmp = DoEffect(srcBitmap, leBmp, 0, (int)EffectMode.MODE_FILTERCOLOR);//滤色
temp = DoSingleColorEffect(filterBmp, 22, 1, 20, 0, (int)EffectMode.MODE_SMOOTHLIGHT);//柔化
temp = DoSingleColorEffect(temp, 253, 253, 241, 0, (int)EffectMode.MODE_MULTIPLY);//正片叠底
return temp;
}</span>

PSD文件及C代码DEMO免费下载链接:点击打开链接

 

最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:

 

最新文章

  1. php面向对象中的静态与抽象,接口
  2. [刘阳Java]_Java环境搭建_第2讲
  3. Quartz 2D 图形上下文栈 矩阵 裁剪
  4. IIS6.0中布署MVC站点(转)
  5. 遍历input。select option 选中的值
  6. 转载linq to sql 的详解
  7. Tomcat 8熵池阻塞变慢详解(转)
  8. [Angular 2] Filter items with a custom search Pipe in Angular 2
  9. DOM的发展,DOM0,DOM1,DOM2,DOM3
  10. Amazon email system中使用的字体
  11. 音乐app各部分笔记(一)
  12. oracle query
  13. 别致的语言GO(GO语言初涉)
  14. (笔记)boa服务器make错误
  15. css内边距 边框
  16. 9-16Jenkins-2定时任务
  17. P3455 [POI2007]ZAP-Queries
  18. PHP开发札记-星期/周操作中常用的日期获取方法
  19. Mysql 的表级锁和行级锁
  20. 利用pandas进行数据分析之三:DataFrame与Series基本功能

热门文章

  1. Freemarker中的null判断,小坑一枚
  2. Tomcat8及之后版本出现的The valid characters are defined in RFC 7230 and RFC 3986
  3. [Node.js] Identify memory leaks with nodejs-dashboard
  4. 【BZOJ 1012】 [JSOI2008]最大数maxnumber(线段树做法)
  5. mysql常用控制台命令
  6. mysql 数据库 添加查询 修改 删除
  7. lucene 7.x 分词 TokenStream的使用及源码分析
  8. 【25.47%】【codeforces 733D】Kostya the Sculptor
  9. 经典书单 —— 语言/算法/机器学习/深度学习/AI/CV/PGM
  10. javascript 获取上一周的时间