1 // -*- C++ -*-
2 // --------------------------------------------------------------------
3 // ipe::Thumbnail
4 // --------------------------------------------------------------------
5 /*
6 
7     This file is part of the extensible drawing editor Ipe.
8     Copyright (c) 1993-2020 Otfried Cheong
9 
10     Ipe is free software; you can redistribute it and/or modify it
11     under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 3 of the License, or
13     (at your option) any later version.
14 
15     As a special exception, you have permission to link Ipe with the
16     CGAL library and distribute executables, as long as you follow the
17     requirements of the Gnu General Public License in regard to all of
18     the software in the executable aside from CGAL.
19 
20     Ipe is distributed in the hope that it will be useful, but WITHOUT
21     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
23     License for more details.
24 
25     You should have received a copy of the GNU General Public License
26     along with Ipe; if not, you can find it at
27     "http://www.gnu.org/copyleft/gpl.html", or write to the Free
28     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 
30 */
31 
32 #ifndef IPETHUMBS_H
33 #define IPETHUMBS_H
34 
35 #include "ipedoc.h"
36 #include "ipefonts.h"
37 
38 // --------------------------------------------------------------------
39 
40 namespace ipe {
41 
42   class Thumbnail {
43   public:
44     enum TargetFormat { ESVG, EPNG, EPS, EPDF };
45 
46     Thumbnail(const Document *doc, int width);
47 
setTransparent(bool t)48     void setTransparent(bool t) { iTransparent = t; }
setNoCrop(bool n)49     void setNoCrop(bool n) {iNoCrop = n; }
50 
width()51     int width() const { return iWidth; }
height()52     int height() const { return iHeight; }
53     Buffer render(const Page *page, int view);
54     bool saveRender(TargetFormat fm, const char *dst,
55 		    const Page *page, int view, double zoom);
56   private:
57     const Document *iDoc;
58     bool iTransparent;
59     bool iNoCrop;
60     int iWidth;
61     int iHeight;
62     double iZoom;
63     const Layout *iLayout;
64     std::unique_ptr<Fonts> iFonts;
65   };
66 
67   class PdfThumbnail {
68   public:
69     PdfThumbnail(const PdfFile *pdf, int width);
width()70     int width() const { return iWidth; }
height()71     int height() const { return iHeight; }
72     Buffer render(const PdfDict *page);
73   private:
74     const PdfFile *iPdf;
75     int iWidth;
76     int iHeight;
77     std::unique_ptr<Cascade> iCascade; // dummy stylesheet
78     std::unique_ptr<PdfFileResources> iResources;
79     std::unique_ptr<Fonts> iFonts;
80   };
81 
82 } // namespace
83 
84 // --------------------------------------------------------------------
85 #endif
86