課程
/移動開發(fā)
/Android
/Android圖像處理-打造美圖秀秀從它開始
為啥不能直接在原來的bitmap上直接操作?
2016-01-26
源自:Android圖像處理-打造美圖秀秀從它開始 3-1
正在回答
?
在canvas類中你可以看到無論是構造方法還是setBitmap(Bitmap bitmap) 中都有
if (!bitmap.isMutable()) {
? ? ? ? ? ? throw new IllegalStateException(
? ? ? ? ? ? ? ? ? ? ? ? ? ? "Immutable bitmap passed to Canvas constructor");
? ? ? ? }
就是說如果bitmap不可改變的情況下,canvas是不允許進行繪制的,當你用BitmapFactory.decodeResource,返回的bitmap是默認狀態(tài)下的mIsMutable=false;(其他方法應該也是一樣的,你自己可以看看),而Bitmap.createBitmap()中可以看到返回的是?
Bitmap bm = nativeCreate(null, 0, width, width, height, config.nativeInt, true);這最后一個參數(shù)是true的也就是?mutable,說可以改變的位圖
? ? private static native Bitmap nativeCreate(int[] colors, int offset,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int stride, int width, int height,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int nativeConfig, boolean mutable);
舉報
圖像色彩的分析與處理,演示市面上常見的圖像處理特效的實現(xiàn)方法
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2016-01-26
?
在canvas類中你可以看到無論是構造方法還是setBitmap(Bitmap bitmap) 中都有
if (!bitmap.isMutable()) {
? ? ? ? ? ? throw new IllegalStateException(
? ? ? ? ? ? ? ? ? ? ? ? ? ? "Immutable bitmap passed to Canvas constructor");
? ? ? ? }
就是說如果bitmap不可改變的情況下,canvas是不允許進行繪制的,當你用BitmapFactory.decodeResource,返回的bitmap是默認狀態(tài)下的mIsMutable=false;(其他方法應該也是一樣的,你自己可以看看),而Bitmap.createBitmap()中可以看到返回的是?
Bitmap bm = nativeCreate(null, 0, width, width, height, config.nativeInt, true);這最后一個參數(shù)是true的也就是?mutable,說可以改變的位圖
? ? private static native Bitmap nativeCreate(int[] colors, int offset,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int stride, int width, int height,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int nativeConfig, boolean mutable);