나는 다음과 같은 RGB888로 RGB565로 변환하는 코드와 그 반대를 반대 :이 나는 색상 정보의 손실을 가져 다시 rgb888로 변환됩니다 때RGB888 ~ RGB565 및 그 반대의 경우 정보가 손실됩니까?
public static void main(String[] args) {
// TODO code application logic here
System.out.println(Integer.toHexString(RGB888ToRGB565(0x11ffffff)));
System.out.println(Integer.toHexString(RGB565ToRGB888(RGB888ToRGB565(0x7FC9FF))));
}
static int RGB888ToRGB565(int red, int green, int blue) {
final int B = (blue >>> 3) & 0x001F;
final int G = ((green >>> 2) << 5) & 0x07E0;
final int R = ((red >>> 3) << 11) & 0xF800;
return (R | G | B);
}
static int RGB888ToRGB565(int aPixel) {
//aPixel <<= 8;
//System.out.println(Integer.toHexString(aPixel));
final int red = (aPixel >> 16) & 0xFF;
final int green = (aPixel >> 8) & 0xFF;
final int blue = (aPixel) & 0xFF;
return RGB888ToRGB565(red, green, blue);
}
static int RGB565ToRGB888(int aPixel) {
final int b = (((aPixel) & 0x001F) << 3) & 0xFF;
final int g = (((aPixel) & 0x07E0) >>> 2) & 0xFF;
final int r = (((aPixel) & 0xF800) >>> 8) & 0xFF;
// return RGBA
return 0x000000ff | (r << 24) | (g << 16) | (b << 8);
}
문제는 두 번째 줄에 있습니다. 비트 시프트 및 마스킹에 대해 더 많이 알고있는 사람이 나를 도와 줄 수 있습니까?
미리 감사드립니다.
http://stackoverflow.com/questions/2442576/how-does-one-convert-16-bit-rgb565-to-24-bit-rgb888을 확인 했습니까? –
물론 손실이 있습니다. 왜 당신은 손실을 기대하지 않겠습니까? –
예. 그렇습니다. 정말 도움이되지 않았습니다. 나는 손실이 있어야한다는 것을 알고 있지만, 나는 그 손실이 많을 것으로 기대하지 않습니다. –