AndroidGUI29:获取ImageView中的图像需要注意的问题(10)
Bitmap ret_bitmap =data.getParcelableExtra("ret_bitmap");
iv_photo.setScaleType(ScaleType.FIT_XY);
iv_photo.setImageBitmap(ret_bitmap);
}
super.onActivityResult(requestCode,resultCode, data);
}
// 简单的比较两个图像是否一致
private boolean compare2Image(Bitmap bmp1,Bitmap bmp2)
{
int iteration = 0;
int width = bmp1.getWidth();
int height = bmp1.getHeight();
if(width != bmp2.getWidth()) return false;
if(height != bmp2.getHeight()) return false;
if(width < height)
{
iteration = width;
}
else
{
iteration = height;
}
for(int i = 0; i < iteration; ++i)
{
if(bmp1.getPixel(i, i) != bmp2.getPixel(i,i)) return false;
}
return true;
}
}
5. 另外创建一个Activity,取名为TakePicture,并为它准备一个对应的layout文件takepicture.xml:
<?xml version="1.0"encoding="utf-8"?>
<LinearLayout
相关新闻>>
- 发表评论
-
- 最新评论 更多>>