116 bytea *result = NULL;
119 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
120 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
125 PG_FREE_IF_COPY(pgraster, 0);
126 elog(ERROR,
"RASTER_to_bytea: Could not deserialize raster");
134 PG_FREE_IF_COPY(pgraster, 0);
135 elog(ERROR,
"RASTER_to_bytea: Could not allocate and generate WKB data");
140 result_size = wkb_size + VARHDRSZ;
141 result = (bytea *)palloc(result_size);
142 SET_VARSIZE(result, result_size);
143 memcpy(VARDATA(result), wkb, VARSIZE(result) - VARHDRSZ);
148 PG_FREE_IF_COPY(pgraster, 0);
150 PG_RETURN_POINTER(result);
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.