vnc: Add a conversion function for bgr888.
This commit is contained in:
parent
aceeecb192
commit
a08cfd797b
2 changed files with 36 additions and 2 deletions
|
@ -52,8 +52,10 @@ VideoConvert::VideoConvert(Mode input_mode, Mode output_mode, int _width,
|
||||||
: inputMode(input_mode), outputMode(output_mode), width(_width),
|
: inputMode(input_mode), outputMode(output_mode), width(_width),
|
||||||
height(_height)
|
height(_height)
|
||||||
{
|
{
|
||||||
if (inputMode != bgr565 && inputMode != rgb565 && inputMode != bgr8888)
|
if (inputMode != bgr565 && inputMode != rgb565 &&
|
||||||
fatal("Only support converting from bgr565, rdb565, and bgr8888\n");
|
inputMode != bgr8888 && inputMode != bgr888)
|
||||||
|
fatal("Only support converting from bgr565, rdb565, "
|
||||||
|
"bgr8888 and bgr888\n");
|
||||||
|
|
||||||
if (outputMode != rgb8888)
|
if (outputMode != rgb8888)
|
||||||
fatal("Only support converting to rgb8888\n");
|
fatal("Only support converting to rgb8888\n");
|
||||||
|
@ -76,6 +78,8 @@ VideoConvert::convert(const uint8_t *fb) const
|
||||||
return m565rgb8888(fb, false);
|
return m565rgb8888(fb, false);
|
||||||
case bgr8888:
|
case bgr8888:
|
||||||
return bgr8888rgb8888(fb);
|
return bgr8888rgb8888(fb);
|
||||||
|
case bgr888:
|
||||||
|
return bgr888rgb8888(fb);
|
||||||
default:
|
default:
|
||||||
panic("Unimplemented Mode\n");
|
panic("Unimplemented Mode\n");
|
||||||
}
|
}
|
||||||
|
@ -136,6 +140,29 @@ VideoConvert::bgr8888rgb8888(const uint8_t *fb) const
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t*
|
||||||
|
VideoConvert::bgr888rgb8888(const uint8_t *fb) const
|
||||||
|
{
|
||||||
|
uint8_t *out = new uint8_t[area() * sizeof(uint32_t)];
|
||||||
|
uint32_t *out32 = (uint32_t*)out;
|
||||||
|
|
||||||
|
typedef uint8_t In24[3];
|
||||||
|
const In24 *in24 = (In24 *)fb;
|
||||||
|
for (int x = 0; x < area(); x++) {
|
||||||
|
Rgb8888 outpx = 0;
|
||||||
|
|
||||||
|
outpx.blue = in24[x][0];
|
||||||
|
outpx.green = in24[x][1];
|
||||||
|
outpx.red = in24[x][2];
|
||||||
|
outpx.alpha = 0xFF;
|
||||||
|
|
||||||
|
out32[x] = outpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint64_t
|
uint64_t
|
||||||
VideoConvert::getHash(const uint8_t *fb) const
|
VideoConvert::getHash(const uint8_t *fb) const
|
||||||
|
|
|
@ -133,6 +133,13 @@ class VideoConvert
|
||||||
*/
|
*/
|
||||||
uint8_t* bgr8888rgb8888(const uint8_t *fb) const;
|
uint8_t* bgr8888rgb8888(const uint8_t *fb) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a bgr888 input to rgb8888.
|
||||||
|
* @param fb the data to convert
|
||||||
|
* @return converted data
|
||||||
|
*/
|
||||||
|
uint8_t* bgr888rgb8888(const uint8_t *fb) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a bgr565 or rgb565 input to rgb8888.
|
* Convert a bgr565 or rgb565 input to rgb8888.
|
||||||
* @param fb the data to convert
|
* @param fb the data to convert
|
||||||
|
|
Loading…
Reference in a new issue