/*
 * Implementation of class PixmapWriter
 *
 * $Date$
 * $Revision$
 *
 */

#undef DPRINTF
#include "WImage/ImageArray.hh"
#include "WImage/PixmapWriter.hh"
#include "WImage/debug.h"
#include "WImage/tools.h"
#include <cmath>
#include <iostream>
#include <stdexcept>
#include <fstream>
#include <cassert>
#include <cfloat>

#if !(defined __WATCOMC__ && __WATCOMC__ < 1230)
using namespace std;
#endif

void
PixmapWriter::write (void)
{
  int success = 0;

  
  /*
   * First check whether file is writeable...
   */
  if (m_fname != NULL)
    {
      ofstream ofs (m_fname);
      if (!ofs)
        {
          success = -1;
        }
    }
  
  if (success == 0)
    {
      success = writefmt ();
    }
  
  if (success < 0)
    {
      throw ios_base::failure ("write: error writing file.");
    }
}




