diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/dvisvgm/src/ImageToSVG.hpp |
Initial commit
Diffstat (limited to 'dviware/dvisvgm/src/ImageToSVG.hpp')
-rw-r--r-- | dviware/dvisvgm/src/ImageToSVG.hpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/dviware/dvisvgm/src/ImageToSVG.hpp b/dviware/dvisvgm/src/ImageToSVG.hpp new file mode 100644 index 0000000000..88564fd736 --- /dev/null +++ b/dviware/dvisvgm/src/ImageToSVG.hpp @@ -0,0 +1,85 @@ +/************************************************************************* +** ImageToSVG.hpp ** +** ** +** This file is part of dvisvgm -- a fast DVI to SVG converter ** +** Copyright (C) 2005-2019 Martin Gieseking <martin.gieseking@uos.de> ** +** ** +** This program 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 3 of ** +** the License, or (at your option) any later version. ** +** ** +** This program 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 this program; if not, see <http://www.gnu.org/licenses/>. ** +*************************************************************************/ + +#ifndef IMAGETOSVG_HPP +#define IMAGETOSVG_HPP + +#include <istream> +#include <memory> +#include <string> +#include "PsSpecialHandler.hpp" +#include "SpecialActions.hpp" +#include "SVGTree.hpp" + +struct SVGOutputBase; + +class ImageToSVG : protected SpecialActions { + public: + ImageToSVG (std::string fname, SVGOutputBase &out) : _fname(std::move(fname)), _out(out) {} + void convert (int pageno); + void convert (int firstPage, int lastPage, std::pair<int,int> *pageinfo); + void convert (const std::string &rangestr, std::pair<int,int> *pageinfo); + void setPageTransformation (const std::string &transCmds) {_transCmds = transCmds;} +// void setPageSize (const std::string &name); + std::string filename () const {return _fname;} + PSInterpreter& psInterpreter () {return _psHandler.psInterpreter();} + virtual bool isSinglePageFormat () const =0; + virtual int totalPageCount () =0; + + protected: + void checkGSAndFileFormat (); + Matrix getUserMatrix (const BoundingBox &bbox) const; + virtual std::string imageFormat () const =0; + virtual bool imageIsValid () const =0; + virtual BoundingBox imageBBox () const =0; + virtual std::string psSpecialCmd () const =0; + // implement abstract base class SpecialActions + double getX () const override {return _x;} + double getY () const override {return _y;} + void setX (double x) override {_x = x; _svg.setX(x);} + void setY (double y) override {_y = y; _svg.setY(y);} + void finishLine () override {} + void setColor (const Color &color) override {_svg.setColor(color);} + Color getColor () const override {return _svg.getColor();} + void setMatrix (const Matrix &m) override {_svg.setMatrix(m);} + const Matrix& getMatrix () const override {return _svg.getMatrix();} + const SVGTree& svgTree () const override {return _svg;} + void setBgColor (const Color &color) override {} + void embed (const BoundingBox &bbox) override {_bbox.embed(bbox);} + void embed (const DPair &p, double r=0) override {if (r==0) _bbox.embed(p); else _bbox.embed(p, r);} + void progress (const char *id) override; + unsigned getCurrentPageNumber() const override {return 0;} + BoundingBox& bbox () override {return _bbox;} + BoundingBox& bbox (const std::string &name, bool reset=false) override {return _bbox;} + std::string getSVGFilename (unsigned pageno) const override; + std::string getBBoxFormatString () const override {return "";} + + private: + std::string _fname; ///< name of image file + SVGTree _svg; + SVGOutputBase &_out; + double _x=0, _y=0; + BoundingBox _bbox; + PsSpecialHandler _psHandler; + bool _haveGS=false; ///< true if Ghostscript is available + std::string _transCmds; ///< transformation commands +}; + +#endif |