PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_band_pixtype_1BB()

static void test_band_pixtype_1BB ( )
static

Definition at line 150 of file cu_band_basics.c.

150 {
151 rt_pixtype pixtype = PT_1BB;
152 uint8_t *data = NULL;
153 rt_band band = NULL;
154 int width = 5;
155 int height = 5;
156 int err = 0;
157 int clamped = 0;
158 double val = 0;
159 int x;
160 int y;
161
162 /* inline band */
163 data = rtalloc(rt_pixtype_size(pixtype) * width * height);
164 CU_ASSERT(data != NULL);
165 memset(data, 0, rt_pixtype_size(pixtype) * width * height);
166
168 width, height,
169 pixtype,
170 0, 0,
171 data
172 );
173 CU_ASSERT(band != NULL);
175 CU_ASSERT(rt_band_get_ownsdata_flag(band));
176
177 err = rt_band_set_nodata(band, 1, &clamped);
178 CU_ASSERT_EQUAL(err, ES_NONE);
179 CU_ASSERT(!clamped);
180
181 rt_band_get_nodata(band, &val);
182 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
183 err = rt_band_set_nodata(band, 0, &clamped);
184 CU_ASSERT_EQUAL(err, ES_NONE);
185 CU_ASSERT(!clamped);
186 rt_band_get_nodata(band, &val);
187 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
188
189 err = rt_band_set_nodata(band, 2, &clamped);
190 CU_ASSERT_EQUAL(err, ES_NONE);
191 CU_ASSERT(clamped);
192
193 err = rt_band_set_nodata(band, 3, &clamped);
194 CU_ASSERT_EQUAL(err, ES_NONE);
195 CU_ASSERT(clamped);
196
197 err = rt_band_set_pixel(band, 0, 0, 2, &clamped);
198 CU_ASSERT_EQUAL(err, ES_NONE);
199 CU_ASSERT(clamped);
200
201 err = rt_band_set_pixel(band, 0, 0, 3, &clamped);
202 CU_ASSERT_EQUAL(err, ES_NONE);
203 CU_ASSERT(clamped);
204
205 for (x = 0; x < rt_band_get_width(band); ++x) {
206 for ( y = 0; y < rt_band_get_height(band); ++y) {
207 err = rt_band_set_pixel(band, x, y, 1, NULL);
208 CU_ASSERT_EQUAL(err, ES_NONE);
209 err = rt_band_get_pixel(band, x, y, &val, NULL);
210 CU_ASSERT_EQUAL(err, ES_NONE);
211 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
212
213 err = rt_band_set_pixel(band, x, y, 0, NULL);
214 CU_ASSERT_EQUAL(err, ES_NONE);
215 err = rt_band_get_pixel(band, x, y, &val, NULL);
216 CU_ASSERT_EQUAL(err, ES_NONE);
217 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
218 }
219 }
220
221 rt_band_destroy(band);
222}
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
Definition rt_band.c:64
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition rt_band.c:826
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
Definition rt_band.c:799
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition rt_band.c:1551
rt_pixtype
Definition librtcore.h:188
@ PT_1BB
Definition librtcore.h:189
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition rt_band.c:892
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
Definition rt_band.c:1140
@ ES_NONE
Definition librtcore.h:182
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition rt_band.c:499
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition rt_band.c:2067
int rt_band_get_ownsdata_flag(rt_band band)
Return 0 (FALSE) or non-zero (TRUE) indicating if rt_band is responsible for managing the memory for ...
Definition rt_band.c:818
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
Definition rt_band.c:808
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition rt_pixel.c:40

References ES_NONE, PT_1BB, rt_band_destroy(), rt_band_get_height(), rt_band_get_nodata(), rt_band_get_ownsdata_flag(), rt_band_get_pixel(), rt_band_get_width(), rt_band_new_inline(), rt_band_set_nodata(), rt_band_set_ownsdata_flag(), rt_band_set_pixel(), rt_pixtype_size(), and rtalloc().

Referenced by band_basics_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: