Dali: BitImage -- C API

[ Header Files | Types | Constants | Allocation | Initialization | Set Operations | Queries | See Also ]

Header Files

#include <dvmbasic.h>

Type Definitions

BitImage

A BitImage is a two dimensional array of pixels, where each pixel can take value of either 0 or 1. As with ByteImages, a BitImage can be either physical or virtual. A physical BitImage has memory allocated to it, while a virtual BitImage borrows its memory from a physical one.

BitImages are internally represented in a packed format (i.e., 8 bits are packed into one byte). This representation allows makes some operations very fast, but slows others down.

A byte in a BitImage bit is said to be a full byte if all 8 bits are part of the BitImage. Otherwise it is said to be partial.

A BitImage is said to be byte-aligned iff the left and right boundary of the BitImage is also at the byte-boundary. It is said to be left byte-aligned iff the left boundary is at the byte-boundary.

    typedef struct BitImage {
         int unitWidth;
         int byteWidth;
         int height;
         int x;
         int y;
         int parentWidth;
         unsigned char firstBit;
         unsigned char lastBit;
         unsigned char isVirtual;
         unsigned char *firstByte;
     } BitImage;
   
unitWidth
the width of the BitImage in bits.
byteWidth
The number of full bytes in the each row of the BitImage. If bits in the first byte (or last) byte are not in the BitImage, the first (or last) byte are considered as partial bytes and is not counted in byteWidth.
height
the height of the BitImage
x
the x-offset of the top-left corner of the BitImage from it's parent (in bits).
y
the y-offset of the top-left corner of the BitImage from it's parent (in bits).
parentWidth
For a physical buffer, parentWidth is the number of bytes allocated for the buffer. Note that this might be one more than byteWidth, since byteWidth does not include the last byte if it is partial.

For a virtual buffer, parentWidth is the parentWidth of the physical buffer it belongs to. (again, this should be called rootWidth since the parent of a BitImage may be a virtual image also.)

firstBit
The first valid bit in the first byte of the buffer. The sequence is 01234567. (First bit is 0, second bit is 1 ...) A physical buffer always has firstBit == 0.
lastBit
The last valid bit in the last byte of the buffer. The sequence is 12345670. (First bit is 1, second bit is 2 ...)
isVirtual
1 iff the BitImage is virtual. 0 otherwise.
firstByte
pointer to the first byte in the BitImage in the first row of BitImage

Constants

Return Code

Return code from various bit primitives. DVM_BIT_OK indicates the primitives executed succesfully. DVM_BIT_IS_BYTE_ALIGN indicates that the BitImage passed into a non-byte-aligned primitives is byte-aligned. DVM_BIT_NOT_BYTE_ALIGN indicates that the BitImage passed into a byte-aligned primitives is not byte-aligned.

     #define DVM_BIT_OK 0
     #define DVM_BIT_IS_BYTE_ALIGN -1
     #define DVM_BIT_NOT_BYTE_ALIGN -2
  

Operators

Allocation

BitImage *BitNew (int w, int h)

void BitFree (BitImage *bitImage)

BitImage *BitClip (BitImage *bitImage, int x, int y, int w, int h)

void BitReclip (BitImage *bitImage, int x, int y, int w, int h, BitImage *clipped)


Initialization

int BitCopy (BitImage *src, BitImage *dest)

int BitCopy8 (BitImage *src, BitImage *dest)

int BitSet (BitImage *bitImage, unsigned char v)

int BitSet8 (BitImage *bitImage, unsigned char v)

void BitMakeFromKey (ByteImage *byteImage, unsigned char low, unsigned char high, BitImage *bitImage)


Set Operations

int BitUnion (BitImage *src1, BitImage *src2, BitImage *dest)

int BitUnion8 (BitImage *src1, BitImage *src2, BitImage *dest)

int BitIntersect (BitImage *src1, BitImage *src2, BitImage *dest)

int BitIntersect8 (BitImage *src1, BitImage *src2, BitImage *dest)


Queries

int BitIsAligned(BitImage *bitImage)

int BitIsLeftAligned(BitImage *bitImage)

int BitGetSize(BitImage *bitImage)

int BitGetWidth(BitImage *bitImage)

int BitGetHeight(BitImage *bitImage)

int BitGetVirtual(BitImage *bitImage)

int BitGetX(BitImage *bitImage)

int BitGetY(BitImage *bitImage)


See Also

ByteImage , BitImageScan API


Last updated : Saturday, November 14, 1998, 07:50 PM