mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix RGB565 to RBG888
This commit is contained in:
parent
18e15559b7
commit
01ed312fdf
@ -264,9 +264,15 @@ void PikaCV_Converter_toRGB888(PikaObj* self, PikaObj* image) {
|
||||
if (img->format == PikaCV_ImageFormat_Type_RGB565) {
|
||||
for (int i = 0; i < img->size; i += 2) {
|
||||
uint16_t* p565 = (uint16_t*)&data[i];
|
||||
uint32_t buf888 = 0;
|
||||
uint32_t* pbuf888 = (uint32_t*)&buf888;
|
||||
*pbuf888 = ((*p565 & 0xF800) << 8) | ((*p565 & 0x07E0) << 5) |
|
||||
((*p565 & 0x001F) << 3);
|
||||
uint32_t* p888 = (uint32_t*)&data_new[i / 2 * 3];
|
||||
*p888 = ((*p565 & 0xF800) << 8) | ((*p565 & 0x07E0) << 5) |
|
||||
((*p565 & 0x001F) << 3);
|
||||
|
||||
((uint8_t*)p888)[0] = ((uint8_t*)pbuf888)[2];
|
||||
((uint8_t*)p888)[1] = ((uint8_t*)pbuf888)[1];
|
||||
((uint8_t*)p888)[2] = ((uint8_t*)pbuf888)[0];
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ void PikaCV_Transforms_rotateDown(PikaObj* self, PikaObj* image) {
|
||||
pika_assert(0);
|
||||
return;
|
||||
}
|
||||
if (img->format == PikaCV_ImageFormat_Type_BGR888 ||
|
||||
img->format == PikaCV_ImageFormat_Type_RGB888) {
|
||||
if ((img->format != PikaCV_ImageFormat_Type_BGR888) &&
|
||||
(img->format != PikaCV_ImageFormat_Type_RGB888)) {
|
||||
obj_setErrorCode(self, PIKA_RES_ERR_OPERATION_FAILED);
|
||||
__platform_printf("unsupported image format\n");
|
||||
return;
|
||||
|
@ -264,9 +264,15 @@ void PikaCV_Converter_toRGB888(PikaObj* self, PikaObj* image) {
|
||||
if (img->format == PikaCV_ImageFormat_Type_RGB565) {
|
||||
for (int i = 0; i < img->size; i += 2) {
|
||||
uint16_t* p565 = (uint16_t*)&data[i];
|
||||
uint32_t buf888 = 0;
|
||||
uint32_t* pbuf888 = (uint32_t*)&buf888;
|
||||
*pbuf888 = ((*p565 & 0xF800) << 8) | ((*p565 & 0x07E0) << 5) |
|
||||
((*p565 & 0x001F) << 3);
|
||||
uint32_t* p888 = (uint32_t*)&data_new[i / 2 * 3];
|
||||
*p888 = ((*p565 & 0xF800) << 8) | ((*p565 & 0x07E0) << 5) |
|
||||
((*p565 & 0x001F) << 3);
|
||||
|
||||
((uint8_t*)p888)[0] = ((uint8_t*)pbuf888)[2];
|
||||
((uint8_t*)p888)[1] = ((uint8_t*)pbuf888)[1];
|
||||
((uint8_t*)p888)[2] = ((uint8_t*)pbuf888)[0];
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ void PikaCV_Transforms_rotateDown(PikaObj* self, PikaObj* image) {
|
||||
pika_assert(0);
|
||||
return;
|
||||
}
|
||||
if (img->format == PikaCV_ImageFormat_Type_BGR888 ||
|
||||
img->format == PikaCV_ImageFormat_Type_RGB888) {
|
||||
if ((img->format != PikaCV_ImageFormat_Type_BGR888) &&
|
||||
(img->format != PikaCV_ImageFormat_Type_RGB888)) {
|
||||
obj_setErrorCode(self, PIKA_RES_ERR_OPERATION_FAILED);
|
||||
__platform_printf("unsupported image format\n");
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user