BitmapConfig中的几种ARGB值

作者: 金馆长说 | 来源:发表于2017-04-06 01:02 被阅读176次

我们创建图片的时候一般需要指定bitmap的色彩值
Bitmap有一个Config内部枚举里面有四种色彩模式
ARGB是四种颜色的简称,RGB也称为三原色。
A alpha 透明色
R RED 红色
G green 绿色
B blue 蓝色

ALPHA_8 代表8位Alpha位图 1字节
ARGB_4444 代表16位ARGB位图
ARGB_8888 代表32位ARGB位图
RGB_565 代表8位RGB位图
官方推荐使用ARGB_8888作为色彩模式,节省内存而且清晰度高

/**
     * Possible bitmap configurations. A bitmap configuration describes
     * how pixels are stored. This affects the quality (color depth) as
     * well as the ability to display transparent/translucent colors.
     */
    public enum Config {
        // these native values must match up with the enum in SkBitmap.h

        /**
         * Each pixel is stored as a single translucency (alpha) channel.
         * This is very useful to efficiently store masks for instance.
         * No color information is stored.
         * With this configuration, each pixel requires 1 byte of memory.
         */
        ALPHA_8     (1),

        /**
         * Each pixel is stored on 2 bytes and only the RGB channels are
         * encoded: red is stored with 5 bits of precision (32 possible
         * values), green is stored with 6 bits of precision (64 possible
         * values) and blue is stored with 5 bits of precision.
         *
         * This configuration can produce slight visual artifacts depending
         * on the configuration of the source. For instance, without
         * dithering, the result might show a greenish tint. To get better
         * results dithering should be applied.
         *
         * This configuration may be useful when using opaque bitmaps
         * that do not require high color fidelity.
         */
        RGB_565     (3),

        /**
         * Each pixel is stored on 2 bytes. The three RGB color channels
         * and the alpha channel (translucency) are stored with a 4 bits
         * precision (16 possible values.)
         *
         * This configuration is mostly useful if the application needs
         * to store translucency information but also needs to save
         * memory.
         *
         * It is recommended to use {@link #ARGB_8888} instead of this
         * configuration.
         *
         * Note: as of {@link android.os.Build.VERSION_CODES#KITKAT},
         * any bitmap created with this configuration will be created
         * using {@link #ARGB_8888} instead.
         *
         * @deprecated Because of the poor quality of this configuration,
         *             it is advised to use {@link #ARGB_8888} instead.
         */
        @Deprecated
        ARGB_4444   (4),

        /**
         * Each pixel is stored on 4 bytes. Each channel (RGB and alpha
         * for translucency) is stored with 8 bits of precision (256
         * possible values.)
         *
         * This configuration is very flexible and offers the best
         * quality. It should be used whenever possible.
         */
        ARGB_8888   (5);

        final int nativeInt;

        private static Config sConfigs[] = {
            null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888
        };

        Config(int ni) {
            this.nativeInt = ni;
        }

        static Config nativeToConfig(int ni) {
            return sConfigs[ni];
        }
    }
Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);

相关文章

  • BitmapConfig中的几种ARGB值

    我们创建图片的时候一般需要指定bitmap的色彩值Bitmap有一个Config内部枚举里面有四种色彩模式ARGB...

  • Android的 颜色和透明度

    概述 : ARGB 中 A 是不透明度,特别注意 颜色 Android中的颜色值通常遵循RGB/ARGB标准,使用...

  • Android 颜色透明度换算

    Android中的颜色值通常遵循RGB/ARGB标准,使用时通常以“#”字符开头,以16进制表示。 其中,ARGB...

  • Android颜色透明度

    Android中的颜色值通常遵循RGB/ARGB标准,使用时以#开头,以16进制表示。ARGB依次表示透明度(al...

  • OpenCV滤波

    图像通道在Android中默认是ARGB,在OpenCV中是BGRA。 RGB转灰度值公式:R*0.299+G*0...

  • 【转】关于透明色值

    转自:Android 颜色透明度换算 简介 颜色 Android中的颜色值通常遵循RGB/ARGB标准,使用时通常...

  • Android 颜色透明度换算

    简介 颜色 Android中的颜色值通常遵循RGB/ARGB标准,使用时通常以“#”字符开头,以16进制表示。 常...

  • Android颜色定义、设置、转换、拾取详解

    序言 Android中的颜色值通常遵循RGB/ARGB标准,使用时通常以“ # ”字符开头的8位16进制表示。其中...

  • Android滤镜--Alpha值滤镜处理之MaskFilter

    所谓的滤镜效果就是对图像进行一定的颜色过滤处理,颜色值是32位的int值,ARGB :A---Alpha值,RGB...

  • Bitmap的优化策略

    思路: 1、BitmapConfig的配置 2、使用decodeFile、decodeResource、decod...

网友评论

    本文标题:BitmapConfig中的几种ARGB值

    本文链接:https://www.haomeiwen.com/subject/nhdfattx.html