- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
getHolder().setFormat(PixelFormat.RGBA_888);
Options options = new BitmapFactory.Options();
options.inDither=true;
options.inScaled = true;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inPurgeable=true;
(使用上述选项创建的位图)
当使用上面的代码时,我得到以下结果.........
测试手机 (Samsung Galaxy Ace) 上有明显的色带
getHolder().setFormat(PixelFormat.RGBA_888);
Options options = new BitmapFactory.Options();
options.inDither=true;
options.inScaled = true;
options.inPreferredConfig = Bitmap.Config.ARGB_565;
options.inPurgeable=true;
我的平板电脑上没有色带
结果同上
getHolder().setFormat(PixelFormat.RGB_565);
Options options = new BitmapFactory.Options();
options.inDither=true;
options.inScaled = true;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inPurgeable=true;
我的平板电脑上出现色带
SG Ace 上的色带
getHolder().setFormat(PixelFormat.RGB_565);
Options options = new BitmapFactory.Options();
options.inDither=true;
options.inScaled = true;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inPurgeable=true;
我的平板电脑上出现色带
因此,总而言之,似乎只有 PixelFormat.xxxx 部分有所不同。我的理解是这是设置holder的颜色格式。这将影响绘制的所有内容。 (即,一切都将采用该格式)。
有人可以解释下一行的目的吗?
options.inPreferredConfig = Bitmap.Config.xxxxxxx
这似乎对已经绘制的位图没有任何影响。
性能是最重要的,所以我可能不得不更改我的原始 png 文件,使它们没有渐变,(即,将它们绘制为 RGB565 - 这是可取的还是我应该坚持使用 8888?)或者应该抖动排序出去? (因为如您所见,我启用了它,但它似乎没有帮助)。
知道为什么 Ace 上总是有 strip 吗?会不会是硬件限制?
谢谢,这一切都非常困惑。
(PS 我已经阅读了官方指南,在向 SO 发布问题以及查看其他相关的 SO 问题之前,我总是先看一下,但是官方指南(通常是这种情况)并不清楚这是我的问题,我无法通过其他问题找到答案,如果已经在这里,我深表歉意。
最佳答案
565 格式是默认格式,因为它可以更快地绘制并且需要更少的处理能力。至于你的SG Ace,我相信前段时间只有部分Android版本支持8888色。
要让我的应用程序背景之一不带,我必须执行以下操作:
1 - 将背景添加到可绘制文件夹
2 - 使用以下内容创建 background_dithered.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="true"
android:src="@drawable/background" />
3 - 在 Activity 代码中:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
getWindow().setFormat(PixelFormat.RGBA_8888);
}
关于Android 颜色格式(RGB565、ARGB8888),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15177943/
所以我有一个项目可以通过使用算法更改 argb 值来手动将图像转换为黑白图像。我已经尝试对 RGB 值进行平均,我得到了一个几乎完全灰度的图像,但其中仍然有一些颜色。谁有手动将 aRGB 中的像素转换
我有一个 ARGB 图像数据。我希望将我的窗口图标设置为该数据。经过几个小时的搜索后,我仍然处于起点,手头一无所有。我知道我需要为图像数据创建一个像素图和(可能是)另一个用于掩码的像素图,并使用提示来
我正在学习 C#,我试图解决的以下问题是将一个数字存储为字符串并获取 a、r、g、b 值。 所以我想从 string s = "4280427042"; 到 int a = 255; int r =
对于 ARGB 颜色图,我有四个整数值 (0 - 255)。 现在我想制作这四个整数的唯一浮点数或整数。是否可以像下面那样做? sum = 4 * 255 + A; sum += 3 * 255 +
我正在尝试使用 MakeColor GDIPAPI 单元中的方法,但来自 int 的转换至 byte没有返回给我正确的值。 例子 var argbStr: string; A, R,
this 中的颜色表全部不透明。我猜 A 的值设置为 FF。 透明度代码是什么? 例如这个颜色FFF0F8FF(AliceBlue),改为透明代码,如??F0F8FF ? 最佳答案 以下是 % 到十六
哪种方法允许将 ARGB 转换为字符串作为 'int, int, int' ?例子。 $Main 背景颜色设置为字符串 '0, 100, 200' 。返回 $Main.BackColor 给出 ARG
在as3中,是否有实用程序或函数可以将RGB颜色(例如0xFF0000)和alpha值(例如0.5)转换为A 32位ARGB值? 从 ARGB 到 RGB + alpha? 一些解释:位图数据可以在其
这段代码非常适合我想要做的事情(设置缓冲图像上像素的颜色/alpha),但我不知道它为什么起作用。语法是什么意思?我无法找到有关它的文档。 int rgb = (alpha << 24) | red
假设我有: int x = 140; 我想得到的结果: int y = new Color(x, x, x).getRGB() 来自 Java API 文档: getRGB() Gets the RG
我正在尝试将 ARGB 十六进制 String 解析为 int 但它不起作用。 我的代码: int color = Integer.parseInt("ff686868", 16); 异常(excep
我需要制作透明度,有 2 个像素: pixel1: {A, R, G, B} - foreground pixel pixel2: {A, R, G, B} - background pixel A,
谁能告诉我如何从 ARGB 计算出相应的窗口颜色?我知道有一个 ColorTranslator.ToWin32() 可以进行计算,但它是如何完成的? 另外,OLE 颜色和 Windows (win32
嗯,我正在努力研究我的车牌检测算法,需要一些简单的帮助。 基本上我正在尝试执行以下操作,代码是不言自明的,我只是找不到我正在尝试实现的示例。 提前致谢 if (img.GetPixel(bottomR
我正在开发一个简单的控制台应用程序,您可以在其中输入一个 ARGB 值的十六进制代码,该应用程序会告诉您该值的红色、绿色、蓝色和 Alpha 内容(共 255 个)。 例如: Enter a 32-b
我正在尝试在图像上设置水印(字符串)和具有一定不透明度(css 属性)的 pdf(带有 itext) 所以,不透明度是一个浮点类型,一切都适用于 pdf,因为它有方法 PdfGState gstate
我正在尝试创建一种方法,将两种 ARGB 颜色(第二个在顶部)混合为 alpha 为 0xFF 的颜色,我可能是盲目的,但经过 30 分钟的谷歌搜索后,我似乎找不到一种方法来做到这一点。而且这个方法必
如何将 TYPE_INT_ARGB 的 BufferedImage 保存为 jpg? 程序为我生成了那个图像: 没关系,但是当我以这种方式保存时: ByteArrayOutputStream
我正在尝试创建使用随机颜色的小型应用程序。 Random rnd = new Random(); int color1 = Color.argb(255, rnd.nextInt(25
在我的小程序中,我使用了不同的 BufferedImage 并将它们用作屏幕部件。每个屏幕部分只会在内容需要更改时重新绘制。 这是抽象的 ScreenPart 类: public abstract c
我是一名优秀的程序员,十分优秀!