【发布时间】:2015-10-16 01:22:36
【问题描述】:
我有一些奇怪的问题。我从int[] 像素阵列设置了一个灰度Bitmap。所以我把这个
bitmap = Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888);
byte[] byteArray = new String(pixelsArray).getBytes("UTF-8");
Bitmap bitmap = getBitmapFromByte(byteArray, pixelsArray.length);
ImageView theImage = (ImageView) findViewById(R.id.echo);
theImage.setImageBitmap(bitmap);
问题是我得到了正确的图像,但是是红色的。所以我认为这与保存位图的ImageView 包装器有关。
<LinearLayout
android:id="@+id/some_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/theme_blue"
android:orientation="vertical">
<ImageView
android:id="@+id/echo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/some_image" />
所以我放了
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.vMiddle);
linearLayout.setBackgroundColor(Color.BLACK);
但它仍然显示为红色。有人有想法吗?顺便说一句,我在一个测试纯 java 应用程序上测试了 int[] 像素数组,它以灰度颜色正确显示。
【问题讨论】: