GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  FARBFELD (5)

NAME

farbfeld - suckless image format

CONTENTS

Description
Usage
Motivation
Examples
See Also
Authors

DESCRIPTION

farbfeld 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]   4*16-Bit BE unsigned integers [RGBA] / pixel, row-major

The RGB-data should be sRGB for best interoperability and not alpha-premultiplied.

USAGE

farbfeld provides png2ff(1), jpg2ff(1), 2ff(1), ff2png(1) for conversions; bzip2(1) is recommended for compression, giving results comparable with PNG for photographs and much better results for other image types.

The file extension is ".ff" and compression extensions shall be appended (e.g. ".ff.bz2").

MOTIVATION

farbfeld was created because the author was not satisfied with the boilerplate and inherent complexity involved in handling common image formats (PNG, JPEG, GIF,...), having to rely on bloated libraries not being able to focus on the task at hand for a given problem.

EXAMPLES

Below is an example for a color inverter usable in a pipeline. No external libraries other than libc are needed to handle the image data:
#include <arpa/inet.h>

#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h>

int main(int argc, char *argv[]) {         uint32_t width, height, i, j, k;         uint16_t rgba[4];         uint8_t hdr[strlen("farbfeld") + 2 * sizeof(uint32_t)];

        if (argc > 1) {                 fprintf(stderr, "usage: %s\n", argv[0]);                 return 1;         }

        if (fread(hdr, 1, sizeof(hdr), stdin) != sizeof(hdr)) {                 fprintf(stderr, "incomplete header\n");                 return 1;         }         if (memcmp("farbfeld", hdr, strlen("farbfeld"))) {                 fprintf(stderr, "invalid magic\n");                 return 1;         }         width = ntohl(*((uint32_t *)(hdr + 8)));         height = ntohl(*((uint32_t *)(hdr + 12)));

        if (fwrite(hdr, 1, sizeof(hdr), stdout) != sizeof(hdr)) {                 fprintf(stderr, "write error\n");                 return 1;         }

        for (i = 0; i < height; i++) {                 for (j = 0; j < width; j++) {                         if (fread(rgba, sizeof(uint16_t), 4,                          stdin) != 4) {                                 fprintf(stderr, "unexpected EOF\n");                                 return 1;                         }                         for (k = 0; k < 4; k++) {                                 rgba[k] = ntohs(rgba[k]);                         }

                        /* invert colors */                         rgba[0] = 65535 - rgba[0];                         rgba[1] = 65535 - rgba[1];                         rgba[2] = 65535 - rgba[2];

                        for (k = 0; k < 4; k++) {                                 rgba[k] = htons(rgba[k]);                         }                         if (fwrite(rgba, sizeof(uint16_t), 4,                          stdout) != 4) {                                 fprintf(stderr, "write error\n");                                 return 1;                         }                 }         }

        return 0; }

SEE ALSO

2ff(1), bzip2(1), ff2png(1), jpg2ff(1), png2ff(1)

AUTHORS


.An Laslo Hunhold Aq Mt dev@frign.de
Search for    or go to Top of page |  Section 5 |  Main Index


Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.