🎨 HiColor is a program for converting images to 15- and 16-bit RGB color

Overview

HiColor

A building with a dithered gradient of the sky behind it.  A jet airplane is taking off in the sky.

HiColor is a program for converting images to 15- and 16-bit RGB color, the color depth of old display modes known as “high color”. In 15-bit mode images have 5 bits for each of red, green, and blue, and the last bit is reserved. In 16-bit mode green, the color the human eye is generally most sensitive to, gets 6 bits.

I wrote this program because I wanted to create images with the characteristic high-color look, and nothing seemed to support high color. It implements its own simple file format and converts between this format and PNG. It can also convert normal PNG to normal 32-bit PNG with only high color color values. (This simulates a roundtrip through HiColor without creating a temporary file.) To reduce the quantization error (the difference between the original and the high-color pixel), HiColor uses the Bayer ordered dithering algorithm, which historical software and hardware used for dithering in high color modes. Dithering can be disabled with a command line flag. HiColor files have the extension .hic or .hi5 for 15-bit and .hi6 for 16-bit.

Quantized images compress better when their originals, so HiColor may serve as a less-lossy alternative to the 256-color pngquant. Quantizing a PNG file to PNG preserves transparency (but does not quantize the alpha channel). Conversion to and from the HiColor format does not preserve transparency.

The program is written in C with minimal dependencies and builds as a static binary by default. It works at least on Linux and Windows 98 Second Edition, 2000 Service Pack 4, XP, and 7.

Known bugs and limitations

PNG file size

PNG files HiColor produces are unoptimized. Run them through OptiPNG.

Generation loss

Right now repeated conversion to .hic and repeated quantization cause (capped) generation loss when dithering is enabled (by default). There is no such generation loss without the dithering. I am not sure whether to fix this or to keep it for artistic use. I think the effect looks cool on colorful high-contrast anime-style images, making them resemble PC-98 art. The example below illustrates a best-case scenario. It converged (stopped changing) after 50 generations. Most anime images won't look this good.

An example of color generation loss with HiColor

(Cropped from a piece by Suparu. I believe this is fair use, but I'll remove this picture if you own it and ask.)

A photo of New York City after 100 generations of quantize..

Photos suffer more than artwork. They work best when they are high-contrast with a lot of neon.

Usage

HiColor has a Git-style CLI.

The actions encode and decode convert images between PNG and HiColor's own image format. quantize round-trips an image through the converter and outputs a normal PNG. Use it to create images that look high-color but aren't. info displays information about a HiColor file: version (5 for 15-bit or 6 for 16), width, and height.

HiColor
Create 15/16-bit color RGB images.

usage:
  hicolor (encode|decode|quantize) [options] src [dest]
  hicolor info file
  hicolor version
  hicolor help

options:
  -5, --15-bit     15-bit color
  -6, --16-bit     16-bit color
  -n, --no-dither  Do not dither the image

Building

Debian/Ubuntu

sudo apt install -y build-essential graphicsmagick tclsh
make test

Cross-compiling for Windows

The following commands build a 32-bit executable for Windows.

sudo apt install -y build-essential gcc-mingw-w64-i686
make hicolor.exe
# Wine, Tcl, and GraphicsMagick are needed only for testing.
sudo apt install -y graphicsmagick tclsh wine
make test-wine

License

MIT.

cute_png is copyright (c) 2019 Randy Gaul and is licensed under the zlib license.

Photos from Unsplash

Building photo with a plane from Bordeaux (bordeaux-15bit.png) by olaf wisser.

NYC photo (nyc-15bit-gen-100.png) by Phi Tran.

Portland photo (tests/photo.png) by Orlova Maria.

You might also like...
Side panels for the Voron Zero printer that has 16 WS2812 RGB LED's per side.
Side panels for the Voron Zero printer that has 16 WS2812 RGB LED's per side.

Voron Zero RGB Side Panels Side panels for the Voron Zero printer with 16 WS2812 RGB LED's per side. The build below has some 3mm TAP Plastic black LE

A wireless control for an RGB LED based on emotions found in discord messages.

Sample project (See the README.md file in the upper level 'examples' directory for more information about examples.) This is the simplest buildable ex

EspHoMaTriX - A simple DIY status display with an 8x32 RGB LED panel implemented with esphome.io

EspHoMaTriX (ehmtx) A simple DIY status display with an 8x32 RGB LED panel implemented with esphome.io Introduction There are some status displays out

Game Boy and Game Boy Color Emulator

SkyBoy A simple game boy emulator written to keep my skills sharp. The majority of the code was written in a 7 day sprint. It supports most common Gam

Classic iPod mod with Raspberry Pi Zero and color screen
Classic iPod mod with Raspberry Pi Zero and color screen

ipodrpi Classic iPod mod with Raspberry Pi Zero and color screen. Suitable for OSMC and plain Raspbian install. Install OSMC: Burn SD card with Raspbe

The command line app automatically determines your location using GeoIP and adjusts the color temperature depending on time

go-sct A color temperature setting library and CLI that operates in a similar way to f.lux and Redshift. The command line app automatically determines

Scientific color conversion library written in C.

Description: ------------ CML stands for "Color Machine Library" and is designed to be a C library for color conversions. The master is not working

This is a simple tool for automatically changing accent color based on wallpaper for kde plasma.
This is a simple tool for automatically changing accent color based on wallpaper for kde plasma.

kde-plasma-adaptive-wallpaper-accent-color This is a simple tool for automatically changing accent color based on wallpaper for kde plasma. How to use

Dwm_lut - Apply 3D LUTs to the Windows desktop for system-wide color correction/calibration

About This tool applies 3D LUTs to the Windows desktop by hooking into DWM. It works in both SDR and HDR modes, and uses tetrahedral interpolation on

Comments
  • alpha.png not found

    alpha.png not found

    When trying to build with "make test" i get the following:

    ./tests/hicolor.test
    
    
    ==== data-integrity-2.1 alpha roundtrip FAILED
    ==== Contents of test case:
    
        hicolor quant alpha.png alpha-q.png
        exec gm compare -metric rmse alpha.png alpha-q.png
    
    ---- Test generated error; Return code was: 1
    ---- Return code should have been one of: 0 2
    ---- errorInfo: source image "alpha.png" doesn't exist
        while executing
    "exec {*}$::hicolorCommand {*}$args"
        (procedure "hicolor" line 2)
        invoked from within
    "hicolor quant alpha.png alpha-q.png"
        ("uplevel" body line 2)
        invoked from within
    "uplevel 1 $script"
    ---- errorCode: CHILDSTATUS 2909 1
    ==== data-integrity-2.1 FAILED
    
    hicolor.test:   Total   24      Passed  23      Skipped 0       Failed  1
    make: *** [Makefile:26: test] Error 1
    
    opened by andihow 1
  • Software can't even open

    Software can't even open

    It doesn't open on my PC at all. All it does is have a command prompt window pop up for a split second.

    Also, the linux version isn't even a program, it's a blank file. Not even a binary.

    I've tried it in other operating systems yet it still doesn't work.

    opened by ghost 0
  • Lack of PNG format verification

    Lack of PNG format verification

    As the cute_png.h library is used to load and parse PNG files, the returned image is not verified. This could cause the program's functionality to be disrupted.

    An example I encountered was when the PNG headers stored excessive values for the image's height and width (despite the fact that the pixels are not stored in the data section of the format). This causes the malloc from the function cp_to_rgb to return NULL and, as a result of the pointer dereferencing below, the program will generate a SIGSERV and stop working.

    bug 
    opened by iosifache 2
Owner
D. Bohdan
D. Bohdan
Convenient, high-performance RGB color and position control for console output

Oof (omnipotent output friend) It's common for C++ programs to write output to the console. But consoles are far more capable than what they are usual

Sebastian Werhausen 776 Dec 27, 2022
Neo - Simulates the digital rain from "The Matrix" (cmatrix clone with 32-bit color and Unicode support)

neo WARNING: neo may cause discomfort and seizures in people with photosensitive epilepsy. User discretion is advised. neo recreates the digital rain

Stew Reive 470 Dec 28, 2022
A video input (V4L2) to NDI converter that works with Raspberry Pi (32-bit and 64-bit), and Intel/AMD CPUs

V4L2 to NDI V4L2 to NDI is an application that connects to attached V4L2 devices and encodes the video signal into NDI It uses the NDI library, allowi

Luke Plassman 52 Dec 30, 2022
This is a library that can fix the crash on android 5.0 and 5.1 caused by modified utf8 converting.

FixModifiedUtf8ConvertError This is a library that can fix the crash on android 5.0 and 5.1 caused by modified utf8 converting. What's this On Android

Windy 1 Nov 23, 2021
SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.

SPIRV-Cross SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages. Features Convert SPIR-V to readable, usable an

The Khronos Group 1.6k Jan 2, 2023
Emotions and hexagons and RGB oh my!

Chromance Big, bold rainbow-glowing wall art that features the king of shapes - the hexagon. This project was designed to work with an EmotiBit wristb

Zack Freedman 107 Dec 29, 2022
Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics.

Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics Table of contents Introduction Documen

Gianluca Bianco 168 Dec 20, 2022
A clock with 241 RGB LEDs

LEDCircleClock A clock with 241 RGB LEDs. Description The clock shows the hands in diferent colors on the grid of LEDs. To make it more beautiful hand

null 17 Feb 26, 2022
RGB Matrix Audio Visualiser for ESP32

AuroraDrop v0.0.3 RGB Matrix Audio Visualiser for ESP32 Based on the Auroa Demo by Jason Coon, and using the ESP32-HUB75-MatrixPanel-I2S-DMA library b

null 21 Dec 19, 2022
I2C to WS2812 (RGB LED) converter

i2c_ws2812 I2C to WS2812 (RGB LED) converter MCU and Peripherals The code is tested on ATtiny 0 & 1 series (ATtiny212 & ATtiny402). I2C, CCL, SPI, and

null 1 Oct 15, 2021