Color conversion in Blender to RGB565 format

The output pixel color format for rendering in Blender is RGBA in the linear color space. If we need to save the render in RGB565 format, such a format is used, for example, in some old games, the color values of the pixels must be converted.

For example, let’s take the color value for one pixel from the image data from the compositing Viewer Node.

First, we need to convert it to the sRGB color space:

Having received a color value in the generally used 2D color space, we can now convert it to the format we need.

Let’s define a function to convert color from the RGBA format to the RGB565 format:

In the function parameter, we pass the color value in the RGBA format – a set of four values, each in the range from 0 to 255. At the output, we get a two-byte RGB565 value in the range from 0 to 65536.

To save the whole image, each of its pixels needs to be processed through our function, resulting in an array of values in RGB565 format, which can already be saved to a file.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments