【问题标题】:How to crop a bitmap in image view in android and show in next it in next activity?如何在android的图像视图中裁剪位图并在下一个活动中显示它?
【发布时间】:2015-03-03 10:25:48
【问题描述】:

我想裁剪我在Linearayout 的图像视图中设置的bitmap。我正在使用此代码。裁剪 "cropimage" 的代码是什么?

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen4);
        // Screen3.crop
        ImageView cropimage = (ImageView) findViewById(R.id.cropimage);
        bm = Screen3.crop;
        cropimage.setImageBitmap(bm);

 }//onCreate 

【问题讨论】:

标签: android bitmap android-imageview crop resize-crop


【解决方案1】:

也许这就是你想要的:

imageView.setDrawingCacheEnabled(true);
Bitmap bmCache = imageView.getDrawingCache();
Bitmap bm = null;
if (bmCache != null) {
    bm = Bitmap.createBitmap(bmCache);
}
cropimage.setImageBitmap(bm);
imageView.destroyDrawingCache();
imageView.setDrawingCacheEnabled(false);

【讨论】:

  • 它不工作:(。就像没有输出显示甚至图像没有显示。
  • 我想在运行时裁剪图像,然后在下一个活动中显示它。就像应用程序运行时一样,它会显示一个图像。然后我将它裁剪成矩形,然后在下一个活动中显示该裁剪图像。你能解释一下这是怎么可能的吗?
  • 你说的,第一个activity中ImageView中的图片,只需getDrawingCache并克隆一份,然后通过intent putExtra,第二个activity就可以拿到了。
  • 你不知道什么: 1.如何裁剪图像? 2. 如何在两个activity之间传递内容?你的意思是什么?
  • 我只想裁剪图像..我该怎么做?请帮忙
猜你喜欢
  • 2016-01-11
  • 1970-01-01
  • 2014-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
  • 1970-01-01
相关资源
最近更新 更多