farbfeld by suckless.org is a lossless image format which is easy to parse, pipe and compress. It has the following format:
Bytes | Description |
---|---|
8 | "farbfeld" magic value |
4 | 32-Bit BE unsigned integer (width) |
4 | 32-Bit BE unsigned integer (height) |
[2222] | 4x16-Bit BE unsigned integers [RGBA] / pixel, row-aligned |
The RGB-data should be sRGB for best interoperability and not alpha-premultiplied.
Cyotek.Drawing.Imaging.Farbfeld is a library for processing farbfeld files in .NET. There's a bit of background information on why I created this library on the cyotek.com blog.
There are two static classes, FarbfeldDecoder
and FarbfeldEncoder
for saving and loading .NET Bitmap
objects in the farbfeld format, along with a helper object FarbfeldImageData
for holding the data without having to mess around with Bitmap
objects (although can can use those to).
Decode(string)
- reads a farbfeld image from a file and creates aFarbfeldImageData
object from the dataDecode(Stream)
- reads a farbfeld image from a Stream and creates aFarbfeldImageData
from the dataIsFarbfeldImage(string)
- tests if the given file contains a farbfeld imageIsFarbfeldImage(Stream)
- tests if the given Stream contains a farbfeld image
Encode(string, Bitmap)
- saves aBitmap
into the specified file using the farbfeld formatEncode(Stream, Bitmap)
- saves aBitmap
into the specified Stream using the farbfeld formatEncode(string, FarbfeldImageData)
- saves raw image data into the specified file using the farbfeld formatEncode(Stream, FarbfeldImageData)
- saves raw image data into the specified Stream using the farbfeld format
This repository also includes a simple image viewer (using the ImageBox control of course!) that lets you open farbfeld images, or convert other basic image formats to farbfeld.
The sample images which I used for reference to ensure the encoding/decoding actually worked came from the here
There are some tests. However, they have only been tested on little-endian systems (ie Windows)... I suspect the thing is going to break on big-endian systems.
There's a package, but I haven't published it yet.
The icon used in the viewer program came from https://www.iconfinder.com/icons/254234/image_icon#size=128
The polgyon.png
, polygon.png.ff
, yellow-1x1-semitransparent.png
and yellow-1x1-semitransparent.png.ff
sample images came from https://github.com/mehlon/farbfeld