rgb565 to rgb888 and back

General

ripper121

6 years ago

Hi :),

is there a short and fast function to convert the RGB565 to RGB888 and back again?

aoneill

NEW 6 years ago

There is https://gamebuino.com/academy/reference/gb-createcolor for going from rgb888 to rgb565. 

I see rgb565Torgb888 in Misc.cpp to go the other way, but I'm guessing it was written assuming it would only be used internally in the library.

Sorunome

NEW 6 years ago

I'd like to add that rgb888 -> rgb565 has dataloss, as we are downsampling a 24-bit cilor to a 16-bit one

ripper121

6 years ago

Thats no problem.

I have an ESP32 with a OV7670 Camera. 

The Camera only outputs RGR565, but for me its easier to work with RGB888 Values.

ripper121

NEW 6 years ago

Sorunome Sorunome

Thats no problem.

I have an ESP32 with a OV7670 Camera. 

The Camera only outputs RGR565, but for me its easier to work with RGB888 Values.

Sorunome

6 years ago

Well, you can always use the method aoniell pointed out by pre-declaring it.


EDIT:

something like this should do (untested):

#include <utils/Misc.h>

// and then
Gamebuino_Meta::RGB888 rgb = Gamebuino_Meta::rgb565Torgb888(0x1234);

rgb.r; // red
rgb.g; // green
rgb.b; // blue

Sorunome

NEW 6 years ago

ripper121 ripper121

Well, you can always use the method aoniell pointed out by pre-declaring it.


EDIT:

something like this should do (untested):

#include <utils/Misc.h>

// and then
Gamebuino_Meta::RGB888 rgb = Gamebuino_Meta::rgb565Torgb888(0x1234);

rgb.r; // red
rgb.g; // green
rgb.b; // blue