圖像特效---(Punch Filter)交叉沖印濾鏡


(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.zealfilter.com");return 0; }

程序demo:點擊打開鏈接


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com