简体   繁体   English

在Blackberry中镜像图像

[英]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... 嗨,我想将普通图像转换为镜像,即BLACKBERRY应用中的翻牌效果。我已经尝试过此代码,但也无法转换...有没有人可以帮助我做到这一点...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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