版權聲明:本文為博主原創文章,未經博主允許不得轉載。
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