即使图像正确显示为白色,图像也不会完全显示白色 [英] Image does not show completely white despite it's correctly white

查看:156
本文介绍了即使图像正确显示为白色,图像也不会完全显示白色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于启动画面,我使用包含白色背景(纯白色 - 在Photoshop中检查)的图像。由于某种原因,它显示一个微小的绿色bg与活动的默认白色bg - 在截图中标记。只在某些设备中,如

For a splashscreen I use an image which contains a white background (pure white - checked in Photoshop). For some reason it shows a slight green bg vs. the activity's default white bg - as marked in the screenshot. Only in some devices, like the

我在框架布局中将此作为单一视图添加到活动:

I add this as single view in a frame layout to the activity:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitCenter"
    android:src="@drawable/splashscreen" />

</FrameLayout>

任何想法?我阅读关于RGB888与RGB565问题,但找不到一个正确的解决方案。

Any idea? I read about RGB888 vs. RGB565 issues, but couldn't find a proper solution.

注意:我确定可以将图片中的白色更改为透明,但希望了解问题并找到正确的解决方案。

Note: I sure could make change the white in the image to transparent, but would prefer to understand the problem and find a proper solution.

推荐答案

这真的很烦人。我不知道,为什么这么少的人遇到这个问题,因为它应该出现在所有的32位显示器。

This is really annoying. I wonder, why so few people encountered this problem as it should appear on all 32-bit displays.

你提到了关于RGB888格式。问题的原因是,无论APK文件中的原始位图格式,所有位图都被压缩(在我的情况下,转换为索引256色!wtf?)。

You mentioned right about RGB888 format. The cause of the problem is that regardless of the original bitmap format in the APK files all bitmaps are compressed (in my case into indexed 256-color! wtf?).

但是,我发现了两个解决方案对于白色问题。

However, I found two solutions for the white color problem.

1)每位图:说,我们有一个可绘制的位图资源 @ drawable / mypng ,这会导致问题。我们需要添加一个额外的XML drawable drawable / mypng_nofilter.xml

1) Per-bitmap: Say, we have a drawable bitmap resource called @drawable/mypng, which causes the problem. We need to add an additional XML drawable drawable/mypng_nofilter.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/mypng"
    android:filter="false"
/>

并使用 @ drawable / mypng_nofilter

2)对于整个活动:在onCreate方法的活动中,我们需要添加

2) For entire activity: In activity onCreate method we need to add

getWindow().setFormat(PixelFormat.RGB_565);

现在窗口有16位颜色深度,所有位图都显示为正确白色。

Now the window has 16-bit color depth and all bitmaps appear "properly" white.

再次,我希望有32位颜色深度,但我不知道如何控制编译时图像压缩。

Again, I would prefer to have 32-bit color depth, but I don't know how to control compile-time image compression.

这篇关于即使图像正确显示为白色,图像也不会完全显示白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆