//LOMO效果
public static Bitmap changeToLomo(Bitmap bitmap) {

int width = bitmap.getWidth();
int height = bitmap.getHeight();
int dst[] = new int[width*height];
bitmap.getPixels(dst, 0, width, 0, 0, width, height);

int ratio = width > height ? height*32768/width : width*32768/height;
int cx = width >> 1;
int cy = height >> 1;
int max = cx * cx + cy * cy;
int min = (int) (max * (1 - 0.8f));
int diff = max - min;

int ri, gi, bi;
int dx, dy, distSq, v;

int R, G, B;

int value;
int pos, pixColor;
int newR, newG, newB;
for(int y=0; y<height; y++){
for(int x=0; x<width; x++){
pos = y*width + x;
pixColor = dst[pos];
R = Color.red(pixColor);
G = Color.green(pixColor);
B = Color.blue(pixColor);

value = R<128 ? R : 256-R;
newR = (value*value*value)/64/256;
newR = (R<128 ? newR : 255-newR);

value = G<128 ? G : 256-G;
newG = (value*value)/128;
newG = (G<128 ? newG : 255-newG);

newB = B/2 + 0x25;

//==========边缘黑暗==============//
dx = cx - x;
dy = cy - y;
if (width > height)
dx = (dx * ratio) >> 15;
else
dy = (dy * ratio) >> 15;

distSq = dx * dx + dy * dy;
if (distSq > min){
v = ((max - distSq) << 8) / diff;
v *= v;

ri = (int)(newR * v) >> 16;
gi = (int)(newG * v) >> 16;
bi = (int)(newB * v) >> 16;

newR = ri > 255 ? 255 : (ri < 0 ? 0 : ri);
newG = gi > 255 ? 255 : (gi < 0 ? 0 : gi);
newB = bi > 255 ? 255 : (bi < 0 ? 0 : bi);
}
//==========边缘黑暗end==============//

dst[pos] = Color.rgb(newR, newG, newB);
}
}

Bitmap acrossFlushBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
acrossFlushBitmap.setPixels(dst, 0, width, 0, 0, width, height);
return acrossFlushBitmap;
}

LOMO效果的更多相关文章

  1. iOS滤镜实现之LOMO(美图秀秀经典LOMO)

    LOMO追求鲜艳色彩,随意.自由的态度,是一种经常使用的滤镜,今天介绍一下iOS 中LOMO滤镜的实现 首先它有3张输入图像 1.我们要处理的图像.即我们要应用LOMO滤镜的图像 2 3 在gpuim ...

  2. 图像滤镜艺术---LOMO Filter

    原文:图像滤镜艺术---LOMO Filter LOMO Filter LOMO是一种概念,即强调感受.机缘,弱化摄影技巧,不确定性和随意性是LOMO最大特点.LOMO源于Lomography,LOM ...

  3. PS教程1000例

    http://www.missyuan.com/thread-446934-1-1.html Photoshop绘制逼真头发发丝效果http://www.missyuan.com/thread-446 ...

  4. java 滤镜实现

    一句话,滤镜的实现就是对像素点(RGBA)进行再运算,输出新的像素点.    F(r,g,b,a)=G(r,g,b,a); 这个公式包含四个变换,即RGB颜色空间中RGB三个分量的变换以及透明度Alh ...

  5. opencv 一堆算法,图像处理等

    http://blog.csdn.net/wangzhebupt/article/category/1675453 数据挖掘十大经典实用算法及OpenCV算法 http://www.xuebuyuan ...

  6. 如何设计一个异步Web服务——接口部分

    需求比较简单,提供一个异步Web服务供使用者调用.比如说,某应用程序需要批量地给图片加lomo效果.由于加lomo效果这个操作非常消耗CPU资源,所以我们需要把这个加lomo效果的程序逻辑放到一台单独 ...

  7. [Android] 图像各种处理系列文章合集

        这是我近期在做Android随手拍一个项目的各种网上关于图片处理的资料,曾经学过数字图像处理都是用C++写的,以下的资料个人觉得是很优秀的各种集合,还有一方面它是在线笔记,希望对大家有所帮助吧 ...

  8. 关于Mongodb的全面总结

    MongoDB的内部构造<MongoDB The Definitive Guide> MongoDB的官方文档基本是how to do的介绍,而关于how it worked却少之又少,本 ...

  9. BootStrap入门教程 (四) :JQuery类库插件(模态窗口,滚动监控,标签效果,提示效果,“泡芙”效果,警告区域,折叠效果,旋转木马,输入提示)

    上讲回顾:Bootstrap组件丰富同时具有良好可扩展性,能够很好地应用在生产环境.这些组件包括按钮(Button),导航(Navigation),缩略图( thumbnails),提醒(Alert) ...

随机推荐

  1. JS中阻止默认事件与事件冒泡

    JQuery 提供了两种方式来阻止事件冒泡. 方式一:event.stopPropagation(); $("#div1").mousedown(function(event){ ...

  2. Why am I getting an error converting a Foo** → const Foo**?

    Because converting Foo** → const Foo** would be invalid and dangerous. C++ allows the (safe) convers ...

  3. linux下的文件权限管理

    权限管理有两个层面 第一层区分用户:文件属主(u), 组用户(g), 其它(o) 第二层区分权限:读(r),写(w),可执行(x) 这两个层次构成文件权限管理的二维结构 u         g     ...

  4. php大力力 [022节]php编程要有一种态度:渴望遇见麻烦

    2015-08-27 php大力力022.php编程要有一种态度:渴望遇见麻烦 不能一遇到问题和麻烦,就烦躁焦躁. 写程序,写代码,调试实验就是天天遇见不可预期的错误bug,这是常态.老生常谈,要适应 ...

  5. 当前页面js代码

    <script type="text/javascript"> var url = location.href; $(function(){ var url = loc ...

  6. To and Fro

    Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on th ...

  7. 【ajax】FormData

  8. 【ajax】xhr

    jQuery xhr: function() { return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP&quo ...

  9. OVS ARP Responder – Theory and Practice

    Prefix In the GRE tunnels post I’ve explained how overlay networks are used for connectivity and ten ...

  10. CentOS6编译装载nbd模块

    今天突然发现CentOS系统没有nbd模块,只能重新装下,下面记录下整个编译过程: 系统:CentOS6.5 内核:2.6.32-431.el6.x86_64 [root@localhost ~]# ...