Add band data to a raster.
- Parameters
-
| raster | : the raster to add a band to |
| band | : the band to add, ownership left to caller. Band dimensions are required to match with raster ones. |
| index | : the position where to insert the new band (0 based) |
- Returns
- identifier (position) for the just-added raster, or -1 on error
Definition at line 409 of file rt_raster.c.
409 {
413 uint16_t i = 0;
414
415 assert(NULL != raster);
416 assert(NULL != band);
417
418 RASTER_DEBUGF(3,
"Adding band %p to raster %p", band, raster);
419
421 rterror(
"rt_raster_add_band: Can't add a %dx%d band to a %dx%d raster",
423 return -1;
424 }
425
426 if (index >
raster->numBands)
428
429 if (index < 0)
430 index = 0;
431
433
435
438 );
439
441
442 if (NULL ==
raster->bands) {
443 rterror(
"rt_raster_add_band: Out of virtual memory "
444 "reallocating band pointers");
446 return -1;
447 }
448
450
451 for (i = 0; i <=
raster->numBands; ++i) {
452 if (i == index) {
453 oldband =
raster->bands[i];
455 } else if (i > index) {
456 tmpband =
raster->bands[i];
457 raster->bands[i] = oldband;
458 oldband = tmpband;
459 }
460 }
461
463
465
467
468 return index;
469}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUG(level, msg)
#define RASTER_DEBUGF(level, msg,...)
void * rtrealloc(void *mem, size_t size)
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
References RASTER_DEBUG, RASTER_DEBUGF, rterror(), and rtrealloc().
Referenced by convert_raster(), cu_add_band(), RASTER_addBandOutDB(), RASTER_tile(), rt_raster_colormap(), rt_raster_copy_band(), rt_raster_generate_new_band(), and test_band_metadata().