【问题标题】:Android how do I get the red, green and blue value from int RGB?Android 如何从 int RGB 中获取红色、绿色和蓝色值?
【发布时间】:2015-01-02 12:29:12
【问题描述】:

我正在使用 Palette 类从这样的位图中提取主要的 Vibrant 颜色:

     Palette.generateAsync(drawView.getDrawingCache(), new Palette.PaletteAsyncListener() {
            @Override
             public void onGenerated(Palette palette) {
             int color = palette.getVibrantColor(which);
              }
            });

但我还需要从颜色中获取红色、绿色和蓝色的值(范围为 0-255)。有什么想法吗?

【问题讨论】:

    标签: android colors


    【解决方案1】:

    以下代码将为您提供红、绿、蓝颜色代码:

    int color = (int)Long.parseLong(myColorString, 16);
    int r = (color >> 16) & 0xFF;
    int g = (color >> 8) & 0xFF;
    int b = (color >> 0) & 0xFF;
    

    【讨论】:

      猜你喜欢
      • 2014-08-26
      • 2017-07-09
      • 2022-12-06
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      相关资源
      最近更新 更多