Crates.io | rgb565 |
lib.rs | rgb565 |
version | 0.1.3 |
source | src |
created_at | 2022-01-25 20:32:25.08102 |
updated_at | 2022-01-26 14:01:51.302642 |
description | Contains routines for working with RGB565 and converting it to RGB and sRGB |
homepage | |
repository | https://github.com/LoganDark/rgb565 |
max_upload_size | |
id | 521054 |
size | 48,424 |
rgb565
rgb565
provides deserialization, serialization and conversion routines for the
RGB565 pixel format, which stores color information in only 16 bits. The red
channel gets 5 bits, the green 6, and blue 5 again. The RGB565 format is often
used in embedded devices and microcontrollers for things like e-ink displays
that only have a low degree of color reproduction.
rgb565
includes out-of-the-box methods for converting to and from many
orderings and endiannesses, with each routine being manually verified,
automatically verified and also tested on physical devices that use the RGB565
format.
rgb565
comes with the optional ability to make use of look-up tables to gain
massive speed increases (up to 20%!) on embedded devices without a graphics
coprocessor. sRGB in particular gains a lot from LUTs because you usually need
floating-point math to correctly approximate the gamma curve.
You can control the inclusion of look-up tables using Cargo features:
swap_components_lut
to speed up loading and storing to BGR valuesl5_to_l8_lut
to speed up converting to 8-bit RGB red/blue channelsl6_to_l8_lut
to speed up converting to 8-bit RGB green channell5_to_s8_lut
to speed up converting to 8-bit sRGB red/blue channelsl6_to_s8_lut
to speed up converting to 8-bit sRGB green channell565_to_l888_lut
to speed up converting RGB565 values to 8-bit RGBl565_to_s888_lut
to speed up converting RGB565 values to 8-bit sRGBl8_to_l5_lut
to speed up converting from 8-bit RGB red/blue channelsl8_to_l6_lut
to speed up converting from 8-bit RGB green channels8_to_l5_lut
to speed up converting from 8-bit sRGB red/blue channelss8_to_l6_lut
to speed up converting from 8-bit sRGB green channelsl888_to_l565_lut
to speed up converting 8-bit RGB values to RGB565s888_to_l565_lut
to speed up converting 8-bit sRGB values to RGB565If you won't be using BGR565, then you don't need swap_components_lut
. If
you'll only be converting all three channels at once, then you don't need the
individual l/s#_to_l/s#_lut
features.
All LUTs are enabled by default except for l888_to_l565_lut
and
s888_to_l565_lut
, and you'll see why if you read this - the sizes of all the
LUTs is as follows:
swap_components_lut
: 128 KiB (131,072 bytes)l5_to_l8_lut
: 32 bytesl6_to_l8_lut
: 64 bytesl5_to_s8_lut
: 32 bytesl6_to_s8_lut
: 64 bytesl565_to_l888_lut
: 192 KiB (196,608 bytes)l565_to_s888_lut
: 192 KiB (196,608 bytes)l8_to_l5_lut
: 256 bytesl8_to_l6_lut
: 256 bytess8_to_l5_lut
: 256 bytess8_to_l6_lut
: 256 bytesl888_to_l565_lut
: 32 MiB (33,554,432 bytes)s888_to_l565_lut
: 32 MiB (33,554,432 bytes)That's because l888_to_l565_lut
and s888_to_l565_lut
both have to cover the
entire 16.777216-million-color space of 24-bit "true color", and I don't think
it would be very nice to add bloat like that by default.
$ cargo build
$ cargo test
This repository and all source code it contains is licensed under the MIT
License, mainly because I want to include it in libremarkable
, which is also licensed under MIT.