Navigation C API Pages Python bindings Applications

General information

Gfxprim is simple modular 2D bitmap graphics library with emphasis on speed and correctness.

One of the key points of the library are code generators. Most of the graphics operations are written using Jinja 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

Core of the library contains minimal amount of code to define interface that is shared between all parts of the library.

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

The Core also contains generated code for basic operations such as GP_GetPixel and GP_PutPixel and optimized functions for writing continous line of pixels GP_WritePixels that are base for the more complex drawing primitives in GFX or for 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 really quick takes optional pointer to progress callback that allows your program to monitor and possibly abort the operation.

Debug interface is used as 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. Clasicall primitives are nearly finished. Work on anti aliased primitives has been started.

Text

Text part of the library implements basic support for printing text into the 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 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

PSP

Paint Shop Pro Image

Composite image only for newer formats than 3.0

No

PBM PGM PNM

Netpbm portable bitmap

All but < 8bit binary grayscale

All ASCII formats

JP2

JPEG 2000

Experimental support for RGB images

No

CBZ

Comic book archive

Experimental support via ZIP Container

No

Filters

Filters are 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 are API for drawing on screen (or into a window) and for getting keystrokes/mouse coordinates. So far we support X11, linux framebuffer, SDL and AALib as a graphics backend.

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

Python bindings

Python bindings currently covers 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