【梅开二度】修改图片颜色

linxun   ·   发表于 3个月前   ·   IAPP
直接贴代码:
//获取bitmap
sbp(图像路径,bitmap)
//颜色
s color=颜色
//(colorInt)
java(ci,null,"android.graphics.Color.parseColor","String",color)
//获取宽高
tcc(bitmap,"w",w)
tcc(bitmap,"h",h)
//获取config并创建位图
java(config,bitmap,"android.graphics.Bitmap.getConfig")
//(outPutBitmap)
java(optBitmap,null,"android.graphics.Bitmap.createBitmap","int",w,"int",h,"android.graphics.Bitmap$Config",config)
//新建Canvas和Paint
javanew(canvas,"android.graphics.Canvas","android.graphics.Bitmap",optBitmap)
//↑这里Canvas和optBitmap绑定
javanew(paint,"android.graphics.Paint")
//这个mode可以是SRC_IN(整个修改颜色)、SRC_ATOP(覆盖颜色),这里在带透明度颜色上尤其明显
javags(mode,null,"android.graphics.PorterDuff$Mode","SRC_ATOP")
//(porterDuffColorFilter)
javanew(ptcf,"android.graphics.PorterDuffColorFilter","int",ci,"android.graphics.PorterDuff$Mode",mode)
java(null,paint,"android.graphics.Paint.setColorFilter","android.graphics.ColorFilter",ptcf)
//绘制
java(null,canvas,"android.graphics.Canvas.drawBitmap","android.graphics.Bitmap",bitmap,"float",0,"float",0,"android.graphics.Paint",paint)
//现在optBitmap上已经绘制了,直接设置就可以了
us(id,"src",optBitmap)

0 Reply   |  Until 3个月前 | 237 View
LoginCan Publish Content