• Stars
    star
    194
  • Rank 200,219 (Top 4 %)
  • Language
    C
  • License
    MIT License
  • Created over 3 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐ŸŽจ Convert images to 15/16-bit RGB color with dithering

HiColor

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

(The image above has 15-bit color.)

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 either the extension .hic or .hi5 for 15-bit and .hi6 for 16-bit respectively.

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 is known to work on Linux (aarch64, i386, riscv64, x86_64), FreeBSD, NetBSD, OpenBSD, and Windows 98 Second Edition, 2000 Service Pack 4, XP, and 7.

Known bugs and limitations

PNG file size

PNG files produced by HiColor are not optimized. Run them through OptiPNG to significantly reduce their size.

Generation loss

Fixed in version 0.3.0.

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, 2021-2023 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.

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

More Repositories

1

structured-text-tools

A list of command-line tools for manipulating structured text data
6,948
star
2

automatic-api

A list of software that turns your database into a REST/GraphQL API
Go
1,988
star
3

classless-css

A list of classless CSS themes/frameworks with screenshots
HTML
1,928
star
4

embedded-scripting-languages

A list of embedded scripting languages
1,277
star
5

compilers-targeting-c

A list of compilers that can generate C code
JavaScript
692
star
6

sqawk

Like awk but with SQL and table joins
Tcl
310
star
7

liveviews

Phoenix LiveView workalikes for different languages and frameworks
243
star
8

jsonwatch

Track changes in JSON data from the command line
Rust
165
star
9

unflattener

Make normal maps for 2D art
Python
146
star
10

s2png

Store any data in PNG images
Rust
99
star
11

csv2html

Convert CSV files to HTML tables
Rust
73
star
12

initool

Manipulate INI files from the command line
Standard ML
57
star
13

caddy-markdown-site

Serve Markdown files as HTML pages with CSS using just Caddy
CSS
52
star
14

picol

(Fossil repository mirror) A tiny interpreter
C
32
star
15

jimhttp

A library collection and web microframework
Tcl
28
star
16

tcl-duktape

Tcl bindings for Duktape, an embedded JavaScript interpreter
C
19
star
17

all-caps-basic

(WIP) A compiler written in Awk
Awk
16
star
18

caddy-cgi

An example of how to configure Caddy 1/2 with a FastCGI-to-CGI proxy
Perl
11
star
19

tinyfts

Very small standalone full-text search HTTP/SCGI server
Tcl
10
star
20

messagebox

Display message boxes from Windows batch files and command line programs
Shell
8
star
21

jimsh-static

Jim Tcl static binaries with SQLite 3 for Linux
Dockerfile
7
star
22

tcl-fcgi

FastCGI in pure Tcl
Tcl
6
star
23

2048.tcl

The game of 2048 implemented in Tcl
Tcl
4
star
24

pip-wtenv

Make your script download its dependecies; like pip.wtf but uses venvs
Python
4
star
25

joker-cgi-guestbook

A toy old-school CGI guestbook written in Joker
Clojure
3
star
26

HTMLgen

This is a mirror of the HTMLgen module by Robin Friedrich with the Debian patches
Python
3
star
27

ptjd

A pure Tcl JPEG decoder
Tcl
2
star
28

gpgedit

Edit symmetrically encrypted files
Tcl
2
star
29

fossil-wiki-export

Export a Fossil SCM wiki to Git preserving the revision history
Tcl
2
star
30

circleci-tcl-gcc-autoconf

Docker image for testing Tcl and C code with CircleCI
Dockerfile
2
star
31

klisp

C
2
star
32

empty

(Mirror) An alternative to Expect for *nix shells
C
1
star
33

caddy-deb-opt

Build a deb package to install Caddy in /opt/
Makefile
1
star
34

apache-2.4-webdav

A WebDAV file share/inbox configuration example for Apache 2.4
CSS
1
star
35

tcl86-nsis-installer

Build a Windows installer for Tcl with NSIS
PowerShell
1
star
36

tcl-augeas

Tcl bindings for Augeas
C
1
star