Browse Prior Art Database

Technique for Processing Non-Byte Aligned Image Data

IP.com Disclosure Number: IPCOM000114158D
Original Publication Date: 1994-Nov-01
Included in the Prior Art Database: 2005-Mar-27
Document File: 4 page(s) / 119K

Publishing Venue

IBM

Related People

Lahey, LC: AUTHOR [+3]

Abstract

Disclosed is a technique to extract image data that is not aligned on byte boundaries from a datastream. Some applications produce bilevel image data that is not aligned such that the bit data representing a row of the image starts on a byte boundary. This makes reading the image data more difficult, since each row of the data may start at a different bit offset into a data byte. This technique allows the image reader to process the data on a byte-by-byte pass through the data, rather than a bit-by-bit pass.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 47% of the total text.

Technique for Processing Non-Byte Aligned Image Data

      Disclosed is a technique to extract image data that is not
aligned on byte boundaries from a datastream.  Some applications
produce bilevel image data that is not aligned such that the bit data
representing a row of the image starts on a byte boundary.  This
makes reading the image data more difficult, since each row of the
data may start at a different bit offset into a data byte.  This
technique allows the image reader to process the data on a
byte-by-byte pass through the data, rather than a bit-by-bit pass.

      Basically, there is an input buffer containing the
non-byte-aligned data, and it is transformed into an output buffer
that will contain the padded (byte-aligned) image data.  This
technique is very simple, and contains the following steps as
illustrated in the Figure:
  1.  assume the data is not byte-aligned, so the bits of interest
      reside in 2 bytes
  2.  read the 2 bytes that contain the 8 bits of interest (the 8
bits
      that will constitute a byte in the output datastream) into 2
      character variables
  3.  Leftshift the first byte (0-filling the least significant bits
      of the byte) to position the first bit of interest to the most
      significant bit position.
  4.  Rightshift the second byte (0-filling the most significant bits
      of the byte) to position the last bit of interest to the least
      significant bit position.
  5.  Perform a logical OR of these 2 bytes and write the result to
the
      output datasteam.

      Of course, some information needs to be managed to identify the
current bits of interest in the bytes, and processing the last byte
of a row is different (since we we need to 0-pad it and begin a new
row at the next bit), but most of the work is done by the above
algorithm.  To make it work for an entire datastream, it is necessary
to augment it described below.

      A routine is needed which processes a row of image data,
reading it from the input datastream and writing it to the output
datastream.  It is described using C language syntax.
    PadRow(uchar *pInBuf,              // input buffer pointer
       uchar *pOutBuf,              // output buffer pointer
       ulong bits_per_row,          // bits in a row of image
       ushort bit_offset)           // bit offset (into current byte)
                                    //     where this row starts
  {
  unsigned int bytes_per_row,       // bytes per image row in output
               rshift,              // amount to rightshift
             bit_offset;           // bit offset into input data byte
   unsigned long inbuf_pos,      // current position in input buffer
         outbuf_pos;            // current...