您好我想将正常图像转换为镜像,即BLACKBERRY app中的翻转效果。我尝试过此代码但无法转换...有没有人帮我这样做...
如果您有不同的逻辑,请分享..
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 :(得分: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;
}