Debian Codegraph @

src/LercLib/Lerc1Decode/TImage.hpp

raw symbols SCIP
1 /*
2 Copyright 2015 - 2026 Esri
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 A local copy of the license and additional notices are located with the
17 source distribution at:
18
19 http://github.com/Esri/lerc/
20
21 Contributors: Thomas Maurer
22 */
23
24 #ifndef TIMAGE_HPP
25 #define TIMAGE_HPPcxx . . $ `src/LercLib/Lerc1Decode/TImage.hpp:25:9`!
26
27 // ---- includes ------------------------------------------------------------ ;
28
29 #include <cstring>
30 #include <stdlib.h>
31 #include "Image.h"cxx . . $ `<file>/src/LercLib/Lerc1Decode/Image.h`/
32
33 NAMESPACE_LERC_STARTcxx . . $ `src/LercLib/Defines.h:35:9`!
34
35 class CntZcxx . . $ LercNS/CntZ#
36 {
37 public:
38 float cntcxx . . $ LercNS/CntZ#cnt., zcxx . . $ LercNS/CntZ#z.;
39 bool operatorcxx . . $ LercNS/CntZ#`operator==`(251439bf47861b68). == (const CntZcxx . . $ LercNS/CntZ#& cz) const { return cntcxx . . $ LercNS/CntZ#cnt. == cz.cntcxx . . $ LercNS/CntZ#cnt. && zcxx . . $ LercNS/CntZ#z. == cz.zcxx . . $ LercNS/CntZ#z.; }
40 bool operatorcxx . . $ LercNS/CntZ#`operator!=`(251439bf47861b68). != (const CntZcxx . . $ LercNS/CntZ#& cz) const { return cntcxx . . $ LercNS/CntZ#cnt. != cz.cntcxx . . $ LercNS/CntZ#cnt. || zcxx . . $ LercNS/CntZ#z. != cz.zcxx . . $ LercNS/CntZ#z.; }
41 void operatorcxx . . $ LercNS/CntZ#`operator+=`(6dea662788103482). += (const CntZcxx . . $ LercNS/CntZ#& cz) { cntcxx . . $ LercNS/CntZ#cnt. += cz.cntcxx . . $ LercNS/CntZ#cnt.; zcxx . . $ LercNS/CntZ#z. += cz.zcxx . . $ LercNS/CntZ#z.; }
42 };
43
44 template< class Element >
45 class TImagecxx . . $ LercNS/TImage# : public Imagecxx . . $ LercNS/Image#
46 {
47 public:
48 TImagecxx . . $ LercNS/TImage#`TImage<Element>`(49f6e7a06ebc5aa8).() : data_cxx . . $ LercNS/TImage#data_.(0) {}
49 TImagecxx . . $ LercNS/TImage#`TImage<Element>`(9440f60ef83a5d99).(const TImage& tImg) : data_cxx . . $ LercNS/TImage#data_.(0) { type_cxx . . $ LercNS/Image#type_. = tImg.type_cxx . . $ LercNS/Image#type_.; *this = tImg; }
50 virtual ~cxx . . $ LercNS/TImage#`~TImage<Element>`(49f6e7a06ebc5aa8).TImage() { clearcxx . . $ LercNS/TImage#clear(49f6e7a06ebc5aa8).(); }
51
52 /// assignment
53 virtual TImage& operatorcxx . . $ LercNS/TImage#`operator=`(90cf77e4230a9d1d).=(const TImage& tImg);
54
55 bool resizecxx . . $ LercNS/TImage#resize(cf9ef193275fa6d8).(int width, int height);
56 virtual void clearcxx . . $ LercNS/TImage#clear(49f6e7a06ebc5aa8).();
57
58 /// get data
59 Element getPixelcxx . . $ LercNS/TImage#getPixel(dfbfb0731a54165f).(int row, int col) const { return data_cxx . . $ LercNS/TImage#data_.[row * width_cxx . . $ LercNS/Image#width_. + col]; }
60 const Element& operatorcxx . . $ LercNS/TImage#`operator()`(17c8b25841cc6a04).() (int row, int col) const { return data_cxx . . $ LercNS/TImage#data_.[row * width_cxx . . $ LercNS/Image#width_. + col]; }
61 const Element* getDatacxx . . $ LercNS/TImage#getData(1016ee5406d91ab9).() const { return data_cxx . . $ LercNS/TImage#data_.; }
62
63 /// set data
64 void setPixelcxx . . $ LercNS/TImage#setPixel(2bc4eeef7859a16f).(int row, int col, Element element) { data_cxx . . $ LercNS/TImage#data_.[row * width_cxx . . $ LercNS/Image#width_. + col] = element; }
65 Element& operatorcxx . . $ LercNS/TImage#`operator()`(81532356f20a340f).() (int row, int col) { return data_cxx . . $ LercNS/TImage#data_.[row * width_cxx . . $ LercNS/Image#width_. + col]; }
66 Element* getDatacxx . . $ LercNS/TImage#getData(155dc7f103cdb9db).() { return data_cxx . . $ LercNS/TImage#data_.; }
67
68 /// compare
69 bool operatorcxx . . $ LercNS/TImage#`operator==`(1579293246f957a6). == (const Imagecxx . . $ LercNS/Image#& img) const;
70 bool operatorcxx . . $ LercNS/TImage#`operator!=`(1579293246f957a6). != (const Imagecxx . . $ LercNS/Image#& img) const { return !operator==(img); };
71
72 protected:
73 Element* data_cxx . . $ LercNS/TImage#data_.;
74 };
75
76 // -------------------------------------------------------------------------- ;
77
78 template< class Element >
79 bool TImagecxx . . $ LercNS/TImage#< Element >::resizecxx . . $ LercNS/TImage#resize(cf9ef193275fa6d8).(int width, int height)
80 {
81 if (width <= 0 || height <= 0)
82 return false;
83
84 if (width == width_cxx . . $ LercNS/Image#width_. && height == height_cxx . . $ LercNS/Image#height_. && data_cxx . . $ LercNS/TImage#data_.)
85 return true;
86
87 freecxx . . $ free(bd21765a0afc8e3c).(data_cxx . . $ LercNS/TImage#data_.);
88 width_cxx . . $ LercNS/Image#width_. = 0;
89 height_cxx . . $ LercNS/Image#height_. = 0;
90
91 data_cxx . . $ LercNS/TImage#data_. = (Element*)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Element) * width * height);
92 if (!data_cxx . . $ LercNS/TImage#data_.)
93 return false;
94
95 width_cxx . . $ LercNS/Image#width_. = width;
96 height_cxx . . $ LercNS/Image#height_. = height;
97
98 return true;
99 }
100
101 // -------------------------------------------------------------------------- ;
102
103 template< class Element >
104 void TImagecxx . . $ LercNS/TImage#< Element >::clearcxx . . $ LercNS/TImage#clear(49f6e7a06ebc5aa8).()
105 {
106 freecxx . . $ free(bd21765a0afc8e3c).(data_cxx . . $ LercNS/TImage#data_.);
107 data_cxx . . $ LercNS/TImage#data_. = 0;
108 width_cxx . . $ LercNS/Image#width_. = 0;
109 height_cxx . . $ LercNS/Image#height_. = 0;
110 }
111
112 // -------------------------------------------------------------------------- ;
113
114 template< class Element >
115 TImagecxx . . $ LercNS/TImage#< Element >& TImagecxx . . $ LercNS/TImage#< Element >::operatorcxx . . $ LercNS/TImage#`operator=`(90cf77e4230a9d1d). = (const TImage& tImg)
116 {
117 // allow copying image to itself
118 if (this == &tImg) return *this;
119
120 // only for images of the same type!
121 // conversions are implemented in the derived classes
122
123 if (!resizecxx . . $ LercNS/TImage#resize(cf9ef193275fa6d8).(tImg.getWidthcxx . . $ LercNS/Image#getWidth(455f465bc33b4cdf).(), tImg.getHeightcxx . . $ LercNS/Image#getHeight(455f465bc33b4cdf).()))
124 return *this; // return empty image if resize fails
125
126 if (data_cxx . . $ LercNS/TImage#data_. && tImg.data_cxx . . $ LercNS/TImage#data_.)
127 {
128 memcpy(data_cxx . . $ LercNS/TImage#data_., tImg.data_cxx . . $ LercNS/TImage#data_., getSizecxx . . $ LercNS/Image#getSize(455f465bc33b4cdf).() * sizeof(Element));
129 Imagecxx . . $ LercNS/Image#::operator=(tImg);
130 }
131
132 return *this;
133 }
134
135 // -------------------------------------------------------------------------- ;
136
137 template< class Element >
138 bool TImagecxx . . $ LercNS/TImage#< Element >::operatorcxx . . $ LercNS/TImage#`operator==`(1579293246f957a6). == (const Imagecxx . . $ LercNS/Image#& img) const
139 {
140 if (!Imagecxx . . $ LercNS/Image#::operator == (img)) return false;
141
142 const Element* ptr0 = getDatacxx . . $ LercNS/TImage#getData(1016ee5406d91ab9).();
143 const Element* ptr1 = ((const TImage&)img).getDatacxx . . $ LercNS/TImage#getData(155dc7f103cdb9db).();
144 int cnt = getSizecxx . . $ LercNS/Image#getSize(455f465bc33b4cdf).();
145 while (cnt--)
146 if (*ptr0++ != *ptr1++)
147 return false;
148
149 return true;
150 }
151
152 // -------------------------------------------------------------------------- ;
153
154 NAMESPACE_LERC_ENDcxx . . $ `src/LercLib/Defines.h:36:9`!
155 #endif