The Glimmer Guide To ...

Manipulating Pixels in the GIMP

So, you've decided to delve into the internals of the GIMP. Where should you begin? One good starting point is writing plug-ins, using various procedural database (PDB) functions to accomplish tasks. However, whether you write plug-ins or deal with other issues in the GIMP, it is likely that you will eventually need to deal with pixel-level data. This guide is intended to help you wend your way through the joy and complexity of pixels.

It's All Bytes - Representing Pixels

While there are (often) many steps involved in dealing with pixels, let's start with the lowest level representation ... the individual bytes. As you should know at this point in your career, virtually eveything on the computer gets broken down into individual bits (0 or 1) which then tend to be grouped into sets of 8 bits, which are called bytes. With eight bits, you can represent 256 different values, which you might think of as integers between 0 and 255.

Of course, when we write those bytes, we don't write the 0's and 1's. In general, we use hexidecimal (base 16) notation. Since you need four bits to represent sixteen different values, two hex digits gives you eight bits. [Should I insert more about hex here?]

Different C libraries tend to use different names for one byte. GIMP generally uses guchar (GIMP or GNU unsigned character), but I've also seen gint8.

This page was generated by Siteweaver on Thu Apr 11 12:39:20 2013.
The source to the page was last modified on Thu Apr 11 12:39:15 2013.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/GlimmerGuide/index.html.

Creative Commons License
The Glimmer Guide to C and *nix by Samuel A. Rebelsky is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.