/src/gdal/gcore/gdalallvalidmaskband.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL Core |
4 | | * Purpose: Implementation of GDALAllValidMaskBand, a class implementing all |
5 | | * a default 'all valid' band mask. |
6 | | * Author: Frank Warmerdam, warmerdam@pobox.com |
7 | | * |
8 | | ****************************************************************************** |
9 | | * Copyright (c) 2007, Frank Warmerdam |
10 | | * |
11 | | * SPDX-License-Identifier: MIT |
12 | | ****************************************************************************/ |
13 | | |
14 | | #include "cpl_port.h" |
15 | | #include "gdal_priv.h" |
16 | | |
17 | | #include <cstring> |
18 | | |
19 | | #include "gdal.h" |
20 | | #include "cpl_error.h" |
21 | | |
22 | | //! @cond Doxygen_Suppress |
23 | | /************************************************************************/ |
24 | | /* GDALAllValidMaskBand() */ |
25 | | /************************************************************************/ |
26 | | |
27 | | GDALAllValidMaskBand::GDALAllValidMaskBand(GDALRasterBand *poParent) |
28 | 3.90M | : GDALRasterBand(FALSE) |
29 | 3.90M | { |
30 | 3.90M | poDS = nullptr; |
31 | 3.90M | nBand = 0; |
32 | | |
33 | 3.90M | nRasterXSize = poParent->GetXSize(); |
34 | 3.90M | nRasterYSize = poParent->GetYSize(); |
35 | | |
36 | 3.90M | eDataType = GDT_Byte; |
37 | 3.90M | poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); |
38 | 3.90M | } |
39 | | |
40 | | /************************************************************************/ |
41 | | /* ~GDALAllValidMaskBand() */ |
42 | | /************************************************************************/ |
43 | | |
44 | 3.90M | GDALAllValidMaskBand::~GDALAllValidMaskBand() = default; |
45 | | |
46 | | /************************************************************************/ |
47 | | /* IReadBlock() */ |
48 | | /************************************************************************/ |
49 | | |
50 | | CPLErr GDALAllValidMaskBand::IReadBlock(int /* nXBlockOff */, |
51 | | int /* nYBlockOff */, void *pImage) |
52 | 90.1k | { |
53 | 90.1k | memset(pImage, 255, static_cast<size_t>(nBlockXSize) * nBlockYSize); |
54 | | |
55 | 90.1k | return CE_None; |
56 | 90.1k | } |
57 | | |
58 | | /************************************************************************/ |
59 | | /* IRasterIO() */ |
60 | | /************************************************************************/ |
61 | | |
62 | | CPLErr GDALAllValidMaskBand::IRasterIO(GDALRWFlag eRWFlag, int, int, int, int, |
63 | | void *pData, int nBufXSize, |
64 | | int nBufYSize, GDALDataType eBufType, |
65 | | GSpacing nPixelSpace, |
66 | | GSpacing nLineSpace, |
67 | | GDALRasterIOExtraArg *) |
68 | 1.10M | { |
69 | 1.10M | if (eRWFlag != GF_Read) |
70 | 0 | { |
71 | 0 | return CE_Failure; |
72 | 0 | } |
73 | | |
74 | 1.10M | GByte *pabyData = static_cast<GByte *>(pData); |
75 | 1.10M | GByte byVal = 255; |
76 | 7.03M | for (int iY = 0; iY < nBufYSize; ++iY) |
77 | 5.93M | { |
78 | 5.93M | GDALCopyWords64(&byVal, GDT_Byte, 0, pabyData + iY * nLineSpace, |
79 | 5.93M | eBufType, static_cast<int>(nPixelSpace), nBufXSize); |
80 | 5.93M | } |
81 | | |
82 | 1.10M | return CE_None; |
83 | 1.10M | } |
84 | | |
85 | | /************************************************************************/ |
86 | | /* EmitErrorMessageIfWriteNotSupported() */ |
87 | | /************************************************************************/ |
88 | | |
89 | | bool GDALAllValidMaskBand::EmitErrorMessageIfWriteNotSupported( |
90 | | const char *pszCaller) const |
91 | 0 | { |
92 | 0 | ReportError(CE_Failure, CPLE_NoWriteAccess, |
93 | 0 | "%s: attempt to write to an all-valid implicit mask band.", |
94 | 0 | pszCaller); |
95 | |
|
96 | 0 | return true; |
97 | 0 | } |
98 | | |
99 | | /************************************************************************/ |
100 | | /* GetMaskBand() */ |
101 | | /************************************************************************/ |
102 | | |
103 | | GDALRasterBand *GDALAllValidMaskBand::GetMaskBand() |
104 | | |
105 | 0 | { |
106 | 0 | return this; |
107 | 0 | } |
108 | | |
109 | | /************************************************************************/ |
110 | | /* GetMaskFlags() */ |
111 | | /************************************************************************/ |
112 | | |
113 | | int GDALAllValidMaskBand::GetMaskFlags() |
114 | | |
115 | 1.48k | { |
116 | 1.48k | return GMF_ALL_VALID; |
117 | 1.48k | } |
118 | | |
119 | | /************************************************************************/ |
120 | | /* ComputeStatistics() */ |
121 | | /************************************************************************/ |
122 | | |
123 | | CPLErr GDALAllValidMaskBand::ComputeStatistics( |
124 | | int /* bApproxOK */, double *pdfMin, double *pdfMax, double *pdfMean, |
125 | | double *pdfStdDev, GDALProgressFunc, void * /*pProgressData*/) |
126 | 642 | { |
127 | 642 | if (pdfMin) |
128 | 642 | *pdfMin = 255.0; |
129 | 642 | if (pdfMax) |
130 | 642 | *pdfMax = 255.0; |
131 | 642 | if (pdfMean) |
132 | 642 | *pdfMean = 255.0; |
133 | 642 | if (pdfStdDev) |
134 | 642 | *pdfStdDev = 0.0; |
135 | 642 | return CE_None; |
136 | 642 | } |
137 | | |
138 | | //! @endcond |