// This file is part of dvi2bitmap. // Copyright 2001, Yamabe Kazuharu // // This program is part of the Starlink Software Distribution: see // http://www.starlink.ac.uk // // dvi2bitmap is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // dvi2bitmap is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with dvi2bitmap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // The General Public License is distributed along with this // program in the file LICENCE. // // $Id: XPMBitmap.cc,v 1.6 2005/06/04 15:51:04 normang Exp $ // XPMBitmap contributed by Yamabe Kazuharu // // This is a very simple implementation of the XPM format. For // further details, and a full XPM library, see // http://www-sop.inria.fr/koala/lehors/xpm.html #include #include "Bitmap.h" #include "XPMBitmap.h" //#include // debug code writes to cerr #ifdef HAVE_CSTD_INCLUDE # include # include # if CCTYPE_IN_STD using std::isalnum; # endif #else # include # include #endif XPMBitmap::XPMBitmap (const int w, const int h) : BitmapImage (w, h) { } XPMBitmap::~XPMBitmap () { } void XPMBitmap::write (const string filename) { FILE *op; if ((op = fopen (filename.c_str(), "w")) == NULL) throw BitmapError ("can't open XPM file"+filename+" to write"); size_t dotpos = filename.find_last_of('.'); size_t seppos = filename.find_last_of(FSPATH_SEP); if (seppos == string::npos) seppos = 0; if (dotpos == string::npos) dotpos = filename.length(); string fnroot_str = ""; for (unsigned int charno=(unsigned int)seppos; charno