Fast and accurate screen/image color depth conversion #displays #images

When converting between low-bit color color formats (R4G4B4A4, R5G6B6, R8G8B8A8, and so on), the conversion routines used often don’t map to the nearest color channel values in the target bit depth.

For example, when converting 8 bit to 4 bit colors, this is typically done by simply the discarding the lower 4 bits of each channel. This is fast, but not very accurate; the maximum error of this method is 15 units in the source range compared to an error of 8 units when mapping to the closest value.

Inspired by this stackoverflow answer, which lists a method of expanding 5 and 6 bit color channels to their closest equivalent 8 bit value with a cheap combination of integer multiplication, addition and shifting, threadlocalmutex.com has devised a table lists conversion formulas for mapping between UNORM ranges of 4, 5, 6, 8, 10 and 11 bits with correct rounding. This is enough to cover all common color formats (4444, 555, 565, 8888, 10-10-10, 11-11-10) and build fast and accurate conversion routines for them.

See the table in the post here.


Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 11/15/2024 Featuring Adafruit bq25185 USB / DC / Solar Charger with 3.3V Buck Board! (Video)

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: A New Arduino MicroPython Package Manager, How-Tos and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — The 2024 Recap Issue!

Maker Business – Adafruit Daily — Apple to build another chip at TSMC Arizona

Electronics – Adafruit Daily — SMT Tip – Stop moving around!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !


No Comments

No comments yet.

Sorry, the comment form is closed at this time.