(Punch Filter)交叉冲印滤镜
本文介绍一种交叉冲印效果的代码实现,至于原理,不在累赘,直接看代码:
~~~
int f_TPunchFilter(unsigned char* srcData, int width, int height, int stride, unsigned char* dstData, int dw, int dh, int dStride)
{
if(srcData == NULL || dstData == NULL)
return -1;
unsigned char* pSrc = srcData;
unsigned char* pDst = dstData;
int i, j, gray, value, r, g, b;
int offset = stride - width * 4;
int rMap[256], gMap[256], bMap[256];
for(int i = 0;i<256;i++)
{
value = i < 128 ? i : 256 - i;
gray = value * value * value / 16384;
rMap[i] = i < 128 ? gray : 256 - gray;
gray = value * value / 128;
gMap[i] = i < 128 ? gray : 256 - gray;
bMap[i] = i / 2 + 0x25;
}
for(j = 0; j < height; j++)
{
for(i = 0; i < width; i++)
{
b = bMap[pSrc[0]];
g = gMap[pSrc[1]];
r = rMap[pSrc[2]];
pDst[0] = CLIP3(b,0,255);
pDst[1] = CLIP3(g,0,255);
pDst[2] = CLIP3(r,0,255);
pDst[3] = 255;
pSrc+=4;
pDst+=4;
}
pSrc += offset;
pDst += offset;
}
printf("%s","Welcom to our website: www.zealpixel.com");
return 0;
}
~~~
效果如下:
[![](https://box.kancloud.cn/2016-01-05_568b3322cfe5e.png)](http://www.zealpixel.com/data/attachment/portal/201507/28/163740f2ejdjrn4tfa6jt4.png)、
原图
[![](https://box.kancloud.cn/2016-01-05_568b332306d58.png)](http://www.zealpixel.com/data/attachment/portal/201507/28/163735roiwqoh3whh7kqwz.png)
交叉冲印效果图
最后放上一个完整的C#程序DEMO下载连接:[http://www.zealpixel.com/thread-68-1-1.html](http://www.zealpixel.com/thread-68-1-1.html)
- 前言
- 序言
- Brannan滤镜
- 编码基础(Photoshop基础变换的代码实现)
- Toaster滤镜
- Hudson滤镜(Instagram)
- 暴雨滤镜
- 大雪滤镜
- 图像滤镜实现万能方法研究
- 大雾效果滤镜
- 连环画滤镜
- 暗调滤镜
- 怀旧风格滤镜
- (Nostalgla Filter)老照片滤镜
- (Punch Filter)交叉冲印滤镜
- (Lightleaks Filter)漏光滤镜
- 漫画滤镜
- LOMO Filter
- Glow Filter发光滤镜
- (Instagram)1977滤镜
- (Sketch Filter)素描滤镜
- 水彩画滤镜
- 图像光照效果滤镜
- Oilpaint油画滤镜
- Swirl滤镜
- Wave滤镜
- 球面(Spherize)滤镜
- 挤压(Pinch)滤镜
- 旋转模糊滤镜
- 霓虹、浮雕、木刻滤镜
- 图像滤镜晕影调节算法研究
- PS平均(滤镜-模糊-平均)效果
- Photoshop实现Instagram Amaro滤镜特效
- Photoshop实现Instagram之Nashville滤镜
- Photoshop实现Instagram之Sierra滤镜
- Photoshop实现Instagram之Mayfair滤镜效果
- ZPhotoEngine超级算法库
- 乐高像素拼图特效
- 乐高像素拼图特效滤镜的代码实现
- 保留细节的磨皮滤镜之PS实现
- 保留细节的磨皮之C#程序实现
- 流行艺术风滤镜特效PS实现
- PS图层混合模式之明度模式