简体   繁体   中英

Mirroring the image in blackberry

Hi I want to convert normal image into mirror ie flop effect in BLACKBERRY app.I have tried this code but unable too convert...Is there anyone to help me to do this...

If you have a different logic to do this please share..

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;       
}

Your corner conditions seem wrong and the pixels you swipe are from the first row only. Try this:

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;       
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM