/*
 * class RawReader
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef RAW_READER_HH__
#define RAW_READER_HH__

#include "WImage/GreymapReader.hh"

/** 
 * @addtogroup WImage 
 * @{ */
/**
 * A RAW file reader. Dimensions and a read offset can be specified 
 * through additional arguments to the constructor or through some methods.
 */
class 
RawReader: public GreymapReader
{
public:

  /** Constructor. Calls the mother class' constructor to initialize
   * the {\em ImageArray} reference and eventually sets the image
   * dimensions plus offset. 
   * @param name
   * the file name
   * @param data
   * the reference to the {\em ImageArray} object 
   * @param y
   * the number of rows
   * @param x
   * the number of cols
   * @param offs
   * the offset */
  RawReader (char const * name, ImageArray<coeff> &data, int y = 512, 
             int x = 512, int offs = 0): GreymapReader (name, data) 
  { header (offs); rows (y); cols (x); }

  /** Destructor - does nothing. */
  virtual ~RawReader (void) {}

  /** Set the offset. 
   * @param offs
   * the new offset */
  inline void header (int offs) { m_offset = offs; }
  /** Set the horizontal size. 
   * @param cols
   * the new number of cols */
  inline void cols (int cols) { m_xsize = cols; }
  /** Set the vertical size. 
   * @param rows
   * the new number of rows */
  inline void rows (int rows) { m_ysize = rows; }

private:
  /** The read offset. Some files have some leading bytes containing
   * no usable information. If this applies this has a non-zero value. */
  int m_offset;
  /** The horizontal size. */
  int m_xsize;
  /** The vertical size. */
  int m_ysize;
  
protected:
  /** Read the RAW file format. This does the actual work of reading and
   * parsing the image file. It gets called by the {\em read ()} method.
   * @return 
   * 0 if successful, -1 on read error, -2 on file format error. */
  virtual int readfmt (void);

}; /* class RawReader */

/** @} */

#endif /* RAW_READER_HH__ */
