2013-05-29 36 views
0

我要底紋從一種顏色逐漸另一個位圖(因此,如果它是怎麼回事,從沒有這麼紅煥發逐漸變得更紅。着色的位圖的另一種顏色

我每像素這樣做,但它會導致應用跳,可有人告訴我一個更有效的方法

private void adjustCountryBitmapColor() 
{ 
    //TODO Possible memory leak in this method. 
    mAllPixels = new int [ mCountryBitmap.getHeight()* mCountryBitmap.getWidth()]; 
    mCountryBitmap.getPixels(mAllPixels, 0, mCountryBitmap.getWidth(), 0, 0, mCountryBitmap.getWidth(),mCountryBitmap.getHeight()); 


    /* 
    int alpha=argb>>24; 
    int red=(argb & 0x00FF0000)>>16; 
    int green=(argb & 0x0000FF00)>>8; 
    int blue=(argb & 0x000000FF); 
    */ 

    for(int i =0; i< mCountryBitmap.getHeight()*mCountryBitmap.getWidth(); i++) 
    { 
     if(mAllPixels[i]>>24 == -1) 
     { 
      /*AllPixels[i] == Color.BLACK) 
      { 
       mAllPixels[i] = Color.RED; 
      } 
      */ 


      mAllPixels[i] = Color.RED; 


     } 
    } 

    System.out.println(mDeltaOffSet); 

    //int alpha = mAllPixels[0]>>24; 

    //System.out.println(alpha); 

    mCountryBitmap.setPixels(mAllPixels, 0, mCountryBitmap.getWidth(), 0, 0, mCountryBitmap.getWidth(), mCountryBitmap.getHeight()); 
} 
+0

沒有任何關於着色位圖的信息。 –

+0

我希望這將幫助你.. http://stackoverflow.com/questions/4354939/understanding-the-use-of-colormatrix-and-colormatrixcolorfilter-to-modify-a-draw – Mahesh

+0

@OllyDixon,看到我編輯的答案。 –

回答

0

不要創建中間位,那將花費太長時間;。正是出於這個原因,有Canvas#drawBitmap(int[],....)此外,有看是否Paint#setColorFilter()ColorMatrixFilterColorMatrix可以涵蓋您的顏色轉換。

+0

ColorMatrixFilter雖然不讓我遮蔽位圖,但只替換顏色。 –

0

我發現了一個使用GPU的好圖像處理庫。它速度如此之快,以至於你可以做實況相機以及即時圖像處理。

圖書館由提供javierpuntonet/android-gpuimage。只要看看它,我相信,你會得到使用它的好處。

+0

我無法每次重新創建位圖,因爲它每隔30秒就運行24次:P –

相關問題