android 代码执行顺序,android程序不按正确执行顺序

classImage{publicBitmap image;public int imlen=0;//图像总像素数

public int width;//图像像素矩阵宽

public int height;//图像像素高

public int[] pixel;

}public class second extendsActivity{/**Called when the activity is first created.*/

private ImageButton btn1;//打开文件

private EditText edt3;//显示第二幅图片位置

private ImageButton btn3;//Embedded

public ImageButton btn4;//extract

private ImageButton btn5;//save

private EditText edt;//password

private EditText edt1;//message

privateImageView img1;publicProgressBar bar;public Random random = newRandom();public String key = null;static int[] epixel= null;public int p=0;//进度条提示

static int b=0;public Image spic = newImage();public Image fpic = new Image();//也许错

@Overridepublic voidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Intent intent=getIntent();

findview();

btn1.setOnClickListener(new MyButtonListener());//打开文件,寻找图片

setImg();

String location= intent.getStringExtra("location");

BitmapFactory.Options options= newBitmapFactory.Options();if(options != null && location != null)

{

options.inSampleSize= 2;

fpic.image= BitmapFactory.decodeFile(location, options);//get first image

if(fpic.image != null)

{

fpic.image= fpic.image.copy(Bitmap.Config.ARGB_8888, true);

fpic.imlen= (int) fpic.image.getHeight()*fpic.image.getWidth();

fpic.pixel= new int[fpic.imlen];

fpic.image.getPixels(fpic.pixel,0,fpic.image.getWidth(),0,0,fpic.image.getWidth(),fpic.image.getHeight());

btn3.setOnClickListener(newOnClickListener(){

@Overridepublic void onClick(View v) {//TODO Auto-generated method stub

if(b==0)

Toast.makeText(second.this,"请先从图库中选择图片或者拍照", Toast.LENGTH_SHORT).show();else

if(edt.getText().toString().length()==0)

Toast.makeText(second.this,"请先输入要密钥", Toast.LENGTH_SHORT).show();if(edt1.getText().toString().length()==0)

Toast.makeText(second.this,"请先输入要嵌入的内容", Toast.LENGTH_SHORT).show();else{try{

key=edt.getText().toString();byte[] message = edt1.getText().toString().getBytes("ASCII");//嵌入信息(Byte形式)

int[] embed = new int[message.length*8];

embed= match(message,fpic.pixel);//得到匹配序列

String slocation =edt3.getText().toString();

BitmapFactory.Options options= newBitmapFactory.Options();if(options != null && slocation != null)

{

options.inSampleSize= 2;

spic.image= BitmapFactory.decodeFile(slocation, options);//get first image

if(spic.image != null)

{

spic.image= spic.image.copy(Bitmap.Config.ARGB_8888, true);

spic.imlen= (int) spic.image.getHeight()*spic.image.getWidth();

spic.pixel= new int[spic.imlen];

spic.image.getPixels(spic.pixel,0,spic.image.getWidth(),0,0,spic.image.getWidth(),spic.image.getHeight());

}

}

spic.height=spic.image.getHeight();

spic.pixel= embeded(spic.pixel,embed,key);//嵌入匹配序列

edt.setText("");//将Password置空

edt1.setText("");//将嵌入信息置空

b=2;

}catch(Exception e) {//TODO Auto-generated catch block

e.printStackTrace();

}

}

}

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值