版权声明:本文为博主原创文章,未经博主允许不得转载。
1.修改色相、饱和度、亮度
参看:http://blog.csdn.NET/sjf0115/article/details/7267063
2.使用透明度通道,获取图片轮廓
参看:http://blog.csdn.Net/liu2604592/article/details/7759168
方法:
- //提取图像Alpha位图
- public static Bitmap getAlphaBitmap(Bitmap mBitmap,int mColor) {
- // BitmapDrawable mBitmapDrawable = (BitmapDrawable) mContext.getResources().getDrawable(R.drawable.enemy_infantry_ninja);
- // Bitmap mBitmap = mBitmapDrawable.getBitmap();
- //BitmapDrawable的getIntrinsicWidth()方法,Bitmap的getWidth()方法
- //注意这两个方法的区别
- //Bitmap mAlphaBitmap = Bitmap.createBitmap(mBitmapDrawable.getIntrinsicWidth(), mBitmapDrawable.getIntrinsicHeight(), Config.ARGB_8888);
- Bitmap mAlphaBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Config.ARGB_8888);
- Canvas mCanvas = new Canvas(mAlphaBitmap);
- Paint mPaint = new Paint();
- mPaint.setColor(mColor);
- //从原位图中提取只包含alpha的位图
- Bitmap alphaBitmap = mBitmap.extractAlpha();
- //在画布上(mAlphaBitmap)绘制alpha位图
- mCanvas.drawBitmap(alphaBitmap, 0, 0, mPaint);
- return mAlphaBitmap;
- }
deviceIV.setDrawingCacheEnabled(true);
deviceBmp = deviceIV.getDrawingCache();
时常会出现null,原因是超出系统提供最大的DrawingCache值,所以要在此代码前添加如下代码:
deviceIV.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
deviceIV.layout(0, 0, deviceIV.getMeasuredWidth(), deviceIV.getMeasuredHeight());
3.修改图片像素点的色值,动态修改图片
参看:http://blog.csdn.net/xys289187120/article/details/6580777