---
name: "sipp_pixmap"
section: "3"
platform: "linux"
package: "sipp-dev"
version: "3.1-11"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/sipp_pixmap"
---

# sipp\_pixmap(3)

pixmap handling code for sipp. sipp\_bitmap - bitmap handling code for sipp.

## NAME

sipp\_pixmap - pixmap handling code for *sipp*.\
 sipp\_bitmap - bitmap handling code for *sipp*.

## SYNOPSIS

*#include \<sipp\_pixmap.h\>*\
 or\
 *#include \<sipp\_bitmap.h\>*

\[g\]cc \[*flags*\] *files* -lsipp -lm \[ *libraries* \]

## DESCRIPTION

The [sipp(3)](/sipp/3.md) library has provisions to create an image in a pixmap in core.  The most common use of this will probably be rendering into X bitmaps, Macintosh bitmaps or something similar but for those who do not want to use system dependent pixmaps we provide the *Sipp\_pixmap*.  When rendering a line image the target is a bitmap file or a bitmap in core rather than a pixmap.  To faciliate this, we also provide a bitmap implementation, the *Sipp\_bitmap*.

## PIXMAP

A *Sipp\_pixmap* is defined like this:

-

  *typedef struct {*\
       *int   width;*		/\* Width of the pixmap \*/\
       *int   height;*		/\* Height of the pixmap \*/\
       *u\_char \* buffer;*	/\* A pointer to the image. \*/\
   *} Sipp\_pixmap;*

  The pointer *buffer* is a pointer to the image where each pixel is stored as three unsigned chars in the order red, green blue.  Thus, the buffer is 3 \* *width* \* *height* bytes long.

  The following functions operate on a *Sipp\_pixmap*:

- *Sipp\_pixmap \*sipp\_pixmap\_create(width, height)*

  *int width;*\
   *int height;*

  Returns a new *Sipp\_pixmap* with the given size.  The memory used is allocated using [malloc(3)](/malloc/3.md).

- *void sipp\_pixmap\_destruct(pm)*

  *Sipp\_pixmap \*pm;*

  Frees all memory associated to the *Sipp\_pixmap pm*.

- *void sipp\_pixmap\_set\_pixel(pm, col, row, red, grn, blu)*

  *Sipp\_pixmap \*pm;*\
   *int col;*\
   *int row;*\
   *u\_char red;*\
   *u\_char grn;*\
   *u\_char blu*

  Set the pixel at (*col*, *row*) in pixmap *pm* to be the color (*red*, *grn*, *blu*). (0, 0) is upper left.

- *void sipp\_pixmap\_write(file, pm)*

  *FILE \*file;*\
   *Sipp\_pixmap \*pm*

  Write the pixmap *pm* to the open file *file*.  The image is written in the Portable Pixmap format (ppm), the same format sipp is using when rendering to a file.

## BITMAP

A *Sipp\_bitmap* is defined like this:

-

  *typedef struct {*\
       *int   width;*		/\* Width of the bitmap in pixels \*/\
       *int   height;*		/\* Height of the bitmap in pixels \*/\
       *int   width\_bytes;*	/\* Width of the bitmap in bytes. \*/\
       *u\_char \* buffer;*	/\* A pointer to the image. \*/\
   *} Sipp\_bitmap;*

  The pointer *buffer* is a pointer to the image where each pixel is a bit in an unsigned char.  If the *width* field is not a multiple of 8, the last bits in the last byte of a row are not used.  The most significant bit in each byte is the leftmost pixel. The entire buffer is *width\_bytes* \* *height* bytes long.

  The following functions operate on a *Sipp\_bitmap*:

- *Sipp\_bitmap \*sipp\_bitmap\_create(width, height)*

  *int width;*\
   *int height;*

  Returns a new *Sipp\_bitmap* with the given size.  The memory used is allocated using [malloc(3)](/malloc/3.md).

- *void sipp\_bitmap\_destruct(bm)*

  *Sipp\_bitmap \*bm;*

  Frees all memory associated to the *Sipp\_bitmap bm*.

- *void sipp\_bitmap\_line(bm, col1, row1, col2, row2)*

  *Sipp\_bitmap \*bm;*\
   *int col1;*\
   *int row1;*\
   *int col2;*\
   *int row2;*

  Draw a line from (*col1*, *row1*) to (*col2*, *row2*) in the bitmap *bm*. (0, 0) is upper left.

- *void sipp\_bitmap\_write(file, bm)*

  *FILE \*file;*\
   *Sipp\_bitmap \*bm*

  Write the bitmap *bm* to the open file *file*.  The image is written in the Portable Bitmap format (pbm), the same format sipp is using when rendering a line drawing to a file.

## SEE ALSO

[sipp(3)](/sipp/3.md) - simple polygon processor, a 3d-graphics library\
 [sipp\_geometric(3)](/sipp_geometric/3.md) - Vector and matrix functions for the [sipp(3)](/sipp/3.md) library\
 [sipp\_primitives(3)](/sipp_primitives/3.md) - a collection of geometric primitives for *sipp*.\
 [sipp\_shaders(3)](/sipp_shaders/3.md) - a collection of shaders for *sipp*.

## AUTHORS

Jonas Yngvesson		(jonas-y@isy.liu.se)\
 Inge Wallin		(ingwa@isy.liu.se)

## BUGS

No known bugs.
