java 图像特效之随机光晕

阅读本系列,请先看前言!谢谢 

光晕,听起来很美。实现起来也很简单,本文实现了一个随机光晕。属于比较简单的。那种美伦美幻的,比较复杂,先从简单的开始~

所谓光晕,就是中间特别亮,然后向四周递减,在最边缘达到和正常一样~,我们只要在一个随机圆的范围内,给图像增加亮度即可。

说完原理,来看代码:

public Image filter() {
		
		int[] d = new int[this.img.w*this.img.h]; //must be writed as this.not int[] d = this.img.data;
		int cenX = (int)(Math.random()*this.img.w);
		int cenY = (int)(Math.random()*this.img.h);
		int therash = this.img.w/6;
		for (int y = 0; y < this.img.h ; y++) {
            for (int x = 0; x < this.img.w; x++) {
            	d[x + y * this.img.w] = getRGB(cenX,cenY,x,y,therash);
            }
        }
		
		this.img.data = d;
		return this
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值