gpt4 book ai didi

java - Android 在传递 byte[] 时返回到之前的 Activity

转载 作者:行者123 更新时间:2023-11-30 01:42:37 24 4
gpt4 key购买 nike

我遇到了烦人的错误:

12-12 03:46:48.241 23461-23461/com.cronline.haito.projectbeggining W/EGL_genymotion: eglSurfaceAttrib not implemented
12-12 03:46:48.241 23461-23461/com.cronline.haito.projectbeggining E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
12-12 03:46:48.245 23461-23461/com.cronline.haito.projectbeggining E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
12-12 03:46:48.245 23461-23461/com.cronline.haito.projectbeggining D/OpenGLRenderer: Enabling debug mode 0

当我尝试打开某些图像时会发生这种情况,当它发生时会返回到之前的 Activity 。

我不知道是什么原因造成的。它仅在传递某些照片时发生。但我找不到它们之间的区别,因为我有几乎 2 个相同的图像,一个会导致问题,而另一个则不会。它们具有相同的分辨率 685x960 和 60KB 的大小。

代码:

Passing to the second activity
Intent intent = new Intent(getActivity(), EditorActivity.class);
intent.putExtra("image", BitmapTransformer.compress(bitmap));
startActivity(intent);

压缩和解压方法:

public static byte[] compress(Bitmap bmp){
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 80, stream);
return stream.toByteArray();
}
public static Bitmap decompress(byte[] data){
return BitmapFactory.decodeByteArray(data, 0, data.length);
}

并接收图像:

Intent intent = getIntent();
byte[] imageAsByteArray = intent.getExtras().getByteArray("image");
Bitmap bitmap = BitmapTransformer.decompress(imageAsByteArray);

导致问题的图像: https://www.dropbox.com/sh/ylwhbpdx41w6x2u/AAAUtQsYppge5kb7dEBHuouHa?dl=0

最佳答案

你要把你的位图保存到文件中,只发送文件名的路径,然后再次从路径中读取。是位置

关于java - Android 在传递 byte[] 时返回到之前的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34238099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com