2012-04-02 91 views
1

嗨我想轉換成鏡像,即在BLACKBERRY應用中的翻轉效果。我試過這段代碼,但無法轉換...有沒有人幫我做到這一點...鏡像黑莓中的圖像

如果你有不同的邏輯來做到這一點,請分享..

public Bitmap changetoFlopEffect(Bitmap bitmap){ 

    int[] argb = new int[bitmap.getWidth() * bitmap.getHeight()]; 
    int[] newargb =new int[bitmap.getWidth() * bitmap.getHeight()]; 
    int length=bitmap.getWidth(); 

    bitmap.getARGB(argb, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); 

    for(int i=0;i<=bitmap.getHeight();i++) 
    { 
     for(int j=bitmap.getWidth(),k=0;j>0;j--) 
     { 
       //newargb[k]=argb[j]; 
       int swap=argb[j]; 
       newargb[k]=swap; 
       k++; 
     } 
    } 
     bitmap.setARGB(newargb,0,bitmap.getWidth(),0,0,bitmap.getWidth(),bitmap.getHeight()); 
    return bitmap;  
} 
+0

這是什麼問題?我的意思是一些像素鏡像?發表一些你得到的圖片 – tipycalFlow 2012-04-03 05:43:56

回答

0

你的角落條件似乎錯了,你刷卡像素僅從第一行。試試這個:

public Bitmap changetoFlopEffect(Bitmap bitmap){ 

int[] argb = new int[bitmap.getWidth() * bitmap.getHeight()]; 
int[] newargb =new int[bitmap.getWidth() * bitmap.getHeight()]; 
int length=bitmap.getWidth(); 
int newIndex = 0; 

bitmap.getARGB(argb, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); 

for (int i = 0; i < bitmap.getHeight(); i++) 
    for (int j = bitmap.getWidth()-1; j >= 0 ; j--){ 
    newargb[newIndex] = argb[i * bitmap.getWidth() + j]; 
    newIndex++; 
    } 
    bitmap.setARGB(newargb,0,bitmap.getWidth(),0,0,bitmap.getWidth(),bitmap.getHeight()); 
return bitmap;  
} 
+0

我已經在回覆之前解決了這個問題....但是你的回覆輸出比我好。所以謝謝你......你能幫我消極和單色的圖像...回覆 – 2012-04-03 06:17:45

+0

我用javax.microedition.amms.control.imageeffect的ImageEffectControll接口。我發現這個鏈接http://www.blackberry.com/developers/docs/6.0.0api/javax/microedition/amms/control/imageeffect/ImageEffectControl.html 這是爲monochrom和負面影響.. 如果你有此解決方案請分享你的邏輯。 – 2012-04-03 06:29:56

+0

回覆我的這個主題 - 如何在黑莓應用程序中對圖像應用單色和負面效果。 – 2012-04-03 08:42:19