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 405 of file rt_raster.c.
References ovdump::band, rt_raster_t::bands, rt_raster_t::height, rt_band_t::height, rt_raster_t::numBands, rtrowdump::raster, rt_band_t::raster, RASTER_DEBUG, RASTER_DEBUGF, rterror(), rtrealloc(), rt_raster_t::width, and rt_band_t::width.
Referenced by convert_raster(), cu_add_band(), RASTER_addBandOutDB(), RASTER_clip(), RASTER_tile(), rt_raster_colormap(), rt_raster_copy_band(), rt_raster_generate_new_band(), and test_band_metadata().
411 assert(NULL != raster);
412 assert(NULL != band);
414 RASTER_DEBUGF(3,
"Adding band %p to raster %p", band, raster);
417 rterror(
"rt_raster_add_band: Can't add a %dx%d band to a %dx%d raster",
428 oldbands = raster->
bands;
438 if (NULL == raster->
bands) {
439 rterror(
"rt_raster_add_band: Out of virtual memory " 440 "reallocating band pointers");
441 raster->
bands = oldbands;
447 for (i = 0; i <= raster->
numBands; ++i) {
449 oldband = raster->
bands[i];
451 }
else if (i > index) {
452 tmpband = raster->
bands[i];
453 raster->
bands[i] = oldband;
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtrealloc(void *mem, size_t size)
#define RASTER_DEBUGF(level, msg,...)
#define RASTER_DEBUG(level, msg)