/* Serialize bands now */
for (i = 0; i < raster->numBands; ++i) {
rt_band band = raster->bands[i];
+ RASTER_DEBUGF(3, "band %d at %p", i, raster->bands[i]);
assert(NULL != band);
rt_pixtype pixtype = band->pixtype;
ptr += 1;
/* Add padding (if needed) */
+ RASTER_DEBUGF(3, "modulus: %d", (((uintptr_t) ptr) % pixbytes));
if (pixbytes > 1) {
memset(ptr, '\0', pixbytes - 1);
ptr += pixbytes - 1;
+ RASTER_DEBUG(3, "added padding");
}
#if POSTGIS_DEBUG_LEVEL > 2
*ptr = 0;
++ptr;
- RASTER_DEBUGF(3, "PAD at %d", (uint64_t) ptr % 8);
+ RASTER_DEBUGF(3, "PAD at %d", (uintptr_t) ptr % 8);
}
BEGIN
num_bands := st_numbands($1);
- -- JPEG only supports 8BUI pixeltype
- FOR i IN 1..num_bands LOOP
- IF st_bandpixeltype(rast, i) != '8BUI' THEN
- RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.', i;
- END IF;
- END LOOP;
-
-- JPEG only allows 1 or 3 bands
-- we only use the first
- IF num_bands <> 1 AND num_bands <> 333 THEN
+ IF num_bands <> 1 AND num_bands <> 3 THEN
RAISE NOTICE 'The JPEG format only permits one or three bands. The first band will be used.';
rast2 := st_band(rast, ARRAY[1]);
num_bands := st_numbands(rast);
rast2 := rast;
END IF;
+ -- JPEG only supports 8BUI pixeltype
+ FOR i IN 1..num_bands LOOP
+ IF st_bandpixeltype(rast, i) != '8BUI' THEN
+ RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.', i;
+ END IF;
+ END LOOP;
+
RETURN st_asgdalraster(rast2, 'JPEG', $2, NULL);
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
1
ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.
1
-NOTICE: The JPEG format only permits one or three bands. The first band will be used.
1
ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.
+NOTICE: The JPEG format only permits one or three bands. The first band will be used.
ERROR: The pixel type of band 1 in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.
1