在我的第一个 Activity 中,我使用glide加载图像
Glide.with(getBaseContext())
.load(image)
.asBitmap()
.into(new SimpleTarget<Bitmap>(myWidth, myHeight) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
content_image.setImageBitmap(resource);
}
});
现在我想在另一个 activity
中以全屏 imageView
显示相同的图像..
这是我在第一个 Activity 中编写的代码
public void openPoster(View v){
Toast.makeText(this,"Click sur l'image", Toast.LENGTH_SHORT).show();
Intent i =new Intent(this, Affiche.class);
Bitmap bitmap = ((BitmapDrawable)content_image.getDrawable()).getBitmap();
i.putExtra("imageBitmap", bitmap);
startActivity(i);
}
现在在第二个 Activity
Intent intent = getIntent();
Bitmap bmp = intent.getParcelableExtra("imageBitmap");
img.setImageBitmap(bmp);
最佳答案
Intent 没有记录数据限制,因此不要像那样发送位图。 Glide 使用 LRU 缓存,这意味着下次您通过 URL 请求图像时,您将从缓存中接收它,因此只需通过 Intent 发送图像 URL
关于java - 通过 Intent 传递图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33738165/