PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_band_pixtype_1BB()

static void test_band_pixtype_1BB ( )
static

Definition at line 143 of file cu_band_basics.c.

References ovdump::band, ovdump::data, 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(), rtalloc(), pixval::x, and pixval::y.

Referenced by band_basics_suite_setup().

143  {
144  rt_pixtype pixtype = PT_1BB;
145  uint8_t *data = NULL;
146  rt_band band = NULL;
147  int width = 5;
148  int height = 5;
149  int err = 0;
150  int clamped = 0;
151  double val = 0;
152  int x;
153  int y;
154 
155  /* inline band */
156  data = rtalloc(rt_pixtype_size(pixtype) * width * height);
157  CU_ASSERT(data != NULL);
158  memset(data, 0, rt_pixtype_size(pixtype) * width * height);
159 
160  band = rt_band_new_inline(
161  width, height,
162  pixtype,
163  0, 0,
164  data
165  );
166  CU_ASSERT(band != NULL);
167  rt_band_set_ownsdata_flag(band, 1);
168  CU_ASSERT(rt_band_get_ownsdata_flag(band));
169 
170  err = rt_band_set_nodata(band, 1, &clamped);
171  CU_ASSERT_EQUAL(err, ES_NONE);
172  CU_ASSERT(!clamped);
173 
174  rt_band_get_nodata(band, &val);
175  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
176  err = rt_band_set_nodata(band, 0, &clamped);
177  CU_ASSERT_EQUAL(err, ES_NONE);
178  CU_ASSERT(!clamped);
179  rt_band_get_nodata(band, &val);
180  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
181 
182  err = rt_band_set_nodata(band, 2, &clamped);
183  CU_ASSERT_EQUAL(err, ES_NONE);
184  CU_ASSERT(clamped);
185 
186  err = rt_band_set_nodata(band, 3, &clamped);
187  CU_ASSERT_EQUAL(err, ES_NONE);
188  CU_ASSERT(clamped);
189 
190  err = rt_band_set_pixel(band, 0, 0, 2, &clamped);
191  CU_ASSERT_EQUAL(err, ES_NONE);
192  CU_ASSERT(clamped);
193 
194  err = rt_band_set_pixel(band, 0, 0, 3, &clamped);
195  CU_ASSERT_EQUAL(err, ES_NONE);
196  CU_ASSERT(clamped);
197 
198  for (x = 0; x < rt_band_get_width(band); ++x) {
199  for ( y = 0; y < rt_band_get_height(band); ++y) {
200  err = rt_band_set_pixel(band, x, y, 1, NULL);
201  CU_ASSERT_EQUAL(err, ES_NONE);
202  err = rt_band_get_pixel(band, x, y, &val, NULL);
203  CU_ASSERT_EQUAL(err, ES_NONE);
204  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
205 
206  err = rt_band_set_pixel(band, x, y, 0, NULL);
207  CU_ASSERT_EQUAL(err, ES_NONE);
208  err = rt_band_get_pixel(band, x, y, &val, NULL);
209  CU_ASSERT_EQUAL(err, ES_NONE);
210  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
211  }
212  }
213 
214  rt_band_destroy(band);
215 }
band
Definition: ovdump.py:57
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
data
Definition: ovdump.py:103
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_band.c:600
rt_pixtype
Definition: librtcore.h:185
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:242
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1597
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_band.c:534
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:526
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1088
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
Definition: rt_band.c:507
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
Definition: rt_band.c:516
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:58
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel&#39;s value.
Definition: rt_band.c:841
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: