Bitmap.h
1 /* Copyright (C) 2015 Marc Boris Duerner
2  Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  As a special exception, you may use this file as part of a free
10  software library without restriction. Specifically, if other files
11  instantiate templates or use macros or inline functions from this
12  file, or you compile this file and link it with other files to
13  produce an executable, this file does not by itself cause the
14  resulting executable to be covered by the GNU General Public
15  License. This exception does not however invalidate any other
16  reasons why the executable file might be covered by the GNU Library
17  General Public License.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library; if not, write to the Free Software
26  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27  MA 02110-1301 USA
28 */
29 
30 #ifndef PT_GFX_BITMAP_H
31 #define PT_GFX_BITMAP_H
32 
33 #include <Pt/Gfx/Api.h>
34 #include <Pt/Gfx/FontFace.h>
35 #include <Pt/Gfx/PaintSurface.h>
36 #include <Pt/Gfx/Paint.h>
37 #include <Pt/Gfx/Point.h>
38 #include <Pt/Gfx/Size.h>
39 #include <Pt/Gfx/Rect.h>
40 #include <Pt/System/Path.h>
41 
42 #include <string>
43 #include <vector>
44 #include <cstddef>
45 
46 namespace Pt {
47 
48 namespace Gfx {
49 
50 class BitmapSurface;
51 
54 class PT_GFX_API Bitmap : public PaintSurface
55 {
56  public:
57  Bitmap();
58 
59  Bitmap(const Gfx::SizeF& size, std::size_t stride = 0);
60 
61  virtual ~Bitmap();
62 
65  void reset();
66 
69  void reset(const Gfx::Image& image);
70 
73  void reset(const Gfx::SizeF&, std::size_t stride = 0);
74 
75  bool empty() const;
76 
77  const Gfx::Image& image() const;
78 
79  void setScaleFactor(double scaleFactor);
80 
81  void drawBitmap(const Pt::Gfx::PointF& to, const Bitmap& image,
82  const Gfx::Paint& paint, const Gfx::RectF* rect = 0);
83 
84  protected:
85  virtual const Gfx::ImageFormat& onGetFormat() const;
86 
87  virtual const Gfx::SizeF& onGetSize() const;
88 
89  virtual const Scaling& onGetScaling() const;
90 
91  protected:
92  virtual Gfx::Canvas* onCreateCanvas(Gfx::Canvas* reuse) override;
93 
94  virtual void onReleaseCanvas() override;
95 
96  virtual void onSync() override;
97 
98  virtual void onFinish() override;
99 
100  public:
101  static const std::string& defaultFont();
102 
103  static void setDefaultFont(const std::string& family);
104 
105  static std::vector<std::string> fontFamilies();
106 
107  static std::vector<FontFace> fontFaces(const std::string& family);
108 
109  private:
110  BitmapSurface* _surface;
111 };
112 
113 } // namespace
114 
115 } // namespace
116 
117 #endif
118 
Paint surface.
Definition: PaintSurface.h:47
Rect with floating-point coordinates.
Definition: Rect.h:44
Basic image.
Definition: Api.h:81
Paint context.
Definition: Canvas.h:57
Paint context.
Definition: Paint.h:44
Image drawing surface.
Definition: Bitmap.h:54
Size with floating-point width and height.
Definition: Size.h:44
Image format.
Definition: ImageFormat.h:52
Surface scaling.
Definition: Scaling.h:43
Point with floating-point X and Y coordinates.
Definition: Point.h:44