OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | List of all members
ossimPackedBits Class Reference

This class will allow access to individual packed pixels given an offset and return as an ossim_uint32 type. More...

#include <ossimPackedBits.h>

Public Member Functions

 ossimPackedBits (const ossim_uint8 *packedBits, ossim_uint16 bits)
 Constructor that takes packed bits array and word size in bits. More...
 
ossim_uint32 getValueAsUint32 (ossim_uint32 idx) const
 Extract out the value at offset indicated by idx and convert the the vale to an ossim_uint32. More...
 

Protected Attributes

const ossim_uint8thePackedBits
 
ossim_uint16 theBits
 
ossim_uint16 theBytes
 
ossim_uint16 theBitsLeft
 

Detailed Description

This class will allow access to individual packed pixels given an offset and return as an ossim_uint32 type.

Definition at line 22 of file ossimPackedBits.h.

Constructor & Destructor Documentation

◆ ossimPackedBits()

ossimPackedBits::ossimPackedBits ( const ossim_uint8 packedBits,
ossim_uint16  bits 
)

Constructor that takes packed bits array and word size in bits.

Parameters
packedBitsThe unsigned eight bit array of packed bits. This pointer is not owned by this class, only used.
bitsThe number of bits in the packed bits word.

Definition at line 16 of file ossimPackedBits.cpp.

References theBits, theBitsLeft, and theBytes.

18  :thePackedBits(packedBits),
19  theBits(bits)
20 {
21  theBytes = theBits>>3;
22  theBitsLeft = theBits%8;
23 }
ossim_uint16 theBitsLeft
ossim_uint16 theBits
ossim_uint16 theBytes
const ossim_uint8 * thePackedBits

Member Function Documentation

◆ getValueAsUint32()

ossim_uint32 ossimPackedBits::getValueAsUint32 ( ossim_uint32  idx) const

Extract out the value at offset indicated by idx and convert the the vale to an ossim_uint32.

This class only supports packed bits less than 32.

Parameters
idxThe packed bit word index to grab and stuff into an unsigned 32 bit integer.

Definition at line 25 of file ossimPackedBits.cpp.

References theBits, theBitsLeft, theBytes, and thePackedBits.

Referenced by ossimNitfTileSource::explodePackedBits().

26 {
27  ossim_uint32 value = 0;
28  ossim_uint32 tempBits = (theBitsLeft*idx);
29  ossim_uint32 tempBitShift = tempBits%8;
30  ossim_uint32 byteOffset = ( (idx*theBytes) + (tempBits>>3) );
31  ossim_uint32 bitCount = 0;
32  ossim_uint32 bitsSeen = tempBitShift;
33  ossim_uint8 bitmask = 1 << (7-tempBitShift);
34 
35  while(bitCount < theBits)
36  {
37  value |= (ossim_uint8)((bool)(thePackedBits[byteOffset]&bitmask));
38  ++bitCount;
39  ++bitsSeen;
40  if(bitsSeen >= 8)
41  {
42  bitsSeen = 0;
43  bitmask = 0x80; // binary pattern 10000000
44  ++byteOffset;
45  }
46  else
47  {
48  bitmask>>=1;
49  }
50  if(bitCount < theBits)
51  {
52  value <<=1;
53  }
54  }
55 
56  return value;
57 }
ossim_uint16 theBitsLeft
unsigned int ossim_uint32
ossim_uint16 theBits
ossim_uint16 theBytes
unsigned char ossim_uint8
const ossim_uint8 * thePackedBits

Member Data Documentation

◆ theBits

ossim_uint16 ossimPackedBits::theBits
protected

Definition at line 47 of file ossimPackedBits.h.

Referenced by getValueAsUint32(), and ossimPackedBits().

◆ theBitsLeft

ossim_uint16 ossimPackedBits::theBitsLeft
protected

Definition at line 49 of file ossimPackedBits.h.

Referenced by getValueAsUint32(), and ossimPackedBits().

◆ theBytes

ossim_uint16 ossimPackedBits::theBytes
protected

Definition at line 48 of file ossimPackedBits.h.

Referenced by getValueAsUint32(), and ossimPackedBits().

◆ thePackedBits

const ossim_uint8* ossimPackedBits::thePackedBits
protected

Definition at line 46 of file ossimPackedBits.h.

Referenced by getValueAsUint32().


The documentation for this class was generated from the following files: