pcb 4.1.1
An interactive printed circuit board layout editor.

bitmap.h File Reference

This header file collects some general-purpose macros (and static inline functions) that are used in various places. More...

#include <string.h>
#include <stdlib.h>
#include "potracelib.h"
Include dependency graph for bitmap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BM_WORDSIZE   ((int)sizeof(potrace_word))
 The bitmap type is defined in potracelib.h.
#define BM_WORDBITS   (8*BM_WORDSIZE)
#define BM_HIBIT   (((potrace_word)1)<<(BM_WORDBITS-1))
#define BM_ALLBITS   (~(potrace_word)0)
#define bm_scanline(bm, y)   ((bm)->map + (y)*(bm)->dy)
#define bm_index(bm, x, y)   (&bm_scanline(bm, y)[(x)/BM_WORDBITS])
#define bm_mask(x)   (BM_HIBIT >> ((x) & (BM_WORDBITS-1)))
#define bm_range(x, a)   ((int)(x) >= 0 && (int)(x) < (a))
#define bm_safe(bm, x, y)   (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))
#define BM_UGET(bm, x, y)   ((*bm_index(bm, x, y) & bm_mask(x)) != 0)
#define BM_USET(bm, x, y)   (*bm_index(bm, x, y) |= bm_mask(x))
#define BM_UCLR(bm, x, y)   (*bm_index(bm, x, y) &= ~bm_mask(x))
#define BM_UINV(bm, x, y)   (*bm_index(bm, x, y) ^= bm_mask(x))
#define BM_UPUT(bm, x, y, b)   ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))
#define BM_GET(bm, x, y)   (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)
#define BM_SET(bm, x, y)   (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)
#define BM_CLR(bm, x, y)   (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)
#define BM_INV(bm, x, y)   (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
#define BM_PUT(bm, x, y, b)   (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)

Functions

static void bm_free (potrace_bitmap_t *bm)
 Free the given bitmap. Leaves errno untouched.
static potrace_bitmap_tbm_new (int w, int h)
 Create a new bitmap.
static void bm_clear (potrace_bitmap_t *bm, int c)
 Clear the given bitmap.
static potrace_bitmap_tbm_dup (const potrace_bitmap_t *bm)
 Duplicate the given bitmap.
static void bm_invert (potrace_bitmap_t *bm)
 Invert the given bitmap.

Detailed Description

This header file collects some general-purpose macros (and static inline functions) that are used in various places.


Copyright.


PCB, interactive printed circuit board design

Copyright (C) 2001-2007 Peter Selinger.

This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details.

Definition in file bitmap.h.


Define Documentation

#define BM_ALLBITS   (~(potrace_word)0)

Definition at line 45 of file bitmap.h.

Referenced by bm_clearexcess(), bm_invert(), and xor_to_ref().

#define BM_CLR (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)

Definition at line 62 of file bitmap.h.

#define BM_GET (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)

Definition at line 60 of file bitmap.h.

Referenced by bm_to_pathlist(), findnext(), findpath(), majority(), and pathlist_to_tree().

#define BM_HIBIT   (((potrace_word)1)<<(BM_WORDBITS-1))

Definition at line 44 of file bitmap.h.

#define bm_index (   bm,
  x,
  y 
)    (&bm_scanline(bm, y)[(x)/BM_WORDBITS])

Definition at line 51 of file bitmap.h.

Referenced by bm_clearexcess(), findnext(), and xor_to_ref().

#define BM_INV (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)

Definition at line 63 of file bitmap.h.

#define bm_mask (   x)    (BM_HIBIT >> ((x) & (BM_WORDBITS-1)))

Definition at line 52 of file bitmap.h.

#define BM_PUT (   bm,
  x,
  y,
 
)    (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)

Definition at line 64 of file bitmap.h.

Referenced by gcode_do_export().

#define bm_range (   x,
 
)    ((int)(x) >= 0 && (int)(x) < (a))

Definition at line 53 of file bitmap.h.

#define bm_safe (   bm,
  x,
  y 
)    (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))

Definition at line 54 of file bitmap.h.

#define bm_scanline (   bm,
  y 
)    ((bm)->map + (y)*(bm)->dy)

Definition at line 50 of file bitmap.h.

Referenced by clear_bm_with_bbox().

#define BM_SET (   bm,
  x,
  y 
)    (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)

Definition at line 61 of file bitmap.h.

#define BM_UCLR (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) &= ~bm_mask(x))

Definition at line 57 of file bitmap.h.

#define BM_UGET (   bm,
  x,
  y 
)    ((*bm_index(bm, x, y) & bm_mask(x)) != 0)

Definition at line 55 of file bitmap.h.

#define BM_UINV (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) ^= bm_mask(x))

Definition at line 58 of file bitmap.h.

#define BM_UPUT (   bm,
  x,
  y,
 
)    ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))

Definition at line 59 of file bitmap.h.

#define BM_USET (   bm,
  x,
  y 
)    (*bm_index(bm, x, y) |= bm_mask(x))

Definition at line 56 of file bitmap.h.

#define BM_WORDBITS   (8*BM_WORDSIZE)

Definition at line 43 of file bitmap.h.

Referenced by bm_clearexcess(), bm_new(), clear_bm_with_bbox(), findnext(), xor_path(), and xor_to_ref().

#define BM_WORDSIZE   ((int)sizeof(potrace_word))

The bitmap type is defined in potracelib.h.

Definition at line 42 of file bitmap.h.

Referenced by bm_clear(), bm_dup(), and bm_new().


Function Documentation

static void bm_clear ( potrace_bitmap_t bm,
int  c 
) [inline, static]

Clear the given bitmap.

Set all bits to c.

Definition at line 113 of file bitmap.h.

References BM_WORDSIZE, potrace_bitmap_s::dy, potrace_bitmap_s::h, and potrace_bitmap_s::map.

Referenced by pathlist_to_tree().

static potrace_bitmap_t* bm_dup ( const potrace_bitmap_t bm) [inline, static]

Duplicate the given bitmap.

Returns:
NULL on error with errno set.

Definition at line 124 of file bitmap.h.

References bm_new(), BM_WORDSIZE, potrace_bitmap_s::dy, potrace_bitmap_s::h, potrace_bitmap_s::map, and potrace_bitmap_s::w.

Referenced by bm_to_pathlist().

Here is the call graph for this function:

static void bm_free ( potrace_bitmap_t bm) [inline, static]

Free the given bitmap. Leaves errno untouched.

Definition at line 70 of file bitmap.h.

References potrace_bitmap_s::map.

Referenced by bm_to_pathlist(), and gcode_do_export().

static void bm_invert ( potrace_bitmap_t bm) [inline, static]

Invert the given bitmap.

Definition at line 139 of file bitmap.h.

References BM_ALLBITS, potrace_bitmap_s::dy, potrace_bitmap_s::h, and potrace_bitmap_s::map.

static potrace_bitmap_t* bm_new ( int  w,
int  h 
) [inline, static]

Create a new bitmap.

Returns:
New un-initialized bitmap, NULL with errno on error.

Definition at line 85 of file bitmap.h.

References BM_WORDBITS, BM_WORDSIZE, potrace_bitmap_s::dy, potrace_bitmap_s::h, malloc(), potrace_bitmap_s::map, and potrace_bitmap_s::w.

Referenced by bm_dup(), and gcode_do_export().

Here is the call graph for this function: