2015-10-22 37 views
1

我正在嘗試在drawable中添加一個color filer,然後將它轉換爲位圖。問題是,當將drawable轉換成位圖時,它失去了它的顏色過濾器。我在imageview中使用了drawable,並且它具有顏色過濾器,但是在imageview中使用位圖沒有任何顏色效果。爲什麼會發生?提前致謝。Drawable在轉換爲位圖後丟失顏色過濾器

+0

可能重複:http://stackoverflow.com/questions/8937036/what-is-the-difference-在位圖和可繪製的Android之間 – selbie

+0

*你真的想做什麼?*你是否試圖將Drawable轉換回位圖。告訴我們你的代碼。 – selbie

+0

我想將一個顏色過濾器添加到繪圖並將其轉換爲位圖。 –

回答

0

用帆布做塊的繪製對象返回到一個位圖:

Canvas canvas; 
    Drawable drawable = <yourDrawable created from wherever>; 
    Bitmap bmp = <your Bitmap which is the same width/height as the drawable> 

    // blit the drawable onto the bitmap using a Canvas 
    canvas = new Canvas(bmp); 
    drawable.draw(canvas); 

http://developer.android.com/guide/topics/graphics/2d-graphics.html

+0

使用此代碼但結果不是預期的。我需要帶有可繪製濾鏡的位圖。 –