/src/lerc/src/LercLib/Lerc1Decode/CntZImage.h
Line | Count | Source |
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 CNTZIMAGE_H |
25 | | #define CNTZIMAGE_H |
26 | | |
27 | | #include <vector> |
28 | | #include "TImage.hpp" |
29 | | |
30 | | NAMESPACE_LERC_START |
31 | | |
32 | | /** count / z image |
33 | | * |
34 | | * count can also be a weight, therefore float; |
35 | | * z can be elevation or intensity; |
36 | | */ |
37 | | |
38 | | class CntZImage : public TImage< CntZ > |
39 | | { |
40 | | public: |
41 | | CntZImage(); |
42 | 0 | virtual ~CntZImage() {}; |
43 | 0 | std::string getTypeString() const { return "CntZImage "; } |
44 | | |
45 | | bool resizeFill0(int width, int height); |
46 | | |
47 | | static unsigned int computeNumBytesNeededToReadHeader(bool onlyZPart); |
48 | | |
49 | | /// read succeeds only if maxZError on file <= maxZError requested |
50 | | bool read(const Byte** ppByte, const Byte* bArr_end, double maxZError, bool onlyHeader = false, bool onlyZPart = false); |
51 | | |
52 | | protected: |
53 | | |
54 | | struct InfoFromComputeNumBytes |
55 | | { |
56 | | double maxZError; |
57 | | bool cntsNoInt; |
58 | | int numTilesVertCnt; |
59 | | int numTilesHoriCnt; |
60 | | int numBytesCnt; |
61 | | float maxCntInImg; |
62 | | int numTilesVertZ; |
63 | | int numTilesHoriZ; |
64 | | int numBytesZ; |
65 | | float maxZInImg; |
66 | | }; |
67 | | |
68 | | bool readTiles(bool zPart, double maxZErrorInFile, int numTilesVert, int numTilesHori, float maxValInImg, const Byte* bArr); |
69 | | |
70 | | bool readCntTile(const Byte** ppByte, int i0, int i1, int j0, int j1); |
71 | | bool readZTile(const Byte** ppByte, int i0, int i1, int j0, int j1, double maxZErrorInFile, float maxZInImg); |
72 | | |
73 | | static int numBytesFlt(float z); // returns 1, 2, or 4 |
74 | | static bool readFlt(const Byte** ppByte, float& z, int numBytes); |
75 | | |
76 | | protected: |
77 | | |
78 | | InfoFromComputeNumBytes m_infoFromComputeNumBytes; |
79 | | std::vector<unsigned int> m_tmpDataVec; // used in read fcts |
80 | | bool m_bDecoderCanIgnoreMask; // " |
81 | | }; |
82 | | |
83 | | NAMESPACE_LERC_END |
84 | | #endif |