我正在创建相框应用程序,我得到了两张图像,一张是来自 imagelist 数组的框架,另一张来自我的画廊。我已将此图像拖入框架,但现在我无法将这两个图像保存为单个图像以及它们当前的大小和位置。
我已将 frame(drawable) 设置为 imageview 并将上传的图像转换为位图。
我也尝试过使用画布,但它不起作用......我的代码是:
`if (requestCode == PICK_FROM_GALLERY) { Bundle extras2 = data.getExtras(); if (extras2 != null) { photo= extras2.getParcelable("data");
imgview.setImageBitmap(photo);
}
}
resultbitmap = Bitmap.createBitmap(frame.getWidth(),frame.getHeight(),Bitmap.Config.ARGB_8888);
canvas= new Canvas(resultbitmap);
canvas.drawBitmap(photo, 0, 0, null);
frame.draw(canvas);
save=(Button)findViewById(R.id.save);
save.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists ()) file.delete ();
try {
FileOutputStream out = new FileOutputStream(file);
resultbitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
Toast.makeText(getApplicationContext(), "Your Image:"+fname+"is stored in saved_images Folder in sd card", Toast.LENGTH_LONG).show();
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}`
请给出一些解决方案......我正在尝试很长时间......