b. 当touch down OK按钮btn_photo时(用来模拟保存数据的动作),再次从iv_photo中获取图像,然后和a中获得的图像进行比较,并进行进一步的处理。
4. Compare2Images的代码如下:
package com.waveline.compare2images;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.os.Bundle;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.ImageView.ScaleType;
public class Compare2Images extends Activity
implements
OnTouchListener
{
private Bitmap obmp;
private ImageView iv_photo;
private Button btn_photo;
@Override
public void onCreate(BundlesavedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iv_photo =(ImageView)findViewById(R.id.iv_photo);
iv_photo.setOnTouchListener(this);
btn_photo = (Button)findViewById(R.id.btn_photo);
btn_photo.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEventevent)
{
switch(v.getId())
{
case R.id.iv_photo: