rgb565 to rgb888 and back

Général

ripper121

il y a 1 an

Hi :),

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

aoneill

NEW il y a 1 an

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 il y a 1 an

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

ripper121

il y a 1 an

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 il y a 1 an

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

il y a 1 an

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 il y a 1 an

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