Navigation C API Pages Python bindings Applications

General information

GFXprim is simple modular 2D bitmap graphics library with emphasis on speed and correctness. It comes batteries included, but free from bloat.

It includes:

  • Graphical user interface widgets with object hierarchy and declarative layouts.

  • Clean and non-intrusive implementations of elementary data structures.

  • Multiple rendering backends supporting desktop to embedded.

  • Integrations with many image loaders.

  • Image filters

  • Sample applications including image and PDF viewers.

  • Many tests

One of the key points of the library are code generators. Most of the graphics operations are written using CCT templating engine which is used to create specialized C code. So, for an example, once you add pixel definition into configuration file, creating specialized filters, loaders and conversions to other pixel formats is just a matter of typing make rebuild.

Core

The Core of the library contains a minimal amount of code to define interfaces that are shared between all parts of the library.

The most important part of the core is the gp_pixmap structure that represents an in-memory pixmap.

The Core also contains generated code for basic operations such as gp_get_pixel, gp_put_pixel and optimized functions for writing continous lines of pixels gp_write_pixels that are a base for the more complex drawing primitives in GFX or for the graphics operations in Filters.

Blits are functions used to copy part of one bitmap into another bitmap. The blits be also used for primitive bitmap pixel type conversions (i.e. RGB888 vs BGR888).

Progress Callback is an interface that allows you to monitor progress of an operation. It is mainly used in loaders and filters. Generally, any operation that is not very quick takes an optional pointer to a progress-callback that allows your program to monitor and possibly abort the operation.

The Debug interface is used as a unified facility to print debug messages, control debug level, etc.

There is also support for Gamma correction. Unfortunatelly not all parts of library use it at the moment.

And last but not least: Core is a home for some common macros that are used from different parts of the library.

Gfx

Gfx is part of the library that implements basic graphics primitives such as lines, circles, polygons, etc. Classical primitives are nearly finished. Work on anti-aliased primitives has been started.

Text

The Text part of the library implements basic support for printing text into a bitmap. There are two bitmap fonts compiled directly into the library and we support True Type fonts through FreeType (so far ASCII printable characters only).

Loaders

Loaders are the part that is resposible for loading and saving images into various standard formats (PNG, JPEG, GIF, TIFF, BMP, PNM, etc…).

Table 1. Currently supported formats
Extension Format Name Read Support Write Support

JPEG

Yes

Yes

PNG

Portable Network Graphics

16 Bit RGB not supported

16 Bit RGB not supported

GIF

Graphics Interchange Format

Yes

No

BMP

RLE4 and some less common bitfiels not supported

RGB888 only

TIFF

Tagged Image File Format

Most of the Palette, RGB and Grayscale works (no tiles yet)

RGB888 and Grayscale

WEBP

Yes

No

PSP

Paint Shop Pro Image

Composite image only for newer formats than 3.0

No

PSD

Adobe Photoshop Image

Thumbnail or Merged image (16 bit RGB and CMYK not supported yet)

No

PBM PGM PPM PNM

Netpbm portable bitmap

All but < 8bit binary grayscale

All ASCII formats

JP2

JPEG 2000

Experimental support for RGB images

No

PCX

ZSoft PCX

Yes

No

CBZ

Comic book archive

Experimental support via ZIP Container

No

Filters

Filters are the part of the library that implements bitmap image filters.

Table 2. Currently Implemented Point Filters
Filter Name Supported Pixel Type Multithreaded

Brightness

All

Not Applicable

Contrast

All

Not Applicable

Invert

All

Not Applicable

Posterize

All

Not Applicable

Table 3. Currently Implemented Linear Filters
Filter Name Supported Pixel Type Mutithreaded

Convolution

All

Yes

Separable Convolution

All

Yes

Gaussian Blur

All

Yes

Sobel Edge Detection

RGB888

Yes

Prewitt Edge Detection

RGB888

Yes

Table 4. Currently Implemented Aritmetic Filters
Filter Name Supported Pixel Type Multithreaded

Addition

All

No

Multiplication

All

No

Difference

All

No

Max, Min

All

No

Table 5. Currently Implemented Ditherings
Filter Name Supported Pixel Type Multithreaded

Floyd Steinberg

All → Any

No

Hilbert Peano

All → Any

No

Table 6. Currently Implemented Resamplings
Filter Name Supported Pixel Type Multithreaded

Nearest Neighbour

All

No

Bilinear (Integer Arithmetics)

All

No

Bicubic (Integer Arithmetics)

All

No

Bicubic (Float Arithmetics)

RGB888

No

Table 7. Rotation and mirroring
Filter Name Supported Pixel Type Multithreaded

Rotate 90

All

No

Rotate 180

All

No

Rotate 270

All

No

Mirror Vertically

All

No

Mirror Horizontally

All

No

Table 8. Misc filters
Filter Name Supported Pixel Type Multithreaded

Histogram

All

No

Additive Gaussian Noise

All

No

Median

RGB888

No

Weighted Median

RGB888

No

Sigma Lee

RGB888

No

Backends

Backends together with Input form an API for drawing on screen (or into a window) and for getting keystrokes/mouse coordinates. So far we support X11, the Linux framebuffer, SDL and AALib as graphics backends.

There is also a virtual backend used for testing. This allows you to create a backend of any pixel type on the top of other backends.

Python bindings

Python bindings currently cover most of the library, there is (work in progress) documentation for Core, Gfx, Loaders, Filters and Backends.

Work in progress

  • Anti Aliased drawing

  • Gamma correction and color profiles