android RGB565格式位图

android RGB565 format bitmap

我正在尝试在 Anki Vector 机器人上显示图像。 我的 Android 应用程序从 canvas 绘制位图,然后使用“createBitmap”方法将其转换为 RGB_565 格式。因为这里指定显示为RGB565: https://vector.ikkez.de/generated/anki_vector.screen.html#module-anki_vector.screen

createBitmap(宽度, 高度, Bitmap.Config.RGB_565);

结果似乎成功,但颜色通道不正确。

RGB 与 BRG 一样被订购。 作为解决方法,我相应地交换了频道。 但现在橙色和黄色似乎互换了。 当我画 orange 时,显示器显示黄色。当我画黄色时,它显示橙色。 可能是什么问题?

为了交换频道,我使用了以下代码:

public Bitmap swapC(Bitmap srcBmp) {

    int width = srcBmp.getWidth();
    int height = srcBmp.getHeight();

    float srcHSV[] = new float[3];
    float dstHSV[] = new float[3];

    Bitmap dstBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);

    for (int row = 0; row < height; row++) {
        for (int col = 0; col < width; col++) {
            int pixel = srcBmp.getPixel(col, row);
            int alpha = Color.alpha(pixel);
            int redC = Color.red(pixel);
            int greenC = Color.green(pixel);
            int blueC = Color.blue(pixel);
            dstBitmap.setPixel(col, row, Color.argb(alpha,blueC,redC,greenC));
        }
    }

    return dstBitmap;
}

我已经使用变通方法作为解决方案;将颜色通道值除以 8 :

public Bitmap swapC(Bitmap srcBmp) {

    int width = srcBmp.getWidth();
    int height = srcBmp.getHeight();

    float srcHSV[] = new float[3];
    float dstHSV[] = new float[3];

    Bitmap dstBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    for (int row = 0; row < height; row++) {
        for (int col = 0; col < width; col++) {
            int pixel = srcBmp.getPixel(col, row);
            int alpha = Color.alpha(pixel);
            int redC = Color.red(pixel);
            int greenC = Color.green(pixel);
            int blueC = Color.blue(pixel);
            dstBitmap.setPixel(col, row, Color.argb(alpha,blueC/8,redC/8,greenC/8));
        }
    }

    return dstBitmap;
}