/*
 * class RawWriter
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef RAW_WRITER_HH__
#define RAW_WRITER_HH__

#include "WImage/GreymapWriter.hh"

/** 
 * @addtogroup WImage 
 * @{ */

/**
 * A RAW image file writer. Dimensions are known from the {\em ImageArray}
 * object.
 */
class 
RawWriter: public GreymapWriter
{
public:
  
  /** Constructor. Only calls the mother class' constructor to initialize
   * the {\em ImageArray} reference and set the offset if necessary. 
   * @param name
   * the file name
   * @param data
   * the reference to the {\em ImageArray} object 
   * @param offs
   * the offset */
  RawWriter (char const *name, ImageArray<coeff> &data, int offs = 0)
    : GreymapWriter (name, data) { header (offs); }

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

  /** Set the offset. 
   * @param offs
   * the new offset */
  inline void header (int offs) { m_offset = offs; }

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;
protected: 
  /** Write a RAW image file. This is the method that does the actual
   * work. It will be called by the {\em write ()} method.
   * @return 
   * 0 if successful, -1 on write error. */
  virtual int writefmt (void);
  
}; /* class RawWriter */

/** @} */

#endif /* RAW_WRITER_HH__ */
