Set values of multiple pixels.
Unlike rt_band_set_pixel, values in vals are expected to be of the band's pixel type as this function uses memcpy.
It is important to be careful when using this function as the number of values being set may exceed a pixel "row". Remember that the band values are stored in a stream (1-D array) regardless of what the raster's width and height might be. So, setting a number of values may cross multiple pixel "rows".
857 {
859 int size = 0;
860 uint8_t *
data = NULL;
861 uint32_t offset = 0;
862
863 assert(NULL != band);
864 assert(vals != NULL && len > 0);
865
867
869 rterror(
"rt_band_set_pixel_line not implemented yet for OFFDB bands");
871 }
872
873 pixtype =
band->pixtype;
875
876 if (
877 x < 0 || x >=
band->width ||
878 y < 0 || y >=
band->height
879 ) {
880 rterror(
"rt_band_set_pixel_line: Coordinates out of range (%d, %d) vs (%d, %d)", x, y,
band->width,
band->height);
882 }
883
885 offset =
x + (
y *
band->width);
887
888
889 if (len > (
band->width *
band->height) - offset) {
890 rterror(
"rt_band_set_pixel_line: Could not apply pixels as values length exceeds end of data");
892 }
893
894 switch (pixtype) {
901 ptr += offset;
902 memcpy(ptr, vals, size * len);
903 break;
904 }
906 uint16_t *ptr = (uint16_t *) data;
907 ptr += offset;
908 memcpy(ptr, vals, size * len);
909 break;
910 }
912 int16_t *ptr = (int16_t *) data;
913 ptr += offset;
914 memcpy(ptr, vals, size * len);
915 break;
916 }
918 uint32_t *ptr = (uint32_t *) data;
919 ptr += offset;
920 memcpy(ptr, vals, size * len);
921 break;
922 }
924 int32_t *ptr = (int32_t *) data;
925 ptr += offset;
926 memcpy(ptr, vals, size * len);
927 break;
928 }
930 float *ptr = (float *) data;
931 ptr += offset;
932 memcpy(ptr, vals, size * len);
933 break;
934 }
936 double *ptr = (double *) data;
937 ptr += offset;
938 memcpy(ptr, vals, size * len);
939 break;
940 }
941 default: {
942 rterror(
"rt_band_set_pixel_line: Unknown pixeltype %d", pixtype);
944 }
945 }
946
947#if POSTGIS_DEBUG_LEVEL > 0
948 {
952 }
953#endif
954
955
958
960}
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag)
Set isnodata flag value.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.