ViewBase.h
1/* Copyright (C) 2015 Marc Boris Duerner
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public
5 License as published by the Free Software Foundation; either
6 version 2.1 of the License, or (at your option) any later version.
7
8 As a special exception, you may use this file as part of a free
9 software library without restriction. Specifically, if other files
10 instantiate templates or use macros or inline functions from this
11 file, or you compile this file and link it with other files to
12 produce an executable, this file does not by itself cause the
13 resulting executable to be covered by the GNU General Public
14 License. This exception does not however invalidate any other
15 reasons why the executable file might be covered by the GNU Library
16 General Public License.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 MA 02110-1301 USA
27*/
28
29#ifndef PT_GFX_VIEWBASE_H
30#define PT_GFX_VIEWBASE_H
31
32#include <Pt/Gfx/Api.h>
33#include <Pt/Types.h>
34
35namespace Pt {
36
37namespace Gfx {
38
49class ViewBase
50{
51 public:
52 typedef Pt::ssize_t pos_t;
53 typedef Pt::ssize_t length_t;
54
55 public:
56 ViewBase()
57 : _width(0)
58 , _height(0)
59 , _stride(0)
60 { }
61
62 ViewBase(Pt::ssize_t width, Pt::ssize_t height,
63 Pt::ssize_t stride)
64 : _width(width)
65 , _height(height)
66 , _stride(stride)
67 { }
68
69 Pt::ssize_t width() const
70 { return _width; }
71
72 Pt::ssize_t height() const
73 { return _height; }
74
75 bool empty() const
76 { return _width == 0 || _height == 0; }
77
78 Pt::ssize_t stride() const
79 { return _stride; }
80
81 protected:
82 ~ViewBase()
83 { }
84
85 protected:
86 void setDimensions(Pt::ssize_t w, Pt::ssize_t h,
87 Pt::ssize_t s)
88 {
89 _width = w;
90 _height = h;
91 _stride = s;
92 }
93
94 private:
95 Pt::ssize_t _width;
96 Pt::ssize_t _height;
97 Pt::ssize_t _stride;
98};
99
100} // namespace
101
102} // namespace
103
104#endif
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33