1 /*
2 
3  rasterlite2 -- main header file
4 
5  version 0.1, 2013 March 29
6 
7  Author: Sandro Furieri a.furieri@lqt.it
8 
9  -----------------------------------------------------------------------------
10 
11  Version: MPL 1.1/GPL 2.0/LGPL 2.1
12 
13  The contents of this file are subject to the Mozilla Public License Version
14  1.1 (the "License"); you may not use this file except in compliance with
15  the License. You may obtain a copy of the License at
16  http://www.mozilla.org/MPL/
17 
18 Software distributed under the License is distributed on an "AS IS" basis,
19 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20 for the specific language governing rights and limitations under the
21 License.
22 
23 The Original Code is the RasterLite2 library
24 
25 The Initial Developer of the Original Code is Alessandro Furieri
26 
27 Portions created by the Initial Developer are Copyright (C) 2013
28 the Initial Developer. All Rights Reserved.
29 
30 Alternatively, the contents of this file may be used under the terms of
31 either the GNU General Public License Version 2 or later (the "GPL"), or
32 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33 in which case the provisions of the GPL or the LGPL are applicable instead
34 of those above. If you wish to allow use of your version of this file only
35 under the terms of either the GPL or the LGPL, and not to allow others to
36 use your version of this file under the terms of the MPL, indicate your
37 decision by deleting the provisions above and replace them with the notice
38 and other provisions required by the GPL or the LGPL. If you do not delete
39 the provisions above, a recipient may use your version of this file under
40 the terms of any one of the MPL, the GPL or the LGPL.
41 
42 */
43 
44 /**
45  \file rasterlite2.h
46 
47  Main RasterLite2 header file
48  */
49 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 #ifdef _WIN32
52 #ifdef DLL_EXPORT
53 #define RL2_DECLARE __declspec(dllexport)
54 #else
55 #define RL2_DECLARE extern
56 #endif
57 #else
58 #define RL2_DECLARE __attribute__ ((visibility("default")))
59 #endif
60 #endif
61 
62 #ifndef _RASTERLITE2_H
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
64 #define _RASTERLITE2_H
65 #endif
66 
67 
68 #ifdef __cplusplus
69 extern "C"
70 {
71 #endif
72 
73 #ifdef SPATIALITE_AMALGAMATION
74 #include <spatialite/sqlite3.h>
75 #else
76 #include <sqlite3.h>
77 #endif
78 
79 #include <spatialite/gaiageo.h>
80 
81 /** RasterLite2 flag: FALSE */
82 #define RL2_FALSE			0
83 /** RasterLite2 flag: TRUE */
84 #define RL2_TRUE			1
85 
86 /** RasterLite2 ret-value: OK (success) */
87 #define RL2_OK				0
88 /** RasterLite2 ret-value: ERROR (failure) */
89 #define RL2_ERROR			-1
90 
91 /** RasterLite2 constant: INVALID/UNDEFINED Pyramid Level */
92 #define RL_INVALID_PYRAMID_LEVEL	-1
93 
94 /** RasterLite2 constant: Sample Type UNKNOWN */
95 #define RL2_SAMPLE_UNKNOWN		0xa0
96 /** RasterLite2 constant: Sample Type 1-bit */
97 #define RL2_SAMPLE_1_BIT		0xa1
98 /** RasterLite2 constant: Sample Type 2-bit */
99 #define RL2_SAMPLE_2_BIT		0xa2
100 /** RasterLite2 constant: Sample Type 4-bit */
101 #define RL2_SAMPLE_4_BIT		0xa3
102 /** RasterLite2 constant: Sample Type 8 bit Integer */
103 #define RL2_SAMPLE_INT8			0xa4
104 /** RasterLite2 constant: Sample Type 8 bit Unsigned Integer */
105 #define RL2_SAMPLE_UINT8		0xa5
106 /** RasterLite2 constant: Sample Type 16 bit Integer */
107 #define RL2_SAMPLE_INT16		0xa6
108 /** RasterLite2 constant: Sample Type 16 bit Unsigned Integer */
109 #define RL2_SAMPLE_UINT16		0xa7
110 /** RasterLite2 constant: Sample Type 32 bit Integer */
111 #define RL2_SAMPLE_INT32		0xa8
112 /** RasterLite2 constant: Sample Type 32 bit Unsigned Integer */
113 #define RL2_SAMPLE_UINT32		0xa9
114 /** RasterLite2 constant: Sample Type Floating Point Single Precision */
115 #define RL2_SAMPLE_FLOAT		0xaa
116 /** RasterLite2 constant: Sample Type Floating Point Double Precision */
117 #define RL2_SAMPLE_DOUBLE		0xab
118 
119 /** RasterLite2 constant: Pixel Type UNKNOWN */
120 #define RL2_PIXEL_UNKNOWN		0x10
121 /** RasterLite2 constant: Pixel Type Monochrome - Bilevel */
122 #define RL2_PIXEL_MONOCHROME		0x11
123 /** RasterLite2 constant: Pixel Type Palette based */
124 #define RL2_PIXEL_PALETTE		0x12
125 /** RasterLite2 constant: Pixel Type Grayscale */
126 #define RL2_PIXEL_GRAYSCALE		0x13
127 /** RasterLite2 constant: Pixel Type Red-Green-Blue */
128 #define RL2_PIXEL_RGB			0x14
129 /** RasterLite2 constant: Pixel Type Multiband (arbitrary) */
130 #define RL2_PIXEL_MULTIBAND		0x15
131 /** RasterLite2 constant: Pixel Type Data-Grid */
132 #define RL2_PIXEL_DATAGRID		0x16
133 
134 /** RasterLite2 constant: Opaque Pixel */
135 #define RL2_PIXEL_OPAQUE		0x80
136 /** RasterLite2 constant: Transparent Pixel */
137 #define RL2_PIXEL_TRANSPARENT		0x40
138 
139 /** RasterLite2 constant: Compression UNKNOWN */
140 #define RL2_COMPRESSION_UNKNOWN		0x20
141 /** RasterLite2 constant: Compression None */
142 #define RL2_COMPRESSION_NONE		0x21
143 /** RasterLite2 constant: Compression Deflate (zip) */
144 #define RL2_COMPRESSION_DEFLATE		0x22
145 /** RasterLite2 constant: Compression LZMA */
146 #define RL2_COMPRESSION_LZMA		0x23
147 /** RasterLite2 constant: Compression GIF */
148 #define RL2_COMPRESSION_GIF		0x24
149 /** RasterLite2 constant: Compression PNG */
150 #define RL2_COMPRESSION_PNG		0x25
151 /** RasterLite2 constant: Compression JPEG */
152 #define RL2_COMPRESSION_JPEG		0x26
153 /** RasterLite2 constant: Compression WEBP (lossy mode) */
154 #define RL2_COMPRESSION_LOSSY_WEBP	0x27
155 /** RasterLite2 constant: Compression WEBP (lossless mode) */
156 #define RL2_COMPRESSION_LOSSLESS_WEBP	0x28
157 /** RasterLite2 constant: Compression CCITTFAX3 */
158 #define RL2_COMPRESSION_CCITTFAX3	0x29
159 /** RasterLite2 constant: Compression CCITTFAX4 */
160 #define RL2_COMPRESSION_CCITTFAX4	0x30
161 /** RasterLite2 constant: Compression LZW */
162 #define RL2_COMPRESSION_LZW		0x31
163 
164 /** RasterLite2 constant: UNKNOWN number of Bands */
165 #define RL2_BANDS_UNKNOWN		0x00
166 
167 /** RasterLite2 constant: Red Band */
168 #define RL2_RED_BAND			0
169 /** RasterLite2 constant: Green Band */
170 #define RL2_GREEN_BAND			1
171 /** RasterLite2 constant: Blue Band */
172 #define RL2_BLUE_BAND			2
173 /** RasterLite2 constant: Grayscale Band */
174 #define RL2_GRAYSCALE_BAND		0
175 /** RasterLite2 constant: Data-Grid Band */
176 #define RL2_DATAGRID_BAND		0
177 /** RasterLite2 constant: Monochrome Band */
178 #define RL2_MONOCHROME_BAND		0
179 /** RasterLite2 constant: Palette Band */
180 #define RL2_PALETTE_BAND		0
181 
182 /** RasterLite2 constant: No Georeferencing infos */
183 #define RL2_GEOREFERENCING_NONE		-1
184 
185 /** RasterLite2 constant: Undefined Tile size */
186 #define RL2_TILESIZE_UNDEFINED		0
187 
188 /** RasterLite2 constant: reproduction scale 1:1 */
189 #define RL2_SCALE_1			0x31
190 /** RasterLite2 constant: reproduction scale 1:2 */
191 #define RL2_SCALE_2			0x32
192 /** RasterLite2 constant: reproduction scale 1:4 */
193 #define RL2_SCALE_4			0x33
194 /** RasterLite2 constant: reproduction scale 1:8 */
195 #define RL2_SCALE_8			0x34
196 
197 /** RasterLite2 constant: output format UNKNOWN */
198 #define RL2_OUTPUT_FORMAT_UNKNOWN	0x70
199 /** RasterLite2 constant: output format JPEG */
200 #define RL2_OUTPUT_FORMAT_JPEG		0x71
201 /** RasterLite2 constant: output format PNG */
202 #define RL2_OUTPUT_FORMAT_PNG		0x72
203 /** RasterLite2 constant: output format TIFF */
204 #define RL2_OUTPUT_FORMAT_TIFF		0x73
205 /** RasterLite2 constant: output format PDF */
206 #define RL2_OUTPUT_FORMAT_PDF		0x74
207 
208 /** RasterLite2 constant: contrast enhancement NONE */
209 #define RL2_CONTRAST_ENHANCEMENT_NONE		0x90
210 /** RasterLite2 constant: contrast enhancement NORMALIZE */
211 #define RL2_CONTRAST_ENHANCEMENT_NORMALIZE	0x91
212 /** RasterLite2 constant: contrast enhancement HISTOGRAM */
213 #define RL2_CONTRAST_ENHANCEMENT_HISTOGRAM	0x92
214 /** RasterLite2 constant: contrast enhancement GAMMA-VALUE */
215 #define RL2_CONTRAST_ENHANCEMENT_GAMMA		0x93
216 
217 /** ResterLite2 constant: GroupRenderer - RasterLayer */
218 #define RL2_GROUP_RENDERER_RASTER_LAYER	0xba
219 /** ResterLite2 constant: GroupRenderer - VectorLayer */
220 #define RL2_GROUP_RENDERER_VECTOR_LAYER	0xbb
221 
222 /**
223  Typedef for RL2 Pixel object (opaque, hidden)
224 
225  \sa rl2PixelPtr
226  */
227     typedef struct rl2_pixel rl2Pixel;
228 /**
229  Typedef for RL2 Pixel object pointer (opaque, hidden)
230 
231  \sa rl2Pixel
232  */
233     typedef rl2Pixel *rl2PixelPtr;
234 
235 /**
236  Typedef for RL2 Palette object (opaque, hidden)
237 
238  \sa rl2PalettePtr
239  */
240     typedef struct rl2_palette rl2Palette;
241 /**
242  Typedef for RL2 Pixel object pointer (opaque, hidden)
243 
244  \sa rl2Palette
245  */
246     typedef rl2Palette *rl2PalettePtr;
247 
248 /**
249  Typedef for RL2 Raster object (opaque, hidden)
250 
251  \sa rl2RasterPtr
252  */
253     typedef struct rl2_raster rl2Raster;
254 /**
255  Typedef for RL2 Raster object pointer (opaque, hidden)
256 
257  \sa rl2Raster
258  */
259     typedef rl2Raster *rl2RasterPtr;
260 
261 /**
262  Typedef for RL2 Section object (opaque, hidden)
263 
264  \sa rl2SectionPtr
265  */
266     typedef struct rl2_section rl2Section;
267 /**
268  Typedef for RL2 Section object pointer (opaque, hidden)
269 
270  \sa rl2Section
271  */
272     typedef rl2Section *rl2SectionPtr;
273 
274 /**
275  Typedef for RL2 Coverage object (opaque, hidden)
276 
277  \sa rl2CoveragePtr
278  */
279     typedef struct rl2_coverage rl2Coverage;
280 /**
281  Typedef for RL2 Coverage object pointer (opaque, hidden)
282 
283  \sa rl2Coverage
284  */
285     typedef rl2Coverage *rl2CoveragePtr;
286 
287 /**
288  Typedef for RL2 RasterStyle object (opaque, hidden)
289 
290  \sa rl2RasterStylePtr
291  */
292     typedef struct rl2_raster_style rl2RasterStyle;
293 /**
294  Typedef for RL2 RasterStyle object pointer (opaque, hidden)
295 
296  \sa rl2RasterStyle
297  */
298     typedef rl2RasterStyle *rl2RasterStylePtr;
299 
300 /**
301  Typedef for RL2 GroupStyle object (opaque, hidden)
302 
303  \sa rl2GroupStylePtr
304  */
305     typedef struct rl2_group_style rl2GroupStyle;
306 /**
307  Typedef for RL2 GroupStyle object pointer (opaque, hidden)
308 
309  \sa rl2GroupStyle
310  */
311     typedef rl2GroupStyle *rl2GroupStylePtr;
312 
313 /**
314  Typedef for RL2 GroupRender object (opaque, hidden)
315 
316  \sa rl2GroupRendererPtr
317  */
318     typedef struct rl2_group_renderer rl2GroupRenderer;
319 /**
320  Typedef for RL2 GroupRenderer object pointer (opaque, hidden)
321 
322  \sa rl2GroupRenderer
323  */
324     typedef rl2GroupRenderer *rl2GroupRendererPtr;
325 
326 /**
327  Typedef for RL2 TIFF Origin object (opaque, hidden)
328 
329  \sa rl2TiffOriginPtr
330  */
331     typedef struct rl2_tiff_origin rl2TiffOrigin;
332 /**
333  Typedef for RL2 TIFF Origin object pointer (opaque, hidden)
334 
335  \sa rl2TiffOrigin
336  */
337     typedef rl2TiffOrigin *rl2TiffOriginPtr;
338 
339 /**
340  Typedef for RL2 TIFF Destination object (opaque, hidden)
341 
342  \sa rl2TiffDestinationPtr
343  */
344     typedef struct rl2_tiff_destination rl2TiffDestination;
345 
346 /**
347  Typedef for RL2 TIFF Destination object pointer (opaque, hidden)
348 
349  \sa rl2TiffDestination
350  */
351     typedef rl2TiffDestination *rl2TiffDestinationPtr;
352 
353 /**
354  Typedef for RL2 ASCII Grid Origin object (opaque, hidden)
355 
356  \sa rl2AsciiGridOriginPtr
357  */
358     typedef struct rl2_ascii_origin rl2AsciiGridOrigin;
359 /**
360  Typedef for RL2 ASCII Grid Origin object pointer (opaque, hidden)
361 
362  \sa rl2AsciiGridOrigin
363  */
364     typedef rl2AsciiGridOrigin *rl2AsciiGridOriginPtr;
365 
366 /**
367  Typedef for RL2 ASCII Grid Destination object (opaque, hidden)
368 
369  \sa rl2AsciiGridDestinationPtr
370  */
371     typedef struct rl2_ascii_destination rl2AsciiGridDestination;
372 /**
373  Typedef for RL2 ASCII Grid Destination object pointer (opaque, hidden)
374 
375  \sa rl2AsciiHridDestination
376  */
377     typedef rl2AsciiGridOrigin *rl2AsciiGridDestinationPtr;
378 
379 /**
380  Typedef for RL2 Raster Statistics object (opaque, hidden)
381 
382  \sa rl2RasterStatisticsPtr
383  */
384     typedef struct rl2_raster_statistics rl2RasterStatistics;
385 
386 /**
387  Typedef for RL2 Raster Statistics object pointer (opaque, hidden)
388 
389  \sa rl2RasterStatistics
390  */
391     typedef rl2RasterStatistics *rl2RasterStatisticsPtr;
392 
393 /**
394  Typedef for RL2 in-memory PDF target object
395 
396  \sa rl2MemPtrPtr
397  */
398     typedef struct rl2_mem_pdf_target rl2MemPdf;
399 
400 /**
401  Typedef for RL2 in-memory PDF target
402 
403  \sa rl2MemPtr
404  */
405     typedef rl2MemPdf *rl2MemPdfPtr;
406 
407 /**
408  Releases (frees) dynamic memory allocated by RasterLite2
409 
410  \param p pointer to the dynamic memory block to be released.
411  */
412     RL2_DECLARE void rl2_free (void *ptr);
413 
414 /**
415  Return the target CPU name.
416 
417  \return the target CPU string.
418  */
419     RL2_DECLARE const char *rl2_target_cpu (void);
420 
421 /**
422  Return the current library version.
423 
424  \return the version string.
425  */
426     RL2_DECLARE const char *rl2_version (void);
427 
428 #ifdef LOADABLE_EXTENSION
429     RL2_DECLARE int
430 	sqlite3_rasterlite_init (sqlite3 * db, char **pzErrMsg,
431 				 const sqlite3_api_routines * pApi);
432 #endif
433 
434 /**
435  Initializes the library
436 
437  \param db_handle handle to the current SQLite connection
438  \param verbose if TRUE a short start-up message is shown on stderr
439 
440  \note you are always expected to explicitly call this function
441  before attempting to call any RasterLite-2 own function.
442  */
443     RL2_DECLARE void rl2_init (sqlite3 * db_handle, int verbose);
444 
445 /**
446  Allocates and initializes a new Pixel object
447 
448  \param sample_type one of RL2_SAMPLE_1_BIT, RL2_SAMPLE_2_BIT, RL2_SAMPLE_4_BIT,
449         RL2_SAMPLE_INT8, RL2_SAMPLE_UINT8, RL2_SAMPLE_INT16, RL2_SAMPLE_UINT16,
450 		RL2_SAMPLE_INT32, RL2_SAMPLE_UINT32, RL2_SAMPLE_FLOAT or RL2_SAMPLE_DOUBLE.
451  \param pixel_type one of RL2_PIXEL_MONOCHROME, RL2_PIXEL_PALETTE, RL2_PIXEL_GRAYSCALE,
452 		RL2_PIXEL_RGB, RL2_PIXEL_MULTIBAND, RL2_PIXEL_DATAGRID.
453  \param num_samples number of samples per pixel (aka Bands)
454 
455  \return the pointer to newly created Coverage Object: NULL on failure.
456 
457  \sa rl2_destroy_pixel, rl2_compare_pixels, rl2_get_pixel_type,
458 		rl2_get_pixel_sample_1bit,
459 		rl2_set_pixel_sample_1bit, rl2_get_pixel_sample_2bit,
460 		rl2_set_pixel_sample_2bit, rl2_get_pixel_sample_4bit,
461 		rl2_set_pixel_sample_4bit, rl2_get_pixel_sample_int8,
462 		rl2_set_pixel_sample_uint8, rl2_get_pixel_sample_int16,
463 		rl2_set_pixel_sample_uint16, rl2_get_pixel_sample_int32,
464 		rl2_set_pixel_sample_uint32, rl2_get_pixel_sample_float,
465 		rl2_set_pixel_sample_float, rl2_get_pixel_sample_double,
466 		rl2_set_pixel_sample_double, rl2_is_pixel_transparent,
467 		rl2_is_pixel_opaque, rl2_set_pixel_transparent,
468 		rl2_set_pixel_opaque
469 
470  \note you are responsible to destroy (before or after) any allocated
471  Pixel object.
472  */
473     RL2_DECLARE rl2PixelPtr
474 	rl2_create_pixel (unsigned char sample_type, unsigned char pixel_type,
475 			  unsigned char num_samples);
476 
477     RL2_DECLARE rl2PixelPtr rl2_clone_pixel (rl2PixelPtr org);
478 
479     RL2_DECLARE rl2PixelPtr rl2_create_triple_band_pixel (rl2PixelPtr org,
480 							  unsigned char
481 							  red_band,
482 							  unsigned char
483 							  green_band,
484 							  unsigned char
485 							  blue_band);
486 
487     RL2_DECLARE rl2PixelPtr rl2_create_mono_band_pixel (rl2PixelPtr org,
488 							unsigned char
489 							mono_band);
490 
491 /**
492  Destroys a Pixel Object
493 
494  \param pxl pointer to object to be destroyed
495 
496  \sa rl2_create_pixel
497  */
498     RL2_DECLARE void rl2_destroy_pixel (rl2PixelPtr pxl);
499 
500 /**
501  Testing if two different Pixels are exactly the same
502 
503  \param pxl1 pointer to the first Pixel Object.
504  \param pxl2 pointer to the second Pixel Object.
505 
506  \return RL2_TRUE or RL2_FALSE; RL2_ERROR if any error is encountered.
507 
508  \sa rl2_create_pixel
509  */
510     RL2_DECLARE int rl2_compare_pixels (rl2PixelPtr pxl1, rl2PixelPtr pxl2);
511 
512 /**
513  Retrieving the Sample Type from a Pixel Object
514 
515  \param pxl pointer to the Pixel Object.
516  \param sample_type on completion the variable referenced by this
517  pointer will contain the Sampe Type.
518  \param pixel_type on completion the variable referenced by this
519  pointer will contain the Pixel Type.
520  \param num_bands on completion the variable referenced by this
521  pointer will contain the Number of Bands.
522 
523  \return  RL2_OK on success: RL2_ERROR on failure.
524 
525  \sa rl2_create_pixel
526  */
527     RL2_DECLARE int rl2_get_pixel_type (rl2PixelPtr pxl,
528 					unsigned char *sample_type,
529 					unsigned char *pixel_type,
530 					unsigned char *num_bands);
531 
532 /**
533  Retrieving the Pixel/Sample value from a Pixel Object [1 bit sample]
534 
535  \param pxl pointer to the Pixel Object.
536  \param sample on completion the variable referenced by this
537  pointer will contain the Pixel/Sampe Value.
538 
539  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
540  including querying a Pixel of mismatching PixelType).
541 
542  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_1bit
543  */
544     RL2_DECLARE int rl2_get_pixel_sample_1bit (rl2PixelPtr pxl,
545 					       unsigned char *sample);
546 
547 /**
548  Assigning the Pixel/Sample value to a Pixel Object [1 bit sample]
549 
550  \param pxl pointer to the Pixel Object.
551  \param sample the Pixel/Sampe Value to be set.
552 
553  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
554  including referencing a Pixel of mismatching PixelType).
555 
556  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_1bit
557  */
558     RL2_DECLARE int rl2_set_pixel_sample_1bit (rl2PixelPtr pxl,
559 					       unsigned char sample);
560 
561 /**
562  Retrieving the Pixel/Sample value from a Pixel Object [2 bit sample]
563 
564  \param pxl pointer to the Pixel Object.
565  \param sample on completion the variable referenced by this
566  pointer will contain the Pixel/Sampe Value.
567 
568  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
569  including querying a Pixel of mismatching PixelType).
570 
571  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_2bit
572  */
573     RL2_DECLARE int rl2_get_pixel_sample_2bit (rl2PixelPtr pxl,
574 					       unsigned char *sample);
575 
576 /**
577  Assigning the Pixel/Sample value to a Pixel Object [2 bit sample]
578 
579  \param pxl pointer to the Pixel Object.
580  \param sample the Pixel/Sampe Value to be set.
581 
582  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
583  including referencing a Pixel of mismatching PixelType).
584 
585  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_2bit
586  */
587     RL2_DECLARE int rl2_set_pixel_sample_2bit (rl2PixelPtr pxl,
588 					       unsigned char sample);
589 
590 /**
591  Retrieving the Pixel/Sample value from a Pixel Object [4 bit sample]
592 
593  \param pxl pointer to the Pixel Object.
594  \param sample on completion the variable referenced by this
595  pointer will contain the Pixel/Sampe Value.
596 
597  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
598  including querying a Pixel of mismatching PixelType).
599 
600  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_4bit
601  */
602     RL2_DECLARE int rl2_get_pixel_sample_4bit (rl2PixelPtr pxl,
603 					       unsigned char *sample);
604 
605 /**
606  Assigning the Pixel/Sample value to a Pixel Object [4 bit sample]
607 
608  \param pxl pointer to the Pixel Object.
609  \param sample the Pixel/Sampe Value to be set.
610 
611  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
612  including referencing a Pixel of mismatching PixelType).
613 
614  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_4bit
615  */
616     RL2_DECLARE int rl2_set_pixel_sample_4bit (rl2PixelPtr pxl,
617 					       unsigned char sample);
618 
619 /**
620  Retrieving the Pixel/Sample value from a Pixel Object [integer, 8 bit sample]
621 
622  \param pxl pointer to the Pixel Object.
623  \param sample on completion the variable referenced by this
624  pointer will contain the Pixel/Sampe Value.
625 
626  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
627  including querying a Pixel of mismatching PixelType).
628 
629  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_int8
630  */
631     RL2_DECLARE int rl2_get_pixel_sample_int8 (rl2PixelPtr pxl, char *sample);
632 
633 /**
634  Assigning the Pixel/Sample value to a Pixel Object [integer, 8 bit sample]
635 
636  \param pxl pointer to the Pixel Object.
637  \param sample the Pixel/Sampe Value to be set.
638 
639  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
640  including referencing a Pixel of mismatching PixelType).
641 
642  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_int8
643  */
644     RL2_DECLARE int rl2_set_pixel_sample_int8 (rl2PixelPtr pxl, char sample);
645 
646 /**
647  Retrieving the Pixel/Sample value from a Pixel Object [unsigned integer, 8 bit sample]
648 
649  \param pxl pointer to the Pixel Object.
650  \param band the Sample/Band index (the first sample corresponds to index ZERO).
651  \param sample on completion the variable referenced by this
652  pointer will contain the Pixel/Sampe Value.
653 
654  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
655  including querying a Pixel of mismatching PixelType).
656 
657  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_uint8
658  */
659     RL2_DECLARE int rl2_get_pixel_sample_uint8 (rl2PixelPtr pxl, int band,
660 						unsigned char *sample);
661 
662 /**
663  Assigning the Pixel/Sample value to a Pixel Object [unsigned integer, 8 bit sample]
664 
665  \param pxl pointer to the Pixel Object.
666  \param band the Sample/Band index (the first sample corresponds to index ZERO).
667  \param sample the Pixel/Sampe Value to be set.
668 
669  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
670  including referencing a Pixel of mismatching PixelType).
671 
672  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_uint8
673  */
674     RL2_DECLARE int rl2_set_pixel_sample_uint8 (rl2PixelPtr pxl, int band,
675 						unsigned char sample);
676 
677 /**
678  Retrieving the Pixel/Sample value from a Pixel Object [integer, 16 bit sample]
679 
680  \param pxl pointer to the Pixel Object.
681  \param sample on completion the variable referenced by this
682  pointer will contain the Pixel/Sampe Value.
683 
684  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
685  including querying a Pixel of mismatching PixelType).
686 
687  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_int16
688  */
689     RL2_DECLARE int rl2_get_pixel_sample_int16 (rl2PixelPtr pxl, short *sample);
690 
691 /**
692  Assigning the Pixel/Sample value to a Pixel Object [integer, 16 bit sample]
693 
694  \param pxl pointer to the Pixel Object.
695  \param sample the Pixel/Sampe Value to be set.
696 
697  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
698  including referencing a Pixel of mismatching PixelType).
699 
700  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_int16
701  */
702     RL2_DECLARE int rl2_set_pixel_sample_int16 (rl2PixelPtr pxl, short sample);
703 
704 /**
705  Retrieving the Pixel/Sample value from a Pixel Object [unsigned integer, 16 bit sample]
706 
707  \param pxl pointer to the Pixel Object.
708  \param band the Sample/Band index (the first sample corresponds to index ZERO).
709  \param sample on completion the variable referenced by this
710  pointer will contain the Pixel/Sampe Value.
711 
712  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
713  including querying a Pixel of mismatching PixelType).
714 
715  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_uint16
716  */
717     RL2_DECLARE int rl2_get_pixel_sample_uint16 (rl2PixelPtr pxl, int band,
718 						 unsigned short *sample);
719 
720 /**
721  Assigning the Pixel/Sample value to a Pixel Object [unsigned integer, 16 bit sample]
722 
723  \param pxl pointer to the Pixel Object.
724  \param band the Sample/Band index (the first sample corresponds to index ZERO).
725  \param sample the Pixel/Sampe Value to be set.
726 
727  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
728  including referencing a Pixel of mismatching PixelType).
729 
730  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_uint16
731  */
732     RL2_DECLARE int rl2_set_pixel_sample_uint16 (rl2PixelPtr pxl, int band,
733 						 unsigned short sample);
734 
735 /**
736  Retrieving the Pixel/Sample value from a Pixel Object [integer, 32 bit sample]
737 
738  \param pxl pointer to the Pixel Object.
739  \param sample on completion the variable referenced by this
740  pointer will contain the Pixel/Sampe Value.
741 
742  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
743  including querying a Pixel of mismatching PixelType).
744 
745  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_int32
746  */
747     RL2_DECLARE int rl2_get_pixel_sample_int32 (rl2PixelPtr pxl, int *sample);
748 
749 /**
750  Assigning the Pixel/Sample value to a Pixel Object [integer, 32 bit sample]
751 
752  \param pxl pointer to the Pixel Object.
753  \param sample the Pixel/Sampe Value to be set.
754 
755  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
756  including referencing a Pixel of mismatching PixelType).
757 
758  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_int32
759  */
760     RL2_DECLARE int rl2_set_pixel_sample_int32 (rl2PixelPtr pxl, int sample);
761 
762 /**
763  Retrieving the Pixel/Sample value from a Pixel Object [unsigned integer, 32 bit sample]
764 
765  \param pxl pointer to the Pixel Object.
766  \param sample on completion the variable referenced by this
767  pointer will contain the Pixel/Sampe Value.
768 
769  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
770  including querying a Pixel of mismatching PixelType).
771 
772  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_uint32
773  */
774     RL2_DECLARE int rl2_get_pixel_sample_uint32 (rl2PixelPtr pxl,
775 						 unsigned int *sample);
776 
777 /**
778  Assigning the Pixel/Sample value to a Pixel Object [unsigned integer, 32 bit sample]
779 
780  \param pxl pointer to the Pixel Object.
781  \param sample the Pixel/Sampe Value to be set.
782 
783  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
784  including referencing a Pixel of mismatching PixelType).
785 
786  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_uint32
787  */
788     RL2_DECLARE int rl2_set_pixel_sample_uint32 (rl2PixelPtr pxl,
789 						 unsigned int sample);
790 
791 /**
792  Retrieving the Pixel/Sample value from a Pixel Object [floating point, single precision sample]
793 
794  \param pxl pointer to the Pixel Object.
795  \param sample on completion the variable referenced by this
796  pointer will contain the Pixel/Sampe Value.
797 
798  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
799  including querying a Pixel of mismatching PixelType).
800 
801  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_float
802  */
803     RL2_DECLARE int rl2_get_pixel_sample_float (rl2PixelPtr pxl, float *sample);
804 
805 /**
806  Assigning the Pixel/Sample value to a Pixel Object [floating point, single precision sample]
807 
808  \param pxl pointer to the Pixel Object.
809  \param sample the Pixel/Sampe Value to be set.
810 
811  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
812  including referencing a Pixel of mismatching PixelType).
813 
814  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_float
815  */
816     RL2_DECLARE int rl2_set_pixel_sample_float (rl2PixelPtr pxl, float sample);
817 
818 /**
819  Retrieving the Pixel/Sample value from a Pixel Object [floating point, double precision sample]
820 
821  \param pxl pointer to the Pixel Object.
822  \param sample on completion the variable referenced by this
823  pointer will contain the Pixel/Sampe Value.
824 
825  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
826  including querying a Pixel of mismatching PixelType).
827 
828  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_set_pixel_sample_double
829  */
830     RL2_DECLARE int rl2_get_pixel_sample_double (rl2PixelPtr pxl,
831 						 double *sample);
832 
833 /**
834  Assigning the Pixel/Sample value to a Pixel Object [floating point, double precision sample]
835 
836  \param pxl pointer to the Pixel Object.
837  \param sample the Pixel/Sampe Value to be set.
838 
839  \return RL2_OK on success; RL2_ERROR if any error is encountered (this
840  including referencing a Pixel of mismatching PixelType).
841 
842  \sa rl2_create_pixel, rl2_get_pixel_type, rl2_get_pixel_sample_double
843  */
844     RL2_DECLARE int rl2_set_pixel_sample_double (rl2PixelPtr pxl,
845 						 double sample);
846 
847 /**
848  Testing if a Pixel Object is Transparent
849 
850  \param pxl pointer to the Pixel Object.
851  \param is_transparent on completion the variable referenced by this
852  pointer will contain RL2_TRUE or RL2_FALSE.
853 
854  \return RL2_OK on success: RL2_ERROR on failure.
855 
856  \sa rl2_create_pixel, rl2_is_pixel_opaque, rl2_set_pixel_transparent,
857  rl2_set_pixel_opaque
858  */
859     RL2_DECLARE int rl2_is_pixel_transparent (rl2PixelPtr pxl,
860 					      int *is_transparent);
861 
862 /**
863  Testing if a Pixel Object is Opaque
864 
865  \param pxl pointer to the Pixel Object.
866  \param is_opaque on completion the variable referenced by this
867  pointer will contain RL2_TRUE or RL2_FALSE.
868 
869  \return RL2_OK on success: RL2_ERROR on failure.
870 
871  \sa rl2_create_pixel, rl2_is_pixel_transparent, rl2_set_pixel_transparent,
872  rl2_set_pixel_opaque
873  */
874     RL2_DECLARE int rl2_is_pixel_opaque (rl2PixelPtr pxl, int *is_opaque);
875 
876 /**
877  Forcing a Pixel Object to be Transparent
878 
879  \param pxl pointer to the Pixel Object.
880 
881  \return RL2_OK on success: RL2_ERROR on failure.
882 
883  \sa rl2_create_pixel, rl2_is_pixel_opaque, rl2_is_pixel_transparent,
884  rl2_set_pixel_opaque
885  */
886     RL2_DECLARE int rl2_set_pixel_transparent (rl2PixelPtr pxl);
887 
888 /**
889  Forcing a Pixel Object to be Opaque
890 
891  \param pxl pointer to the Pixel Object.
892 
893  \return RL2_OK on success: RL2_ERROR on failure.
894 
895  \sa rl2_create_pixel, rl2_is_pixel_opaque, rl2_is_pixel_transparent,
896  rl2_set_pixel_transparent
897  */
898     RL2_DECLARE int rl2_set_pixel_opaque (rl2PixelPtr pxl);
899 
900 /**
901  Allocates and initializes a new Palette object
902 
903  \param num_entries total number of color entries for this Palette:
904  any valid palette should contain at least one entry and no more than 256 entries.
905 
906  \return the pointer to newly created Palette Object: NULL on failure.
907 
908  \sa rl2_destroy_palette, rl2_set_palette_color, rl2_get_palette_index,
909 	rl2_set_palette_hexrgb, rl2_get_palette_entries, rl2_get_palette_colors,
910 	rl2_get_palette_type
911 
912  \note you are responsible to destroy (before or after) any allocated
913  Palette object.
914  */
915     RL2_DECLARE rl2PalettePtr rl2_create_palette (int num_entries);
916 
917 /**
918  Destroys a Palette Object
919 
920  \param plt pointer to object to be destroyed
921 
922  \sa rl2_create_palette
923  */
924     RL2_DECLARE void rl2_destroy_palette (rl2PalettePtr plt);
925 
926 /**
927  Assigns a Palette Color
928 
929  \param plt pointer to the Palette Object
930  \param index references a Palette Entry [first Entry has index ZERO]
931  \param r Red component
932  \param g Green component
933  \param b Blue component
934 
935  \return RL2_OK on success: RL2_ERROR on failure (invald Palette or invalid Index).
936 
937  \sa rl2_create_palette, rl2_set_palette_hexrgb, rl2_get_palette_index,
938 	rl2_get_palette_colors, rl2_get_palette_entries
939  */
940     RL2_DECLARE int
941 	rl2_set_palette_color (rl2PalettePtr plt, int index,
942 			       unsigned char r, unsigned char g,
943 			       unsigned char b);
944 
945 /**
946  Assigns a Palette Color (Hex RGB)
947 
948  \param plt pointer to the Palette Object
949  \param index references a Palette Entry [first Entry has index ZERO]
950  \param rgb an Hex RGB Color: "#ff0000" corresponds to Red, "#0000ff"
951  corresponds to Blue and so on.
952 
953  \return RL2_OK on success: RL2_ERROR on failure (invald Palette or invalid Index).
954 
955  \sa rl2_create_palette, rl2_set_palette_color, rl2_get_palette_index,
956 	rl2_get_palette_colors, rl2_get_palette_entries
957  */
958     RL2_DECLARE int
959 	rl2_set_palette_hexrgb (rl2PalettePtr plt, int index, const char *rgb);
960 
961 /**
962  Return the Palette Index corresponding to a given Color
963 
964  \param plt pointer to the Palette Object
965  \param index on completion the variable referenced by this
966  pointer will contain the Index corresponding to the matching Entry.
967  \param r Red component
968  \param g Green component
969  \param b Blue component
970 
971  \return RL2_OK on success: RL2_ERROR on failure (invald Palette or no matching Entry).
972 
973  \sa rl2_create_palette
974  */
975     RL2_DECLARE int
976 	rl2_get_palette_index (rl2PalettePtr plt, unsigned char *index,
977 			       unsigned char r, unsigned char g,
978 			       unsigned char b);
979 
980 /**
981  Retrieving the total number of Palette Entries
982 
983  \param plt pointer to the Palette Object.
984  \param num_entries on completion the variable referenced by this
985  pointer will contain the total count of Colors.
986 
987  \return RL2_OK on success: RL2_ERROR on failure.
988 
989  \sa rl2_create_palette, rl2_get_palette_colors, rl2_set_palette_color,
990 	rl2_set_palette_hexrgb
991  */
992     RL2_DECLARE int rl2_get_palette_entries (rl2PalettePtr plt,
993 					     unsigned short *num_entries);
994 
995 /**
996  Exports all Palette Colors as separate arrays for each component
997 
998  \param plt pointer to the Palette Object
999  \param num_entries on completion the variable referenced by this
1000  pointer will contain the total count of Colors (i.e. the size of each
1001  one of the following arrays).
1002  \param r on completion will point to an array of Red components
1003  \param g on completion will point to an array of Green components
1004  \param b on completion will point to an array of Blue components
1005 
1006  \return RL2_OK on success: RL2_ERROR on failure.
1007 
1008  \sa rl2_create_palette
1009 
1010  \note you are responsible to destroy (before or after) any array
1011  created by rl2_get_palette_colors() by invoking rl2_free().
1012  */
1013     RL2_DECLARE int
1014 	rl2_get_palette_colors (rl2PalettePtr plt, unsigned short *num_entries,
1015 				unsigned char **r, unsigned char **g,
1016 				unsigned char **b);
1017 
1018 /**
1019  Return the best fit Sample Type and Pixel Type for a given Palette Object
1020 
1021  \param plt pointer to the Palette Object
1022  \param sample_type on completion the variable referenced by this
1023  pointer will contain the Sample Type corresponding to the Palette Object
1024  (one of RL2_SAMPLE_1_BIT, RL2_SAMPLE_2_BIT, RL2_SAMPLE_4_BIT or RL2_SAMPLE_UINT8)
1025  \param pixel_type on completion the variable referenced by this
1026  pointer will contain the Pixel Type corresponding to the Palette Object
1027  (one of RL2_PIXEL_PALETTE, RL2_PIXEL_MONOCHROME or RL2_PIXEL_GRAYSCALE)
1028 
1029  \return RL2_OK on success: RL2_ERROR on failure.
1030 
1031  \sa rl2_create_palette
1032  */
1033     RL2_DECLARE int
1034 	rl2_get_palette_type (rl2PalettePtr plt, unsigned char *sample_type,
1035 			      unsigned char *pixel_type);
1036 
1037 /**
1038  Allocates and initializes a new Coverage object
1039 
1040  \param name a text string intended to be the symbolic Coverage name.
1041  \param sample_type one of RL2_SAMPLE_1_BIT, RL2_SAMPLE_2_BIT, RL2_SAMPLE_4_BIT,
1042         RL2_SAMPLE_INT8, RL2_SAMPLE_UINT8, RL2_SAMPLE_INT16, RL2_SAMPLE_UINT16,
1043 		RL2_SAMPLE_INT32, RL2_SAMPLE_UINT32, RL2_SAMPLE_FLOAT or RL2_SAMPLE_DOUBLE.
1044  \param pixel_type one of RL2_PIXEL_MONOCHROME, RL2_PIXEL_PALETTE, RL2_PIXEL_GRAYSCALE,
1045 		RL2_PIXEL_RGB, RL2_PIXEL_MULTIBAND, RL2_PIXEL_DATAGRID.
1046  \param num_samples number of samples per pixel (aka Bands)
1047  \param compression one of RL2_COMPRESSION_NONE, RL2_COMPRESSION_DEFLATE,
1048 		RL2_COMPRESSION_LZMA, RL2_COMPRESSION_GIF, RL2_COMPRESSION_PNG,
1049 		RL2_COMPRESSION_JPEG, RL2_COMPRESSION_LOSSY_WEBP or
1050  		RL2_COMPRESSION_LOSSLESS_WEBP
1051  \param quality compression quality factor (0-100); only meaningfull for
1052 		JPEG or WEBP lossy compressions, ignored in any other case.
1053  \param tile_width the individual tile width in pixels.
1054  \param tile_height the individual tile height in pixels.
1055  \param no_data pointer to a Pixel Object indented as NO-DATA value;
1056 		could be eventually NULL if not required.
1057 
1058  \return the pointer to newly created Coverage Object: NULL on failure.
1059 
1060  \sa rl2_destroy_coverage, rl2_coverage_georeference, rl2_get_coverage_name,
1061 		rl2_get_coverage_type, rl2_get_coverage_compression,
1062 		rl2_is_coverage_uncompressed, rl2_is_coverage_compression_lossless,
1063 		rl2_is_coverage_compression_lossy, rl2_get_coverage_tile_size,
1064 		rl2_get_coverage_no_data, rl2_create_coverage_pixel,
1065 		rl2_get_coverage_srid, rl2_get_coverage_resolution
1066 
1067  \note you are responsible to destroy (before or after) any allocated
1068  Coverage object.
1069  */
1070     RL2_DECLARE rl2CoveragePtr
1071 	rl2_create_coverage (const char *name, unsigned char sample_type,
1072 			     unsigned char pixel_type,
1073 			     unsigned char num_samples,
1074 			     unsigned char compression, int quality,
1075 			     unsigned int tile_width,
1076 			     unsigned int tile_height, rl2PixelPtr no_data);
1077 
1078 /**
1079  Destroys a Coverage Object
1080 
1081  \param cvg pointer to object to be destroyed
1082 
1083  \sa rl2_create_coverage
1084  */
1085     RL2_DECLARE void rl2_destroy_coverage (rl2CoveragePtr cvg);
1086 
1087 /**
1088  Assigns GeoReferencing parameters to a Coverage Object
1089 
1090  \param cvg pointer to the Coverage Object.
1091  \param srid a valid SRID identifier
1092  \param horz_res horizontal pixel resolution: the size (measured
1093 		in map units) corresponding to a single Pixel at full
1094 		resolution.
1095  \param vert_res vertical pixel resolution.
1096 
1097  \return RL2_OK on success: RL2_ERROR on failure.
1098 
1099  \sa rl2_create_coverage
1100  */
1101     RL2_DECLARE int
1102 	rl2_coverage_georeference (rl2CoveragePtr cvg, int srid,
1103 				   double horz_res, double vert_res);
1104 
1105 /**
1106  Retrieving the Name from a Coverage Object
1107 
1108  \param cvg pointer to the Coverage Object.
1109 
1110  \return pointer to the Name text string; NULL if any error is encountered.
1111 
1112  \sa rl2_create_coverage
1113  */
1114     RL2_DECLARE const char *rl2_get_coverage_name (rl2CoveragePtr cvg);
1115 
1116 /**
1117  Retrieving the Sample Type from a Coverage Object
1118 
1119  \param cvg pointer to the Coverage Object.
1120  \param sample_type on completion the variable referenced by this
1121  pointer will contain the Sampe Type.
1122  \param pixel_type on completion the variable referenced by this
1123  pointer will contain the Pixel Type.
1124  \param num_bands on completion the variable referenced by this
1125  pointer will contain the Number of Bands.
1126 
1127  \return  RL2_OK on success: RL2_ERROR on failure.
1128 
1129  \sa rl2_create_coverage
1130  */
1131     RL2_DECLARE int rl2_get_coverage_type (rl2CoveragePtr cvg,
1132 					   unsigned char *sample_type,
1133 					   unsigned char *pixel_type,
1134 					   unsigned char *num_bands);
1135 
1136 /**
1137  Retrieving the Compression Type from a Coverage Object
1138 
1139  \param cvg pointer to the Coverage Object.
1140  \param compression on completion the variable referenced by this
1141  pointer will contain the Compression Type.
1142  \param quality on completion the variable referenced by this
1143  pointer will contain the Compression Quality.
1144 
1145  \return  RL2_OK on success: RL2_ERROR on failure.
1146 
1147  \sa rl2_create_coverage
1148  */
1149     RL2_DECLARE int rl2_get_coverage_compression (rl2CoveragePtr cvg,
1150 						  unsigned char *compression,
1151 						  int *quality);
1152 
1153 /**
1154  Testing if a Coverage Object is uncompressed or compressed
1155 
1156  \param cvg pointer to the Coverage Object.
1157  \param is_uncompressed on completion the variable referenced by this
1158  pointer will contain RL2_TRUE or RL2_FALSE.
1159 
1160  \return RL2_OK on success: RL2_ERROR on failure.
1161 
1162  \sa rl2_create_coverage
1163  */
1164     RL2_DECLARE int rl2_is_coverage_uncompressed (rl2CoveragePtr cvg,
1165 						  int *is_uncompressed);
1166 
1167 /**
1168  Testing if a Coverage Object adopts a lossless compression
1169 
1170  \param cvg pointer to the Coverage Object.
1171  \param is_lossless on completion the variable referenced by this
1172  pointer will contain RL2_TRUE or RL2_FALSE.
1173 
1174  \return RL2_OK on success: RL2_ERROR on failure.
1175 
1176  \sa rl2_create_coverage
1177  */
1178     RL2_DECLARE int rl2_is_coverage_compression_lossless (rl2CoveragePtr cvg,
1179 							  int *is_lossless);
1180 
1181 /**
1182  Testing if a Coverage Object adopts a lossy compression
1183 
1184  \param cvg pointer to the Coverage Object.
1185  \param is_lossy on completion the variable referenced by this
1186  pointer will contain RL2_TRUE or RL2_FALSE.
1187 
1188  \return RL2_OK on success: RL2_ERROR on failure.
1189 
1190  \sa rl2_create_coverage
1191  */
1192     RL2_DECLARE int rl2_is_coverage_compression_lossy (rl2CoveragePtr cvg,
1193 						       int *is_lossy);
1194 
1195 /**
1196  Retrieving the Tile Size from a Coverage Object
1197 
1198  \param cvg pointer to the Coverage Object.
1199  \param tile_width on completion the variable referenced by this
1200  pointer will contain the coverage's Tile Width.
1201  \param tile_height on completion the variable referenced by this
1202  pointer will contain the coverage's Tile Height.
1203 
1204  \return RL2_OK on success: RL2_ERROR on failure.
1205 
1206  \sa rl2_create_coverage
1207  */
1208     RL2_DECLARE int rl2_get_coverage_tile_size (rl2CoveragePtr cvg,
1209 						unsigned int *tile_width,
1210 						unsigned int *tile_height);
1211 
1212 /**
1213  Retrieving the NO-DATA Pixel value from a Coverage Object
1214 
1215  \param cvg pointer to the Coverage Object.
1216 
1217  \return pointer to the Pixel Object representing NO-DATA value;
1218   NULL if any error is encountered or if the Coverage has no NO-DATA value.
1219 
1220  \sa rl2_create_coverage
1221  */
1222     RL2_DECLARE rl2PixelPtr rl2_get_coverage_no_data (rl2CoveragePtr cvg);
1223 
1224 /**
1225  Creates a new Pixel Object suitable for a given Coverage Object
1226 
1227  \param cvg pointer to the Coverage Object.
1228 
1229  \return pointer to the newly created Pixel Object; NULL if any error is encountered.
1230 
1231  \sa rl2_create_coverage, rl2_create_pixel, rl2_destroy_pixel
1232 
1233  \note you are responsible to destroy (before or after) the allocated
1234  Pixel object.
1235  */
1236     RL2_DECLARE rl2PixelPtr rl2_create_coverage_pixel (rl2CoveragePtr rst);
1237 
1238 /**
1239  Retrieving the SRID from a Coverage Object
1240 
1241  \param cvg pointer to the Coverage Object.
1242  \param srid on completion the variable referenced by this
1243  pointer will contain the coverage's SRID.
1244 
1245  \return RL2_OK on success: RL2_ERROR on failure.
1246 
1247  \sa rl2_create_coverage, rl2_get_coverage_resolution
1248  */
1249     RL2_DECLARE int rl2_get_coverage_srid (rl2CoveragePtr cvg, int *srid);
1250 
1251 /**
1252  Retrieving the base resolution from a Coverage Object
1253 
1254  \param cvg pointer to the Coverage Object.
1255  \param hResolution on completion the variable referenced by this
1256  pointer will contain the coverage's horizontal resolution.
1257  \param vResolution on completion the variable referenced by this
1258  pointer will contain the coverage's vertical resolution.
1259 
1260  \return RL2_OK on success: RL2_ERROR on failure.
1261 
1262  \sa rl2_create_coverage, rl2_get_coverage_srid
1263  */
1264     RL2_DECLARE int rl2_get_coverage_resolution (rl2CoveragePtr cvg,
1265 						 double *hResolution,
1266 						 double *vResolution);
1267 
1268 /**
1269  Allocates and initializes a new Section object
1270 
1271  \param name a text string intended to be the symbolic Section name.
1272  \param compression one of RL2_COMPRESSION_NONE, RL2_COMPRESSION_DEFLATE,
1273 		RL2_COMPRESSION_LZMA, RL2_COMPRESSION_GIF, RL2_COMPRESSION_PNG,
1274 		RL2_COMPRESSION_JPEG, RL2_COMPRESSION_LOSSY_WEBP or
1275  		RL2_COMPRESSION_LOSSLESS_WEBP
1276  \param tile_width the individual tile width in pixels.
1277  \param tile_height the individual tile height in pixels.
1278  \param rst pointer to a Raster Object.
1279 
1280  \return the pointer to newly created Section Object: NULL on failure.
1281 
1282  \sa rl2_destroy_section, rl2_get_section_name, rl2_get_section_compression,
1283 		rl2_is_section_uncompressed, rl2_is_section_compression_lossless,
1284 		rl2_is_section_compression_lossy, rl2_get_section_tile_width,
1285 		rl2_get_section_tile_height, rl2_get_section_raster,
1286 		rl2_section_from_gif, rl2_section_from_png, rl2_section_from_jpeg,
1287 		rl2_section_from_webp, rl2_section_to_gif, rl2_section_to_png,
1288 		rl2_section_to_jpeg, rl2_section_to_lossy_webp,
1289 		rl2_section_to_lossless_webp
1290 
1291  \note you are responsible to destroy (before or after) any allocated
1292  Section object.
1293  */
1294     RL2_DECLARE rl2SectionPtr
1295 	rl2_create_section (const char *name, unsigned char compression,
1296 			    unsigned int tile_width,
1297 			    unsigned int tile_height, rl2RasterPtr rst);
1298 
1299 /**
1300  Allocates and initializes a new Section object from an external GIF image
1301 
1302  \param path pathname leading to the external GIF image.
1303 
1304  \return the pointer to newly created Section Object: NULL on failure.
1305 
1306  \sa rl2_destroy_section, rl2_create_section, rl2_section_to_gif
1307 
1308  \note you are responsible to destroy (before or after) any allocated
1309  Section object.
1310  */
1311     RL2_DECLARE rl2SectionPtr rl2_section_from_gif (const char *path);
1312 
1313 /**
1314  Allocates and initializes a new Section object from an external PMG image
1315 
1316  \param path pathname leading to the external PNG image.
1317 
1318  \return the pointer to newly created Section Object: NULL on failure.
1319 
1320  \sa rl2_destroy_section, rl2_create_section, rl2_section_to_png
1321 
1322  \note you are responsible to destroy (before or after) any allocated
1323  Section object.
1324  */
1325     RL2_DECLARE rl2SectionPtr rl2_section_from_png (const char *path);
1326 
1327 /**
1328  Allocates and initializes a new Section object from an external JPEG image
1329 
1330  \param path pathname leading to the external JPEG image.
1331 
1332  \return the pointer to newly created Section Object: NULL on failure.
1333 
1334  \sa rl2_destroy_section, rl2_create_section, rl2_section_to_jpeg
1335 
1336  \note you are responsible to destroy (before or after) any allocated
1337  Section object.
1338  */
1339     RL2_DECLARE rl2SectionPtr rl2_section_from_jpeg (const char *path);
1340 
1341 /**
1342  Allocates and initializes a new Section object from an external WEBP image
1343 
1344  \param path pathname leading to the external WEBP image.
1345 
1346  \return the pointer to newly created Section Object: NULL on failure.
1347 
1348  \sa rl2_destroy_section, rl2_create_section, rl2_section_to_lossy_webp,
1349 	rl2_section_to_lossless_webp
1350 
1351  \note you are responsible to destroy (before or after) any allocated
1352  Section object.
1353  */
1354     RL2_DECLARE rl2SectionPtr rl2_section_from_webp (const char *path);
1355 
1356 /**
1357  Exports a Section object as an external GIF image
1358 
1359  \param scn pointer to the Section Object.
1360  \param path pathname leading to the external GIF image.
1361 
1362  \return RL2_OK on success: RL2_ERROR on failure.
1363 
1364  \sa rl2_create_section, rl2_section_from_gif
1365  */
1366     RL2_DECLARE int rl2_section_to_gif (rl2SectionPtr scn, const char *path);
1367 
1368 /**
1369  Exports a Section object as an external PNG image
1370 
1371  \param scn pointer to the Section Object.
1372  \param path pathname leading to the external PNG image.
1373 
1374  \return RL2_OK on success: RL2_ERROR on failure.
1375 
1376  \sa rl2_create_section, rl2_section_from_png
1377  */
1378     RL2_DECLARE int rl2_section_to_png (rl2SectionPtr scn, const char *path);
1379 
1380 /**
1381  Exports a Section object as an external JPEG image
1382 
1383  \param scn pointer to the Section Object.
1384  \param path pathname leading to the external JPEG image.
1385  \param quality compression quality factor (0-100).
1386 
1387  \return RL2_OK on success: RL2_ERROR on failure.
1388 
1389  \sa rl2_create_section, rl2_section_from_jpeg
1390  */
1391     RL2_DECLARE int
1392 	rl2_section_to_jpeg (rl2SectionPtr scn, const char *path, int quality);
1393 
1394 /**
1395  Exports a Section object as an external WEBP (lossy) image
1396 
1397  \param scn pointer to the Section Object.
1398  \param path pathname leading to the external JPEG image.
1399  \param quality compression quality factor (0-100).
1400 
1401  \return RL2_OK on success: RL2_ERROR on failure.
1402 
1403  \sa rl2_create_section, rl2_section_from_jpeg
1404  */
1405     RL2_DECLARE int rl2_section_to_lossy_webp (rl2SectionPtr scn,
1406 					       const char *path, int quality);
1407 
1408 /**
1409  Exports a Section object as an external WEBP (lossless) image
1410 
1411  \param scn pointer to the Section Object.
1412  \param path pathname leading to the external WEBP image.
1413 
1414  \return RL2_OK on success: RL2_ERROR on failure.
1415 
1416  \sa rl2_create_section, rl2_section_from_webp
1417  */
1418     RL2_DECLARE int rl2_section_to_lossless_webp (rl2SectionPtr scn,
1419 						  const char *path);
1420 
1421 /**
1422  Destroys a Section Object
1423 
1424  \param scn pointer to object to be destroyed
1425 
1426  \sa rl2_create_section
1427  */
1428     RL2_DECLARE void rl2_destroy_section (rl2SectionPtr scn);
1429 
1430 /**
1431  Retrieving the Name from a Section Object
1432 
1433  \param scn pointer to the Section Object.
1434 
1435  \return pointer to the Name text string; NULL if any error is encountered.
1436 
1437  \sa rl2_create_section
1438  */
1439     RL2_DECLARE const char *rl2_get_section_name (rl2SectionPtr scn);
1440 
1441 /**
1442  Retrieving the Compression Type from a Section Object
1443 
1444  \param scn pointer to the Section Object.
1445  \param compression on completion the variable referenced by this
1446  pointer will contain the section's Compression Type.
1447  \param rst pointer to the Raster Object.
1448 
1449  \return  RL2_OK on success: RL2_ERROR on failure.
1450 
1451  \sa rl2_create_section
1452  */
1453     RL2_DECLARE int rl2_get_section_compression (rl2SectionPtr scn,
1454 						 unsigned char *compression);
1455 
1456 /**
1457  Testing if a Section Object is uncompressed or compressed
1458 
1459  \param scn pointer to the Section Object.
1460  \param is_uncompressed on completion the variable referenced by this
1461  pointer will contain RL2_TRUE or RL2_FALSE.
1462 
1463  \return RL2_OK on success: RL2_ERROR on failure.
1464 
1465  \sa rl2_create_section
1466  */
1467     RL2_DECLARE int rl2_is_section_uncompressed (rl2SectionPtr scn,
1468 						 int *is_uncompressed);
1469 
1470 /**
1471  Testing if a Section Object adopts a lossless compression
1472 
1473  \param scn pointer to the Section Object.
1474  \param is_lossless on completion the variable referenced by this
1475  pointer will contain RL2_TRUE or RL2_FALSE.
1476 
1477  \return RL2_OK on success: RL2_ERROR on failure.
1478 
1479  \sa rl2_create_section
1480  */
1481     RL2_DECLARE int rl2_is_section_compression_lossless (rl2SectionPtr scn,
1482 							 int *is_lossless);
1483 
1484 /**
1485  Testing if a Section Object adopts a lossy compression
1486 
1487  \param scn pointer to the Section Object.
1488  \param is_lossy on completion the variable referenced by this
1489  pointer will contain RL2_TRUE or RL2_FALSE.
1490 
1491  \return RL2_OK on success: RL2_ERROR on failure.
1492 
1493  \sa rl2_create_section
1494  */
1495     RL2_DECLARE int rl2_is_section_compression_lossy (rl2SectionPtr scn,
1496 						      int *is_lossy);
1497 
1498 /**
1499  Retrieving the Tile Size from a Section Object
1500 
1501  \param scn pointer to the Section Object.
1502  \param tile_width on completion the variable referenced by this
1503  pointer will contain the section's Tile Width.
1504  \param tile_height on completion the variable referenced by this
1505  pointer will contain the section's Tile Height.
1506 
1507  \return RL2_OK on success: RL2_ERROR on failure.
1508 
1509  \sa rl2_create_section
1510  */
1511     RL2_DECLARE int rl2_get_section_tile_size (rl2SectionPtr scn,
1512 					       unsigned int *tile_width,
1513 					       unsigned int *tile_height);
1514 
1515 /**
1516  Return a reference to the Raster Object encapsulated within a Section Object
1517 
1518  \param cvg pointer to the Section Object.
1519 
1520  \return pointer to the Raster Object; NULL if any error is encountered.
1521 
1522  \sa rl2_create_section
1523 
1524  \note full ownership of the referenced Raster Object will still belong to the Section Object.
1525  */
1526     RL2_DECLARE rl2RasterPtr rl2_get_section_raster (rl2SectionPtr scn);
1527 
1528 /**
1529  Allocates and initializes a new Raster object
1530 
1531  \param width Raster Width (in pixels).
1532  \param height Raster Height (in pixels).
1533  \param sample_type one of RL2_SAMPLE_1_BIT, RL2_SAMPLE_2_BIT, RL2_SAMPLE_4_BIT,
1534         RL2_SAMPLE_INT8, RL2_SAMPLE_UINT8, RL2_SAMPLE_INT16, RL2_SAMPLE_UINT16,
1535 		RL2_SAMPLE_INT32, RL2_SAMPLE_UINT32, RL2_SAMPLE_FLOAT or RL2_SAMPLE_DOUBLE.
1536  \param pixel_type one of RL2_PIXEL_MONOCHROME, RL2_PIXEL_PALETTE, RL2_PIXEL_GRAYSCALE,
1537 		RL2_PIXEL_RGB, RL2_PIXEL_MULTIBAND, RL2_PIXEL_DATAGRID.
1538  \param num_samples number of samples per pixel (aka Bands)
1539  \param bufpix pointer to the Buffer containing all Pixels
1540  \param bufpix_size size (in bytes) of the above Buffer
1541  \param palette pointer to a Palette object (NULL is the Pixel Type doesn't require a Palette)
1542  \param mask pointer to an optional Transparency Mask (may be NULL if no Mask is required)
1543  \param mask_size size (in bytes) of the above Mask (ZERO if no Mask is required)
1544  \param no_data pointer to a Pixel Object indented as NO-DATA value;
1545 		could be eventually NULL if not required.
1546 
1547  \return the pointer to newly created Raster Object: NULL on failure.
1548 
1549  \sa rl2_destroy_raster, rl2_get_raster_size,
1550 		rl2_get_raster_raster_type, rl2_get_raster_pixel_type,
1551 		rl2_get_raster_bands, rl2_get_raster_no_data, rl2_get_raster_srid,
1552 		rl2_get_raster_horizontal_resolution, rl2_get_raster_vertical_resolution,
1553 		rl2_get_raster_minX, rl2_get_raster_minY, rl2_get_raster_maxX,
1554 		rl2_get_raster_maxY, rl2_create_raster_pixel,
1555 		rl2_raster_georeference_center, rl2_raster_georeference_upper_left,
1556 		rl2_raster_georeference_lower_left, rl2_raster_georeference_upper_right,
1557 		rl2_raster_georeference_lower_right, rl2_raster_georeference_frame,
1558 		rl2_raster_data_to_1bit, rl2_raster_data_to_2bit, rl2_raster_data_to_4bit,
1559 		rl2_raster_data_to_int8, rl2_raster_data_to_uint8, rl2_raster_data_to_int16,
1560 		rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
1561 		rl2_raster_data_to_float, rl2_raster_data_to_double, rl2_raster_band_to_uint8,
1562 		rl2_raster_band_to_uint16, rl2_raster_bands_to_RGB, rl2_raster_to_gif,
1563 		rl2_raster_to_png, rl2_raster_to_jpeg, rl2_raster_to_lossless_webp,
1564 		rl2_raster_to_lossy_webp, rl2_raster_from_gif, rl2_raster_from_png,
1565 		rl2_raster_from_jpeg, rl2_raster_from_webp, rl2_raster_from_tiff
1566 
1567  \note you are responsible to destroy (before or after) any allocated
1568  Raster object.
1569  */
1570     RL2_DECLARE rl2RasterPtr
1571 	rl2_create_raster (unsigned int width, unsigned int height,
1572 			   unsigned char sample_type, unsigned char pixel_type,
1573 			   unsigned char num_samples, unsigned char *bufpix,
1574 			   int bufpix_size, rl2PalettePtr palette,
1575 			   unsigned char *mask, int mask_size,
1576 			   rl2PixelPtr no_data);
1577 
1578 /**
1579  Destroys a Raster Object
1580 
1581  \param rst pointer to object to be destroyed
1582 
1583  \sa rl2_create_raster
1584  */
1585     RL2_DECLARE void rl2_destroy_raster (rl2RasterPtr rst);
1586 
1587 /**
1588  Retrieving the Width/height dimensions from a Raster Object
1589 
1590  \param rst pointer to the Raster Object.
1591  \param width on completion the variable referenced by this
1592  pointer will contain the raster's Width.
1593  \param height on completion the variable referenced by this
1594  pointer will contain the raster's Height.
1595 
1596  \return RL2_OK on success: RL2_ERROR on failure.
1597 
1598  \sa rl2_create_raster
1599  */
1600     RL2_DECLARE int rl2_get_raster_size (rl2RasterPtr rst,
1601 					 unsigned int *width,
1602 					 unsigned int *height);
1603 
1604 /**
1605  Retrieving the Sample Type from a Raster Object
1606 
1607  \param rst pointer to the Raster Object.
1608  \param sample_type on completion the variable referenced by this
1609  pointer will contain the Sampe Type.
1610  \param pixel_type on completion the variable referenced by this
1611  pointer will contain the Pixel Type.
1612  \param num_bands on completion the variable referenced by this
1613  pointer will contain the Number of Bands.
1614 
1615  \return RL2_OK on success: RL2_ERROR on failure.
1616 
1617  \sa rl2_create_raster
1618  */
1619     RL2_DECLARE int rl2_get_raster_type (rl2RasterPtr rst,
1620 					 unsigned char *sample_type,
1621 					 unsigned char *pixel_type,
1622 					 unsigned char *num_bands);
1623 
1624 /**
1625  Explicitly sets the NO-DATA Pixel value for a Raster Object
1626 
1627  \param rst pointer to the Raster Object.
1628  \param no_data pointer to a Pixel Object
1629 
1630  \return RL2_OK on success: RL2_ERROR on failure.
1631 
1632  \sa rl2_create_raster, rl2_get_raster_no_data
1633  */
1634     RL2_DECLARE int rl2_set_raster_no_data (rl2RasterPtr rst,
1635 					    rl2PixelPtr no_data);
1636 
1637 /**
1638  Retrieving the NO-DATA Pixel value from a Raster Object
1639 
1640  \param rst pointer to the Raster Object.
1641 
1642  \return pointer to the Pixel Object representing NO-DATA value;
1643   NULL if any error is encountered or if the Raster has no NO-DATA value.
1644 
1645  \sa rl2_create_raster, rl2_set_raster_no_data
1646  */
1647     RL2_DECLARE rl2PixelPtr rl2_get_raster_no_data (rl2RasterPtr rst);
1648 
1649 /**
1650  Retrieving the SRID from a Raster Object
1651 
1652  \param rst pointer to the Raster Object.
1653  \param srid on completion the variable referenced by this
1654  pointer will contain the raster's SRID.
1655 
1656  \return RL2_OK on success: RL2_ERROR on failure.
1657 
1658  \sa rl2_create_raster
1659  */
1660     RL2_DECLARE int rl2_get_raster_srid (rl2RasterPtr rst, int *srid);
1661 
1662 /**
1663  Retrieving the Pixel resolution from a Raster Object
1664 
1665  \param rst pointer to the Raster Object.
1666  \param hResolution on completion the variable referenced by this
1667  pointer will contain the raster's Horizontal Resolution.
1668  \param vResolution on completion the variable referenced by this
1669  pointer will contain the raster's Vertical Resolution.
1670 
1671  \return RL2_OK on success: RL2_ERROR on failure.
1672 
1673  \sa rl2_create_raster
1674  */
1675     RL2_DECLARE int rl2_get_raster_resolution (rl2RasterPtr rst,
1676 					       double *hResolution,
1677 					       double *vResolution);
1678 
1679 /**
1680  Retrieving the full extent from a Raster Object
1681 
1682  \param rst pointer to the Raster Object.
1683  \param minX on completion the variable referenced by this
1684  pointer will contain the raster's minimum X coordinate.
1685  \param minY on completion the variable referenced by this
1686  pointer will contain the raster's minimum Y coordinate.
1687  \param maxX on completion the variable referenced by this
1688  pointer will contain the raster's maximum X coordinate.
1689  \param maxY on completion the variable referenced by this
1690  pointer will contain the raster's maximum Y coordinate.
1691 
1692  \return RL2_OK on success: RL2_ERROR on failure.
1693 
1694  \sa rl2_create_raster
1695  */
1696     RL2_DECLARE int rl2_get_raster_extent (rl2RasterPtr rst,
1697 					   double *minX, double *minY,
1698 					   double *maxX, double *maxY);
1699 
1700 /**
1701  Retrieving the bounding box from a Raster Object
1702 
1703  \param rst pointer to the Raster Object.
1704 
1705  \return a Geometry Object (rectangle) corresponding to the Raster's BBox;
1706 	NULL if any error is encountered or if the Raster doesn't support any GeoReferencing.
1707 
1708  \sa rl2_create_raster
1709  */
1710     RL2_DECLARE gaiaGeomCollPtr rl2_get_raster_bbox (rl2RasterPtr rst);
1711 
1712 /**
1713  Creates a new Pixel Object suitable for a given Raster Object
1714 
1715  \param rst pointer to the Raster Object.
1716 
1717  \return pointer to the newly created Pixel Object; NULL if any error is encountered.
1718 
1719  \sa rl2_create_raster, rl2_create_pixel, rl2_destroy_pixel
1720 
1721  \note you are responsible to destroy (before or after) the allocated
1722  Pixel object.
1723  */
1724     RL2_DECLARE rl2PixelPtr rl2_create_raster_pixel (rl2RasterPtr rst);
1725 
1726 /**
1727  Georeferencing a Raster Object (by specifying its Center Point)
1728 
1729  \param rst pointer to the Raster Object.
1730  \param srid the SRID value
1731  \param horz_res horizontal pixel resolution: the size (measured
1732 		in map units) corresponding to a single Pixel.
1733  \param vert_res vertical pixel resolution.
1734  \param cx map X coordinate corresponding to the Raster's center point.
1735  \param cy map Y coordinate corresponding to the Raster's center point.
1736 
1737  \return RL2_OK on success: RL2_ERROR on failure.
1738 
1739  \sa rl2_create_raster, rl2_raster_georeference_upper_left,
1740  rl2_raster_georeference_lower_left, rl2_raster_georeference_upper_right,
1741  rl2_raster_georeference_lower_right, rl2_raster_georeference_frame
1742  */
1743     RL2_DECLARE int
1744 	rl2_raster_georeference_center (rl2RasterPtr rst, int srid,
1745 					double horz_res, double vert_res,
1746 					double cx, double cy);
1747 
1748 /**
1749  Georeferencing a Raster Object (by specifying its Upper-Left Corner)
1750 
1751  \param rst pointer to the Raster Object.
1752  \param srid the SRID value
1753  \param horz_res horizontal pixel resolution: the size (measured
1754 		in map units) corresponding to a single Pixel.
1755  \param vert_res vertical pixel resolution.
1756  \param x map X coordinate corresponding to the Raster's upper-left corner.
1757  \param y map Y coordinate corresponding to the Raster's upper-left corner.
1758 
1759  \return RL2_OK on success: RL2_ERROR on failure.
1760 
1761  \sa rl2_create_raster, rl2_raster_georeference_center,
1762  rl2_raster_georeference_lower_left, rl2_raster_georeference_upper_right,
1763  rl2_raster_georeference_lower_right, rl2_raster_georeference_frame
1764  */
1765     RL2_DECLARE int
1766 	rl2_raster_georeference_upper_left (rl2RasterPtr rst, int srid,
1767 					    double horz_res, double vert_res,
1768 					    double x, double y);
1769 
1770 
1771 /**
1772  Georeferencing a Raster Object (by specifying its Lower-Left Corner)
1773 
1774  \param rst pointer to the Raster Object.
1775  \param srid the SRID value
1776  \param horz_res horizontal pixel resolution: the size (measured
1777 		in map units) corresponding to a single Pixel.
1778  \param vert_res vertical pixel resolution.
1779  \param x map X coordinate corresponding to the Raster's lower-left corner.
1780  \param y map Y coordinate corresponding to the Raster's lower-left corner.
1781 
1782  \return RL2_OK on success: RL2_ERROR on failure.
1783 
1784  \sa rl2_create_raster, rl2_raster_georeference_center,
1785  rl2_raster_georeference_upper_left, rl2_raster_georeference_upper_right,
1786  rl2_raster_georeference_lower_right, rl2_raster_georeference_frame
1787  */
1788     RL2_DECLARE int
1789 	rl2_raster_georeference_lower_left (rl2RasterPtr rst, int srid,
1790 					    double horz_res, double vert_res,
1791 					    double x, double y);
1792 
1793 
1794 /**
1795  Georeferencing a Raster Object (by specifying its Upper-Right Corner)
1796 
1797  \param rst pointer to the Raster Object.
1798  \param srid the SRID value
1799  \param horz_res horizontal pixel resolution: the size (measured
1800 		in map units) corresponding to a single Pixel.
1801  \param vert_res vertical pixel resolution.
1802  \param x map X coordinate corresponding to the Raster's upper-right corner.
1803  \param y map Y coordinate corresponding to the Raster's upper-right corner.
1804 
1805  \return RL2_OK on success: RL2_ERROR on failure.
1806 
1807  \sa rl2_create_raster, rl2_raster_georeference_center, rl2_raster_georeference_upper_left,
1808  rl2_raster_georeference_lower_left, rl2_raster_georeference_lower_right,
1809  rl2_raster_georeference_frame
1810  */
1811     RL2_DECLARE int
1812 	rl2_raster_georeference_upper_right (rl2RasterPtr rst, int srid,
1813 					     double horz_res, double vert_res,
1814 					     double x, double y);
1815 
1816 /**
1817  Georeferencing a Raster Object (by specifying its Lower-Right Corner)
1818 
1819  \param rst pointer to the Raster Object.
1820  \param srid the SRID value
1821  \param horz_res horizontal pixel resolution: the size (measured
1822 		in map units) corresponding to a single Pixel.
1823  \param vert_res vertical pixel resolution.
1824  \param x map X coordinate corresponding to the Raster's lower-right corner.
1825  \param y map Y coordinate corresponding to the Raster's lower-right corner.
1826 
1827  \return RL2_OK on success: RL2_ERROR on failure.
1828 
1829  \sa rl2_create_raster, rl2_raster_georeference_center, rl2_raster_georeference_upper_left,
1830  rl2_raster_georeference_upper_right, rl2_raster_georeference_lower_left,
1831  rl2_raster_georeference_frame
1832  */
1833     RL2_DECLARE int
1834 	rl2_raster_georeference_lower_right (rl2RasterPtr rst, int srid,
1835 					     double horz_res, double vert_res,
1836 					     double x, double y);
1837 
1838 /**
1839  Georeferencing a Raster Object (by specifying its Corners)
1840 
1841  \param rst pointer to the Raster Object.
1842  \param srid the SRID value
1843  \param min_x map X coordinate corresponding to the Raster's lower-left corner.
1844  \param min_y map Y coordinate corresponding to the Raster's lower-letf corner.
1845  \param max_x map X coordinate corresponding to the Raster's upper-right corner.
1846  \param max_y map Y coordinate corresponding to the Raster's upper-right corner.
1847 
1848  \return RL2_OK on success: RL2_ERROR on failure.
1849 
1850  \sa rl2_create_raster, rl2_raster_georeference_center, rl2_raster_georeference_upper_left,
1851  rl2_raster_georeference_upper_right, rl2_raster_georeference_lower_left,
1852  rl2_raster_georeference_lower_right
1853  */
1854     RL2_DECLARE int
1855 	rl2_raster_georeference_frame (rl2RasterPtr rst, int srid, double min_x,
1856 				       double min_y, double max_x,
1857 				       double max_y);
1858 
1859 /**
1860  Retrieves a Pixel from a Raster Object
1861 
1862  \param rst pointer to the Raster Object.
1863  \param pxl pointer to an already allocated Pixel Object receiving the pixel's
1864 	values from the raster.
1865  \param row pixel's row number.
1866  \param col pixel's column numer: pixels are structured as a rectangular array.
1867  Pixel [0,0] is always positioned on the raster's left-upper corner.
1868 
1869  \return RL2_OK on success: RL2_ERROR on failure.
1870 
1871  \sa rl2_create_raster, rl2_create_pixel, rl2_get_raster_size,
1872   rl2_set_raster_pixel
1873  */
1874     RL2_DECLARE int
1875 	rl2_get_raster_pixel (rl2RasterPtr rst, rl2PixelPtr pxl,
1876 			      unsigned int row, unsigned int col);
1877 
1878 /**
1879  Retrieves a Pixel from a Raster Object
1880 
1881  \param rst pointer to the Raster Object.
1882  \param pxl pointer to a Pixel Object containing the pixel's
1883 	values to be stored within the raster.
1884  \param row pixel's row number.
1885  \param col pixel's column numer: pixels are structured as a rectangular array.
1886  Pixel [0,0] is always positioned on the raster's left-upper corner.
1887 
1888  \return RL2_OK on success: RL2_ERROR on failure.
1889 
1890  \sa rl2_create_raster, rl2_create_pixel, rl2_get_raster_size,
1891   rl2_get_raster_pixel
1892  */
1893     RL2_DECLARE int
1894 	rl2_set_raster_pixel (rl2RasterPtr rst, rl2PixelPtr pxl,
1895 			      unsigned int row, unsigned int col);
1896 
1897 /**
1898  Encodes a Raster Object into the corresponding BLOB serialized format
1899 
1900  \param rst pointer to the Raster Object.
1901  \param compression one of RL2_COMPRESSION_NONE, RL2_COMPRESSION_DEFLATE,
1902 		RL2_COMPRESSION_LZMA, RL2_COMPRESSION_GIF, RL2_COMPRESSION_PNG,
1903 		RL2_COMPRESSION_JPEG, RL2_COMPRESSION_LOSSY_WEBP or
1904  		RL2_COMPRESSION_LOSSLESS_WEBP
1905  \param blob_odd on completion will point to the created encoded BLOB ("odd" half).
1906  \param blob_odd_sz on completion the variable referenced by this
1907  pointer will contain the size (in bytes) of the "odd" BLOB.
1908  \param blob_even on completion will point to the created encoded BLOB ("even" half).
1909  \param blob_even_sz on completion the variable referenced by this
1910  pointer will contain the size (in bytes) of the "even" BLOB.
1911  \param quality compression quality factor (0-100); only meaningfull for
1912 		JPEG or WEBP lossy compressions, ignored in any other case.
1913  \param litte_endian (boolean) accordingly to required BLOB endianness.
1914 
1915  \return RL2_OK on success: RL2_ERROR on failure.
1916 
1917  \sa rl2_create_raster, rl2_raster_decode, rl2_get_raster_statistics
1918 
1919  \note both "odd" and "even" BLOB objects corresponds to dynamic memory;
1920  you are responsible for properly freeing such dynamic allocations in
1921  the most appropriate way.
1922 
1923  \note some specific encoding doesn't require the "even" BLOB; so be prepared
1924  to get a NULL pointer in this case.
1925  */
1926     RL2_DECLARE int
1927 	rl2_raster_encode (rl2RasterPtr rst, int compression,
1928 			   unsigned char **blob_odd, int *blob_odd_sz,
1929 			   unsigned char **blob_even, int *blob_even_sz,
1930 			   int quality, int little_endian);
1931 
1932 /**
1933  Tests a Raster Tile Object for validity - BLOB serialized format
1934 
1935  \param level Pyramid level index (full resolution always corresponds to the ZERO index)
1936  \param tile_width the individual tile width in pixels.
1937  \param tile_height the individual tile height in pixels.
1938  \param blob_odd pointer to the encoded BLOB ("odd" half).
1939  \param blob_odd_sz size (in bytes) of the "odd" BLOB.
1940  \param blob_even pointer to the encoded BLOB ("even" half): could be NULL.
1941  \param blob_even_sz size (in bytes) of the "even" BLOB: could be ZERO.
1942  \param sample_type sample type of the belonging Coverage
1943  \param pixel_type pixel type of the belonging Coverage
1944  \param num_bands number of bands of the belonging Coverage
1945  \param compression of the belonging Coverage
1946 
1947  \return RL2_OK on success: RL2_ERROR on failure.
1948 
1949  \sa rl2_create_raster, rl2_raster_encode, rl2_get_raster_statistics
1950 
1951  \note you are responsible to destroy (before or after) any allocated
1952  Raster object.
1953 
1954  \note some specific encoding doesn't require the "even" BLOB; in this case
1955  you should set blob_even to NULL and blob_even_sz to ZERO.
1956  */
1957     RL2_DECLARE int
1958 	rl2_is_valid_dbms_raster_tile (unsigned short level,
1959 				       unsigned int tile_width,
1960 				       unsigned int tile_height,
1961 				       const unsigned char *blob_odd,
1962 				       int blob_odd_sz,
1963 				       const unsigned char *blob_even,
1964 				       int blob_even_sz,
1965 				       unsigned char sample_type,
1966 				       unsigned char pixel_type,
1967 				       unsigned char num_bands,
1968 				       unsigned char compression);
1969 
1970 /**
1971  Decodes a Raster Object from the corresponding BLOB serialized format
1972 
1973  \param scale image ratio: one of RL2_SCALE_1 (1:1), RL2_SCALE_2 (1:2),
1974  RL2_SCALE_4 (1:4) or RL2_SCALE_8 (1:8)
1975  \param blob_odd pointer to the encoded BLOB ("odd" half).
1976  \param blob_odd_sz size (in bytes) of the "odd" BLOB.
1977  \param blob_even pointer to the encoded BLOB ("even" half): could be NULL.
1978  \param blob_even_sz size (in bytes) of the "even" BLOB: could be ZERO.
1979  \param palette pointer to a Palette object (could be NULL, but it could
1980  be strictly required by Palette-based tiles)
1981 
1982  \return the pointer to newly created Raster Object: NULL on failure.
1983 
1984  \sa rl2_create_raster, rl2_raster_encode, rl2_get_raster_statistics,
1985  rl2_is_valid_dbms_raster_tile
1986 
1987  \note you are responsible to destroy (before or after) any allocated
1988  Raster object.
1989 
1990  \note some specific encoding doesn't require the "even" BLOB; in this case
1991  you should set blob_even to NULL and blob_even_sz to ZERO.
1992  */
1993     RL2_DECLARE rl2RasterPtr
1994 	rl2_raster_decode (int scale, const unsigned char *blob_odd,
1995 			   int blob_odd_sz, const unsigned char *blob_even,
1996 			   int blob_even_sz, rl2PalettePtr palette);
1997 
1998 /**
1999  Allocates and initializes a new Raster Statistics object
2000 
2001  \param sample_type one of RL2_SAMPLE_1_BIT, RL2_SAMPLE_2_BIT, RL2_SAMPLE_4_BIT,
2002         RL2_SAMPLE_INT8, RL2_SAMPLE_UINT8, RL2_SAMPLE_INT16, RL2_SAMPLE_UINT16,
2003 		RL2_SAMPLE_INT32, RL2_SAMPLE_UINT32, RL2_SAMPLE_FLOAT or RL2_SAMPLE_DOUBLE.
2004  \param num_samples number of samples per pixel (aka Bands)
2005 
2006  \return the pointer to newly created Raster Statistics Object: NULL on failure.
2007 
2008  \sa rl2_destroy_raster_statistic, rl2_get_raster_statistics
2009 
2010  \note you are responsible to destroy (before or after) any allocated
2011  Raster Statistics object.
2012  */
2013     RL2_DECLARE rl2RasterStatisticsPtr rl2_create_raster_statistics (unsigned
2014 								     char
2015 								     sample_type,
2016 								     unsigned
2017 								     char
2018 								     num_samples);
2019 
2020 /**
2021  Destroys a Raster Statistics Object
2022 
2023  \param stats pointer to object to be destroyed
2024 
2025  \sa rl2_create_raster_statistics
2026  */
2027     RL2_DECLARE void rl2_destroy_raster_statistics (rl2RasterStatisticsPtr
2028 						    stats);
2029 
2030 /**
2031  Computes the Raster Statistics from BLOB serialized format
2032 
2033  \param blob_odd pointer to the encoded BLOB ("odd" half).
2034  \param blob_odd_sz size (in bytes) of the "odd" BLOB.
2035  \param blob_even pointer to the encoded BLOB ("even" half): could be NULL.
2036  \param blob_even_sz size (in bytes) of the "even" BLOB: could be ZERO.
2037  \param palette pointer to a Palette object (could be NULL, but it could
2038  be strictly required by Palette-based tiles)
2039  \param no_data NO-DATA pixel value (could be eventually NULL)
2040 
2041  \return the pointer to newly created Raster Statistics Object: NULL on failure.
2042 
2043  \sa rl2_destroy_raster_statistics, rl2_aggregate_raster_statistics,
2044  rl2_serialize_dbms_raster_statistics, rl2_deserialize_dbms_raster_statistics,
2045  rl2_get_raster_statistics_summary, rl2_get_band_statistics
2046 
2047  \note you are responsible to destroy (before or after) any allocated
2048  Raster Statistics object.
2049  */
2050     RL2_DECLARE rl2RasterStatisticsPtr
2051 	rl2_get_raster_statistics (const unsigned char *blob_odd,
2052 				   int blob_odd_sz,
2053 				   const unsigned char *blob_even,
2054 				   int blob_even_sz, rl2PalettePtr palette,
2055 				   rl2PixelPtr no_data);
2056 
2057 /**
2058  Computes the Raster Statistics from a Raster object
2059 
2060  \param raster pointer to a valid Raster object
2061 
2062  \return the pointer to newly created Raster Statistics Object: NULL on failure.
2063 
2064  \sa rl2_destroy_raster_statistics, rl2_get_band_statistics
2065 
2066  \note you are responsible to destroy (before or after) any allocated
2067  Raster Statistics object.
2068  */
2069     RL2_DECLARE rl2RasterStatisticsPtr rl2_build_raster_statistics (rl2RasterPtr
2070 								    raster,
2071 								    rl2PixelPtr
2072 								    noData);
2073 
2074 /**
2075  Encodes a Raster Statistics Object into the corresponding BLOB serialized format
2076 
2077  \param stats pointer to the Raster Statistics Object.
2078  \param blob on completion will point to the created encoded BLOB.
2079  \param blob_sz on completion the variable referenced by this
2080  pointer will contain the size (in bytes) of the BLOB.
2081 
2082  \return RL2_OK on success: RL2_ERROR on failure.
2083 
2084  \sa rl2_create_raster_statistics, rl2_get_raster_statistics,
2085  rl2_deserialize_dbms_raster_statistics, rl2_is_valid_dbms_raster_statistics
2086 
2087  \note the returned BLOB object corresponds to dynamic memory;
2088  you are responsible for properly freeing such dynamic allocation in
2089  the most appropriate way.
2090  */
2091     RL2_DECLARE int
2092 	rl2_serialize_dbms_raster_statistics (rl2RasterStatisticsPtr stats,
2093 					      unsigned char **blob,
2094 					      int *blob_sz);
2095 
2096 /**
2097  Tests a Raster Statistics Object for validity - BLOB serialized format
2098 
2099  \param blob pointer to the encoded BLOB encoded object.
2100  \param blob_sz size (in bytes) of the BLOB encoded object.
2101 
2102  \return RL2_OK on success: RL2_ERROR on failure.
2103 
2104  \sa rl2_create_raster_statistics, rl2_get_raster_statistics,
2105  rl2_deserialize_dbms_raster_statistics, rl2_is_valid_dbms_raster_statistics
2106 
2107  \note the returned BLOB object corresponds to dynamic memory;
2108  you are responsible for properly freeing such dynamic allocation in
2109  the most appropriate way.
2110  */
2111     RL2_DECLARE int
2112 	rl2_is_valid_dbms_raster_statistics (const unsigned char *blob,
2113 					     int blob_sz,
2114 					     unsigned char sample_type,
2115 					     unsigned char num_bands);
2116 
2117 /**
2118  Decodes a Raster Statistics Object from the corresponding BLOB serialized format
2119 
2120  \param blob pointer to the encoded BLOB encoded object.
2121  \param blob_sz size (in bytes) of the BLOB encoded object.
2122 
2123  \return the pointer to newly created Raster Statistics Object: NULL on failure.
2124 
2125  \sa rl2_create_raster_statistics, rl2_serialize_dbms_raster_statistics,
2126  rl2_get_raster_statistics_summary, rl2_get_band_statistics
2127 
2128  \note you are responsible to destroy (before or after) any allocated
2129  Raster Statistics object.
2130  */
2131     RL2_DECLARE rl2RasterStatisticsPtr
2132 	rl2_deserialize_dbms_raster_statistics (const unsigned char *blob,
2133 						int blob_sz);
2134 
2135 /**
2136  Encodes a Raster Statistics Object into the corresponding BLOB serialized format
2137 
2138  \param stats_in pointer to the input Raster Statistics Object.
2139  \param stats_out pointer to the output Raster Statistics Object.
2140 
2141  \return RL2_OK on success: RL2_ERROR on failure.
2142 
2143  \sa rl2_create_raster_statistics, rl2_get_raster_statistics,
2144  rl2_get_raster_statistics_summary, rl2_get_band_statistics
2145  */
2146     RL2_DECLARE int
2147 	rl2_aggregate_raster_statistics (rl2RasterStatisticsPtr stats_in,
2148 					 rl2RasterStatisticsPtr stats_out);
2149 
2150 /**
2151  Return summary values from a Raster Statistics Object
2152 
2153  \param stats pointer to the input Raster Statistics Object.
2154  \param no_data on completion the variable referenced by this
2155  pointer will contain the total count of NO-DATA pixels.
2156  \param count on completion the variable referenced by this
2157  pointer will contain the total count of valid pixels.
2158  \param sample_type on completion the variable referenced by this
2159  pointer will contain the Sampe Type.
2160  \param num_bands on completion the variable referenced by this
2161  pointer will contain the Number of Bands.
2162 
2163  \return RL2_OK on success: RL2_ERROR on failure.
2164 
2165  \sa rl2_create_raster_statistics, rl2_get_raster_statistics,
2166  rl2_aggregate_raster_statistics, rl2_get_band_statistics
2167  */
2168     RL2_DECLARE int
2169 	rl2_get_raster_statistics_summary (rl2RasterStatisticsPtr stats,
2170 					   double *no_data, double *count,
2171 					   unsigned char *sample_type,
2172 					   unsigned char *num_bands);
2173 
2174 /**
2175  Return summary values from a single Band (Raster Statistics Object)
2176 
2177  \param stats pointer to the input Raster Statistics Object.
2178  \param band Band index.
2179  \param min on completion the variable referenced by this
2180  pointer will contain the minimum pixel value.
2181  \param max on completion the variable referenced by this
2182  pointer will contain the maximum pixel value.
2183  \param mean on completion the variable referenced by this
2184  pointer will contain the mean of all pixel values.
2185  \param variance on completion the variable referenced by this
2186  pointer will contain the Variance.
2187  \param standard_deviation on completion the variable referenced by this
2188  pointer will contain the Standard Deviation.
2189 
2190  \return RL2_OK on success: RL2_ERROR on failure.
2191 
2192  \sa rl2_create_raster_statistics, rl2_get_raster_statistics,
2193  rl2_aggregate_raster_statistics, rl2_get_raster_statistics_summary
2194  */
2195     RL2_DECLARE int
2196 	rl2_get_band_statistics (rl2RasterStatisticsPtr stats,
2197 				 unsigned char band, double *min, double *max,
2198 				 double *mean, double *variance,
2199 				 double *standard_deviation);
2200 
2201 /**
2202  Creates an RGB pixel array from a Raster
2203 
2204  \param rst pointer to the Raster Object.
2205  \param buffer on completion will point to the created pixel array.
2206  \param buf_size on completion the variable referenced by this
2207  pointer will contain the size (in bytes) of the pixel array.
2208 
2209  \return RL2_OK on success: RL2_ERROR on failure.
2210 
2211  \sa rl2_create_raster, rl2_raster_data_to_RGBA, rl2_raster_data_to_ARGB,
2212 	rl2_raster_data_to_BGR,	rl2_raster_data_to_BGRA
2213 
2214  \note the arrays returned by this function corresponds to dynamic memory;
2215  you are responsible for properly freeing such dynamic allocation in
2216  the most appropriate way.
2217 
2218  \note pixels into the returned array will be tightly packed and will be
2219  organized by increasing rows and columns; the first pixel will correspond
2220  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2221  Pixel components are always organized as RGBRGBRGB....RGB
2222  */
2223     RL2_DECLARE int
2224 	rl2_raster_data_to_RGB (rl2RasterPtr rst, unsigned char **buffer,
2225 				int *buf_size);
2226 
2227 /**
2228  Creates an RGBA pixel array from a Raster
2229 
2230  \param rst pointer to the Raster Object.
2231  \param buffer on completion will point to the created pixel array.
2232  \param buf_size on completion the variable referenced by this
2233  pointer will contain the size (in bytes) of the pixel array.
2234 
2235  \return RL2_OK on success: RL2_ERROR on failure.
2236 
2237  \sa rl2_create_raster, rl2_raster_data_to_RGB, rl2_raster_data_to_ARGB,
2238 	rl2_raster_data_to_BGR,	rl2_raster_data_to_BGRA
2239 
2240  \note the arrays returned by this function corresponds to dynamic memory;
2241  you are responsible for properly freeing such dynamic allocation in
2242  the most appropriate way.
2243 
2244  \note pixels into the returned array will be tightly packed and will be
2245  organized by increasing rows and columns; the first pixel will correspond
2246  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2247  Pixel components are always organized as RGBARGBARGBA....RGBA
2248  */
2249     RL2_DECLARE int
2250 	rl2_raster_data_to_RGBA (rl2RasterPtr rst, unsigned char **buffer,
2251 				 int *buf_size);
2252 
2253 /**
2254  Creates an ARGB pixel array from a Raster
2255 
2256  \param rst pointer to the Raster Object.
2257  \param buffer on completion will point to the created pixel array.
2258  \param buf_size on completion the variable referenced by this
2259  pointer will contain the size (in bytes) of the pixel array.
2260 
2261  \return RL2_OK on success: RL2_ERROR on failure.
2262 
2263  \sa rl2_create_raster, rl2_raster_data_to_RGB, rl2_raster_data_to_RGBA,
2264 	rl2_raster_data_to_BGR, rl2_raster_data_to_BGRA
2265 
2266  \note the arrays returned by this function corresponds to dynamic memory;
2267  you are responsible for properly freeing such dynamic allocation in
2268  the most appropriate way.
2269 
2270  \note pixels into the returned array will be tightly packed and will be
2271  organized by increasing rows and columns; the first pixel will correspond
2272  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2273  Pixel components are always organized as ARGBARGBARGB....ARGB
2274  */
2275     RL2_DECLARE int
2276 	rl2_raster_data_to_ARGB (rl2RasterPtr rst, unsigned char **buffer,
2277 				 int *buf_size);
2278 
2279 /**
2280  Creates an BGR pixel array from a Raster
2281 
2282  \param rst pointer to the Raster Object.
2283  \param buffer on completion will point to the created pixel array.
2284  \param buf_size on completion the variable referenced by this
2285  pointer will contain the size (in bytes) of the pixel array.
2286 
2287  \return RL2_OK on success: RL2_ERROR on failure.
2288 
2289  \sa rl2_create_raster, rl2_raster_data_to_RGB, rl2_raster_data_to_RGBA,
2290 	rl2_raster_data_to_ARGB, rl2_raster_data_to_BGRA
2291 
2292  \note the arrays returned by this function corresponds to dynamic memory;
2293  you are responsible for properly freeing such dynamic allocation in
2294  the most appropriate way.
2295 
2296  \note pixels into the returned array will be tightly packed and will be
2297  organized by increasing rows and columns; the first pixel will correspond
2298  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2299  Pixel components are always organized as BGRBGRBGR...BGR
2300  */
2301     RL2_DECLARE int
2302 	rl2_raster_data_to_BGR (rl2RasterPtr rst, unsigned char **buffer,
2303 				int *buf_size);
2304 
2305 /**
2306  Creates an BGRA pixel array from a Raster
2307 
2308  \param rst pointer to the Raster Object.
2309  \param buffer on completion will point to the created pixel array.
2310  \param buf_size on completion the variable referenced by this
2311  pointer will contain the size (in bytes) of the pixel array.
2312 
2313  \return RL2_OK on success: RL2_ERROR on failure.
2314 
2315  \sa rl2_create_raster, rl2_raster_data_to_RGB, rl2_raster_data_to_RGBA,
2316 	rl2_raster_data_to_ARGB, rl2_raster_data_to_BGR
2317 
2318  \note the arrays returned by this function corresponds to dynamic memory;
2319  you are responsible for properly freeing such dynamic allocation in
2320  the most appropriate way.
2321 
2322  \note pixels into the returned array will be tightly packed and will be
2323  organized by increasing rows and columns; the first pixel will correspond
2324  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2325  Pixel components are always organized as BGRABGRABGRA...BGRA
2326  */
2327     RL2_DECLARE int
2328 	rl2_raster_data_to_BGRA (rl2RasterPtr rst, unsigned char **buffer,
2329 				 int *buf_size);
2330 
2331 /**
2332  Creates a pixel array from a Raster (1 bit per sample)
2333 
2334  \param rst pointer to the Raster Object.
2335  \param buffer on completion will point to the created pixel array.
2336  \param buf_size on completion the variable referenced by this
2337  pointer will contain the size (in bytes) of the pixel array.
2338 
2339  \return RL2_OK on success: RL2_ERROR on failure.
2340 
2341  \sa rl2_create_raster, rl2_raster_data_to_2bit, rl2_raster_data_to_4bit,
2342 	rl2_raster_data_to_int8, rl2_raster_data_to_uint8, rl2_raster_data_to_int16,
2343 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2344 	rl2_raster_data_to_float, rl2_raster_data_to_double
2345 
2346  \note the arrays returned by this function corresponds to dynamic memory;
2347  you are responsible for properly freeing such dynamic allocation in
2348  the most appropriate way.
2349 
2350  \note pixels into the returned array will be tightly packed and will be
2351  organized by increasing rows and columns; the first pixel will correspond
2352  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2353  */
2354     RL2_DECLARE int
2355 	rl2_raster_data_to_1bit (rl2RasterPtr rst, unsigned char **buffer,
2356 				 int *buf_size);
2357 
2358 /**
2359  Creates a pixel array from a Raster (2 bit per sample)
2360 
2361  \param rst pointer to the Raster Object.
2362  \param buffer on completion will point to the created pixel array.
2363  \param buf_size on completion the variable referenced by this
2364  pointer will contain the size (in bytes) of the pixel array.
2365 
2366  \return RL2_OK on success: RL2_ERROR on failure.
2367 
2368  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_4bit,
2369 	rl2_raster_data_to_int8, rl2_raster_data_to_uint8, rl2_raster_data_to_int16,
2370 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2371 	rl2_raster_data_to_float, rl2_raster_data_to_double
2372 
2373  \note the arrays returned by this function corresponds to dynamic memory;
2374  you are responsible for properly freeing such dynamic allocation in
2375  the most appropriate way.
2376 
2377  \note pixels into the returned array will be tightly packed and will be
2378  organized by increasing rows and columns; the first pixel will correspond
2379  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2380  */
2381     RL2_DECLARE int
2382 	rl2_raster_data_to_2bit (rl2RasterPtr rst, unsigned char **buffer,
2383 				 int *buf_size);
2384 
2385 /**
2386  Creates a pixel array from a Raster (4 bit per sample)
2387 
2388  \param rst pointer to the Raster Object.
2389  \param buffer on completion will point to the created pixel array.
2390  \param buf_size on completion the variable referenced by this
2391  pointer will contain the size (in bytes) of the pixel array.
2392 
2393  \return RL2_OK on success: RL2_ERROR on failure.
2394 
2395  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2396 	rl2_raster_data_to_int8, rl2_raster_data_to_uint8, rl2_raster_data_to_int16,
2397 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2398 	rl2_raster_data_to_float, rl2_raster_data_to_double
2399 
2400  \note the arrays returned by this function corresponds to dynamic memory;
2401  you are responsible for properly freeing such dynamic allocation in
2402  the most appropriate way.
2403 
2404  \note pixels into the returned array will be tightly packed and will be
2405  organized by increasing rows and columns; the first pixel will correspond
2406  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2407  */
2408     RL2_DECLARE int
2409 	rl2_raster_data_to_4bit (rl2RasterPtr rst, unsigned char **buffer,
2410 				 int *buf_size);
2411 
2412 /**
2413  Creates a pixel array from a Raster (Integer, 8 bit sample)
2414 
2415  \param rst pointer to the Raster Object.
2416  \param buffer on completion will point to the created pixel array.
2417  \param buf_size on completion the variable referenced by this
2418  pointer will contain the size (in bytes) of the pixel array.
2419 
2420  \return RL2_OK on success: RL2_ERROR on failure.
2421 
2422  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2423 	rl2_raster_data_to_4bit, rl2_raster_data_to_uint8, rl2_raster_data_to_int16,
2424 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2425 	rl2_raster_data_to_float, rl2_raster_data_to_double
2426 
2427  \note the arrays returned by this function corresponds to dynamic memory;
2428  you are responsible for properly freeing such dynamic allocation in
2429  the most appropriate way.
2430 
2431  \note pixels into the returned array will be tightly packed and will be
2432  organized by increasing rows and columns; the first pixel will correspond
2433  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2434  Endianness will always correspond to CPU natural architecture.
2435  */
2436     RL2_DECLARE int
2437 	rl2_raster_data_to_int8 (rl2RasterPtr rst, char **buffer,
2438 				 int *buf_size);
2439 
2440 /**
2441  Creates a pixel array from a Raster (unsigned Integer, 8 bit sample)
2442 
2443  \param rst pointer to the Raster Object.
2444  \param buffer on completion will point to the created pixel array.
2445  \param buf_size on completion the variable referenced by this
2446  pointer will contain the size (in bytes) of the pixel array.
2447 
2448  \return RL2_OK on success: RL2_ERROR on failure.
2449 
2450  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2451 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_int16,
2452 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2453 	rl2_raster_data_to_float, rl2_raster_data_to_double, rl2_raster_band_to_uint8
2454 
2455  \note the arrays returned by this function corresponds to dynamic memory;
2456  you are responsible for properly freeing such dynamic allocation in
2457  the most appropriate way.
2458 
2459  \note pixels into the returned array will be tightly packed and will be
2460  organized by increasing rows and columns; the first pixel will correspond
2461  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2462  Endianness will always correspond to CPU natural architecture.
2463  */
2464     RL2_DECLARE int
2465 	rl2_raster_data_to_uint8 (rl2RasterPtr rst, unsigned char **buffer,
2466 				  int *buf_size);
2467 
2468 /**
2469  Creates a pixel array from a Raster (Integer, 16 bit sample)
2470 
2471  \param rst pointer to the Raster Object.
2472  \param buffer on completion will point to the created pixel array.
2473  \param buf_size on completion the variable referenced by this
2474  pointer will contain the size (in bytes) of the pixel array.
2475 
2476  \return RL2_OK on success: RL2_ERROR on failure.
2477 
2478  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2479 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2480 	rl2_raster_data_to_uint16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2481 	rl2_raster_data_to_float, rl2_raster_data_to_double
2482 
2483  \note the arrays returned by this function corresponds to dynamic memory;
2484  you are responsible for properly freeing such dynamic allocation in
2485  the most appropriate way.
2486 
2487  \note pixels into the returned array will be tightly packed and will be
2488  organized by increasing rows and columns; the first pixel will correspond
2489  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2490  Endianness will always correspond to CPU natural architecture.
2491  */
2492     RL2_DECLARE int
2493 	rl2_raster_data_to_int16 (rl2RasterPtr rst, short **buffer,
2494 				  int *buf_size);
2495 
2496 /**
2497  Creates a pixel array from a Raster (unsigned Integer, 16 bit sample)
2498 
2499  \param rst pointer to the Raster Object.
2500  \param buffer on completion will point to the created pixel array.
2501  \param buf_size on completion the variable referenced by this
2502  pointer will contain the size (in bytes) of the pixel array.
2503 
2504  \return RL2_OK on success: RL2_ERROR on failure.
2505 
2506  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2507 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2508 	rl2_raster_data_to_int16, rl2_raster_data_to_int32, rl2_raster_data_to_uint32,
2509 	rl2_raster_data_to_float, rl2_raster_data_to_double, rl2_raster_band_to_uint16
2510 
2511  \note the arrays returned by this function corresponds to dynamic memory;
2512  you are responsible for properly freeing such dynamic allocation in
2513  the most appropriate way.
2514 
2515  \note pixels into the returned array will be tightly packed and will be
2516  organized by increasing rows and columns; the first pixel will correspond
2517  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2518  Endianness will always correspond to CPU natural architecture.
2519  */
2520     RL2_DECLARE int
2521 	rl2_raster_data_to_uint16 (rl2RasterPtr rst, unsigned short **buffer,
2522 				   int *buf_size);
2523 
2524 /**
2525  Creates a pixel array from a Raster (Integer, 32 bit sample)
2526 
2527  \param rst pointer to the Raster Object.
2528  \param buffer on completion will point to the created pixel array.
2529  \param buf_size on completion the variable referenced by this
2530  pointer will contain the size (in bytes) of the pixel array.
2531 
2532  \return RL2_OK on success: RL2_ERROR on failure.
2533 
2534  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2535 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2536 	rl2_raster_data_to_int16, rl2_raster_data_to_uint16, rl2_raster_data_to_uint32,
2537 	rl2_raster_data_to_float, rl2_raster_data_to_double
2538 
2539  \note the arrays returned by this function corresponds to dynamic memory;
2540  you are responsible for properly freeing such dynamic allocation in
2541  the most appropriate way.
2542 
2543  \note pixels into the returned array will be tightly packed and will be
2544  organized by increasing rows and columns; the first pixel will correspond
2545  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2546  Endianness will always correspond to CPU natural architecture.
2547  */
2548     RL2_DECLARE int
2549 	rl2_raster_data_to_int32 (rl2RasterPtr rst, int **buffer,
2550 				  int *buf_size);
2551 
2552 /**
2553  Creates a pixel array from a Raster (unsigned Integer, 32 bit sample)
2554 
2555  \param rst pointer to the Raster Object.
2556  \param buffer on completion will point to the created pixel array.
2557  \param buf_size on completion the variable referenced by this
2558  pointer will contain the size (in bytes) of the pixel array.
2559 
2560  \return RL2_OK on success: RL2_ERROR on failure.
2561 
2562  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2563 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2564 	rl2_raster_data_to_int16, rl2_raster_data_to_uint16, rl2_raster_data_to_int32,
2565 	rl2_raster_data_to_float, rl2_raster_data_to_double
2566 
2567  \note the arrays returned by this function corresponds to dynamic memory;
2568  you are responsible for properly freeing such dynamic allocation in
2569  the most appropriate way.
2570 
2571  \note pixels into the returned array will be tightly packed and will be
2572  organized by increasing rows and columns; the first pixel will correspond
2573  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2574  Endianness will always correspond to CPU natural architecture.
2575  */
2576     RL2_DECLARE int
2577 	rl2_raster_data_to_uint32 (rl2RasterPtr rst, unsigned int **buffer,
2578 				   int *buf_size);
2579 
2580 /**
2581  Creates a pixel array from a Raster (floating point, single precision sample)
2582 
2583  \param rst pointer to the Raster Object.
2584  \param buffer on completion will point to the created pixel array.
2585  \param buf_size on completion the variable referenced by this
2586  pointer will contain the size (in bytes) of the pixel array.
2587 
2588  \return RL2_OK on success: RL2_ERROR on failure.
2589 
2590  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2591 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2592 	rl2_raster_data_to_int16, rl2_raster_data_to_uint16, rl2_raster_data_to_int32,
2593 	rl2_raster_data_to_uint32, rl2_raster_data_to_double
2594 
2595  \note the arrays returned by this function corresponds to dynamic memory;
2596  you are responsible for properly freeing such dynamic allocation in
2597  the most appropriate way.
2598 
2599  \note pixels into the returned array will be tightly packed and will be
2600  organized by increasing rows and columns; the first pixel will correspond
2601  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2602  Endianness will always correspond to CPU natural architecture.
2603  */
2604     RL2_DECLARE int
2605 	rl2_raster_data_to_float (rl2RasterPtr rst, float **buffer,
2606 				  int *buf_size);
2607 
2608 /**
2609  Creates a pixel array from a Raster (floating point, double precision sample)
2610 
2611  \param rst pointer to the Raster Object.
2612  \param buffer on completion will point to the created pixel array.
2613  \param buf_size on completion the variable referenced by this
2614  pointer will contain the size (in bytes) of the pixel array.
2615 
2616  \return RL2_OK on success: RL2_ERROR on failure.
2617 
2618  \sa rl2_create_raster, rl2_raster_data_to_1bit, rl2_raster_data_to_2bit,
2619 	rl2_raster_data_to_4bit, rl2_raster_data_to_int8, rl2_raster_data_to_uint8,
2620 	rl2_raster_data_to_int16, rl2_raster_data_to_uint16, rl2_raster_data_to_int32,
2621 	rl2_raster_data_to_uint32, rl2_raster_data_to_float
2622 
2623  \note the arrays returned by this function corresponds to dynamic memory;
2624  you are responsible for properly freeing such dynamic allocation in
2625  the most appropriate way.
2626 
2627  \note pixels into the returned array will be tightly packed and will be
2628  organized by increasing rows and columns; the first pixel will correspond
2629  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2630  Endianness will always correspond to CPU natural architecture.
2631  */
2632     RL2_DECLARE int
2633 	rl2_raster_data_to_double (rl2RasterPtr rst, double **buffer,
2634 				   int *buf_size);
2635 
2636 /**
2637  Creates a pixel array from a Multiband Raster (unsigned Integer, 8 bit sample, single Band)
2638 
2639  \param rst pointer to the Raster Object.
2640  \param band the selected Sample/Band index (the first sample corresponds to index ZERO).
2641  \param buffer on completion will point to the created pixel/Band array.
2642  \param buf_size on completion the variable referenced by this
2643  pointer will contain the size (in bytes) of the pixel/Band array.
2644 
2645  \return RL2_OK on success: RL2_ERROR on failure.
2646 
2647  \sa rl2_create_raster, rl2_raster_data_to_uint8, rl2_raster_band_to_uint16,
2648 	rl2_raster_bands_to_RGB
2649 
2650  \note the arrays returned by this function corresponds to dynamic memory;
2651  you are responsible for properly freeing such dynamic allocation in
2652  the most appropriate way.
2653 
2654  \note pixels into the returned array will be tightly packed and will be
2655  organized by increasing rows and columns; the first pixel will correspond
2656  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2657  Endianness will always correspond to CPU natural architecture.
2658  */
2659     RL2_DECLARE int
2660 	rl2_raster_band_to_uint8 (rl2RasterPtr rst, int band,
2661 				  unsigned char **buffer, int *buf_size);
2662 
2663 /**
2664  Creates a pixel array from a Multiband Raster (unsigned Integer, 16 bit sample, single Band)
2665 
2666  \param rst pointer to the Raster Object.
2667  \param band the selected Sample/Band index (the first sample corresponds to index ZERO).
2668  \param buffer on completion will point to the created pixel/Band array.
2669  \param buf_size on completion the variable referenced by this
2670  pointer will contain the size (in bytes) of the pixel/Band array.
2671 
2672  \return RL2_OK on success: RL2_ERROR on failure.
2673 
2674  \sa rl2_create_raster, rl2_raster_data_to_uint16, rl2_raster_band_to_uint8,
2675 	rl2_raster_bands_to_RGB
2676 
2677  \note the arrays returned by this function corresponds to dynamic memory;
2678  you are responsible for properly freeing such dynamic allocation in
2679  the most appropriate way.
2680 
2681  \note pixels into the returned array will be tightly packed and will be
2682  organized by increasing rows and columns; the first pixel will correspond
2683  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2684  Endianness will always correspond to CPU natural architecture.
2685  */
2686     RL2_DECLARE int
2687 	rl2_raster_band_to_uint16 (rl2RasterPtr rst, int band,
2688 				   unsigned short **buffer, int *buf_size);
2689 
2690 /**
2691  Creates an RGB pixel array from a Multiband Raster
2692 
2693  \param rst pointer to the Raster Object.
2694  \param bandR an arbitrary Sample/Band index assumed to represent the Red Band
2695  (the first sample corresponds to index ZERO).
2696  \param bandG an arbitrary Sample/Band index assumed to represent the Green Band.
2697  \param bandB an arbitrary Sample/Band index assumed to represent the Blue Band.
2698  \param buffer on completion will point to the created pixel array.
2699  \param buf_size on completion the variable referenced by this
2700  pointer will contain the size (in bytes) of the pixel array.
2701 
2702  \return RL2_OK on success: RL2_ERROR on failure.
2703 
2704  \sa rl2_create_raster, rl2_raster_data_to_uint8, rl2_raster_band_to_uint8,
2705 
2706  \note the arrays returned by this function corresponds to dynamic memory;
2707  you are responsible for properly freeing such dynamic allocation in
2708  the most appropriate way.
2709 
2710  \note pixels into the returned array will be tightly packed and will be
2711  organized by increasing rows and columns; the first pixel will correspond
2712  to Row=0,Column=0, the second pixel to Row=0,Column=1 and so on.
2713  Pixel components are always organized as RGBRGBRGB....RGB
2714  */
2715     RL2_DECLARE int
2716 	rl2_raster_bands_to_RGB (rl2RasterPtr rst, int bandR, int bandG,
2717 				 int bandB, unsigned char **buffer,
2718 				 int *buf_size);
2719 
2720 /**
2721  Exports a Raster object as an in-memory stored GIF image
2722 
2723  \param rst pointer to the Raster Object.
2724  \param buffer on completion will point to the memory block storing the created GIF image.
2725  \param buf_size on completion the variable referenced by this
2726  pointer will contain the size (in bytes) of the GIF image.
2727 
2728  \return RL2_OK on success: RL2_ERROR on failure.
2729 
2730  \sa rl2_create_raster, rl2_raster_from_gif
2731  */
2732     RL2_DECLARE int
2733 	rl2_raster_to_gif (rl2RasterPtr rst, unsigned char **gif,
2734 			   int *gif_size);
2735 
2736 /**
2737  Allocates and initializes a new Raster object from an in-memory stored GIF image
2738 
2739  \param gif pointer to the memory block storing the input GIF image.
2740  \param gif_size size (in bytes) of the GIF image.
2741 
2742  \return the pointer to newly created Raster Object: NULL on failure.
2743 
2744  \sa rl2_destroy_raster, rl2_create_raster, rl2_raster_to_gif
2745 
2746  \note you are responsible to destroy (before or after) any allocated
2747  Raster object.
2748  */
2749     RL2_DECLARE rl2RasterPtr rl2_raster_from_gif (const unsigned char *gif,
2750 						  int gif_size);
2751 
2752 /**
2753  Exports a Raster object as an in-memory stored PNG image
2754 
2755  \param rst pointer to the Raster Object.
2756  \param buffer on completion will point to the memory block storing the created PNG image.
2757  \param buf_size on completion the variable referenced by this
2758  pointer will contain the size (in bytes) of the PNG image.
2759 
2760  \return RL2_OK on success: RL2_ERROR on failure.
2761 
2762  \sa rl2_create_raster, rl2_raster_from_png
2763  */
2764     RL2_DECLARE int
2765 	rl2_raster_to_png (rl2RasterPtr rst, unsigned char **png,
2766 			   int *png_size);
2767 
2768 /**
2769  Allocates and initializes a new Raster object from an in-memory stored PNG image
2770 
2771  \param png pointer to the memory block storing the input PNG image.
2772  \param png_size size (in bytes) of the PNG image.
2773 
2774  \return the pointer to newly created Raster Object: NULL on failure.
2775 
2776  \sa rl2_destroy_raster, rl2_create_raster, rl2_raster_to_png
2777 
2778  \note you are responsible to destroy (before or after) any allocated
2779  Raster object.
2780  */
2781     RL2_DECLARE rl2RasterPtr rl2_raster_from_png (const unsigned char *png,
2782 						  int png_size);
2783 
2784 /**
2785  Exports a Raster object as an in-memory stored JPEG image
2786 
2787  \param rst pointer to the Raster Object.
2788  \param buffer on completion will point to the memory block storing the created JPEG image.
2789  \param buf_size on completion the variable referenced by this
2790  pointer will contain the size (in bytes) of the JPEG image.
2791  \param quality compression quality factor (0-100)
2792 
2793  \return RL2_OK on success: RL2_ERROR on failure.
2794 
2795  \sa rl2_create_raster, rl2_raster_from_jpeg
2796  */
2797     RL2_DECLARE int
2798 	rl2_raster_to_jpeg (rl2RasterPtr rst, unsigned char **jpeg,
2799 			    int *jpeg_size, int quality);
2800 
2801 /**
2802  Allocates and initializes a new Raster object from an in-memory stored JPEG image
2803 
2804  \param jpeg pointer to the memory block storing the input JPEG image.
2805  \param jpeg_size size (in bytes) of the JPEG image.
2806 
2807  \return the pointer to newly created Raster Object: NULL on failure.
2808 
2809  \sa rl2_destroy_raster, rl2_create_raster, rl2_raster_to_jpeg
2810 
2811  \note you are responsible to destroy (before or after) any allocated
2812  Raster object.
2813  */
2814     RL2_DECLARE rl2RasterPtr
2815 	rl2_raster_from_jpeg (const unsigned char *jpeg, int jpeg_size);
2816 
2817 /**
2818  Exports a Raster object as an in-memory stored WEBP image (lossy compressed)
2819 
2820  \param rst pointer to the Raster Object.
2821  \param buffer on completion will point to the memory block storing the created WEBP image.
2822  \param buf_size on completion the variable referenced by this
2823  pointer will contain the size (in bytes) of the WEBP image.
2824  \param quality compression quality factor (0-100)
2825 
2826  \return RL2_OK on success: RL2_ERROR on failure.
2827 
2828  \sa rl2_create_raster, rl2_raster_from_webp, rl2_raster_to_lossless_webp
2829  */
2830     RL2_DECLARE int
2831 	rl2_raster_to_lossy_webp (rl2RasterPtr rst, unsigned char **webp,
2832 				  int *webp_size, int quality);
2833 
2834 /**
2835  Exports a Raster object as an in-memory stored WEBP image (lossless compressed)
2836 
2837  \param rst pointer to the Raster Object.
2838  \param buffer on completion will point to the memory block storing the created WEBP image.
2839  \param buf_size on completion the variable referenced by this
2840  pointer will contain the size (in bytes) of the WEBP image.
2841 
2842  \return RL2_OK on success: RL2_ERROR on failure.
2843 
2844  \sa rl2_create_raster, rl2_raster_from_webp, rl2_raster_to_lossy_webp
2845  */
2846     RL2_DECLARE int
2847 	rl2_raster_to_lossless_webp (rl2RasterPtr rst, unsigned char **webp,
2848 				     int *webp_size);
2849 
2850 /**
2851  Allocates and initializes a new Raster object from an in-memory stored WEBP image
2852 
2853  \param webp pointer to the memory block storing the input WEBP image.
2854  \param webp_size size (in bytes) of the WEBP image.
2855 
2856  \return the pointer to newly created Raster Object: NULL on failure.
2857 
2858  \sa rl2_destroy_raster, rl2_create_raster, rl2_raster_to_lossy_webp,
2859 	rl2_raster_to_lossless_webp
2860 
2861  \note you are responsible to destroy (before or after) any allocated
2862  Raster object.
2863  */
2864     RL2_DECLARE rl2RasterPtr
2865 	rl2_raster_from_webp (const unsigned char *webp, int webp_size);
2866 
2867 /**
2868  Allocates and initializes a new Raster object from an in-memory stored TIFF image
2869 
2870  \param webp pointer to the memory block storing the input TIFF image.
2871  \param webp_size size (in bytes) of the WEBP image.
2872 
2873  \return the pointer to newly created Raster Object: NULL on failure.
2874 
2875  \sa rl2_destroy_raster, rl2_create_raster
2876 
2877  \note you are responsible to destroy (before or after) any allocated
2878  Raster object. Not all TIFF images are supported, but only the ones
2879  actually corresponding to a visible image (RGB, Grayscale, Palette
2880  and Monochrome).
2881  */
2882     RL2_DECLARE rl2RasterPtr
2883 	rl2_raster_from_tiff (const unsigned char *tiff, int tiff_size);
2884 
2885     RL2_DECLARE rl2PalettePtr rl2_get_raster_palette (rl2RasterPtr raster);
2886 
2887     RL2_DECLARE rl2PalettePtr rl2_clone_palette (rl2PalettePtr palette);
2888 
2889     RL2_DECLARE rl2CoveragePtr
2890 	rl2_create_coverage_from_dbms (sqlite3 * handle, const char *coverage);
2891 
2892     RL2_DECLARE int
2893 	rl2_find_matching_resolution (sqlite3 * handle, rl2CoveragePtr cvg,
2894 				      double *x_res, double *y_res,
2895 				      unsigned char *level,
2896 				      unsigned char *scale);
2897 
2898     RL2_DECLARE int
2899 	rl2_get_raw_raster_data (sqlite3 * handle, rl2CoveragePtr cvg,
2900 				 unsigned int width, unsigned int height,
2901 				 double minx, double miny, double maxx,
2902 				 double maxy, double x_res, double y_res,
2903 				 unsigned char **buffer, int *buf_size,
2904 				 rl2PalettePtr * palette,
2905 				 unsigned char out_pixel);
2906 
2907     RL2_DECLARE int
2908 	rl2_get_triple_band_raw_raster_data (sqlite3 * handle,
2909 					     rl2CoveragePtr cvg,
2910 					     unsigned int width,
2911 					     unsigned int height,
2912 					     double minx, double miny,
2913 					     double maxx, double maxy,
2914 					     double x_res, double y_res,
2915 					     unsigned char red_band,
2916 					     unsigned char green_band,
2917 					     unsigned char blue_band,
2918 					     unsigned char **buffer,
2919 					     int *buf_size,
2920 					     rl2PixelPtr no_data);
2921 
2922     RL2_DECLARE int
2923 	rl2_get_mono_band_raw_raster_data (sqlite3 * handle,
2924 					   rl2CoveragePtr cvg,
2925 					   unsigned int width,
2926 					   unsigned int height,
2927 					   double minx, double miny,
2928 					   double maxx, double maxy,
2929 					   double x_res, double y_res,
2930 					   unsigned char mono_band,
2931 					   unsigned char **buffer,
2932 					   int *buf_size, rl2PixelPtr no_data);
2933 
2934     RL2_DECLARE int
2935 	rl2_get_raw_raster_data_bgcolor (sqlite3 * handle, rl2CoveragePtr cvg,
2936 					 unsigned int width,
2937 					 unsigned int height, double minx,
2938 					 double miny, double maxx, double maxy,
2939 					 double x_res, double y_res,
2940 					 unsigned char **buffer, int *buf_size,
2941 					 rl2PalettePtr * palette,
2942 					 unsigned char *out_pixel,
2943 					 unsigned char bg_red,
2944 					 unsigned char bg_green,
2945 					 unsigned char bg_blue,
2946 					 rl2RasterStylePtr style,
2947 					 rl2RasterStatisticsPtr stats);
2948 
2949     RL2_DECLARE int
2950 	rl2_create_dbms_coverage (sqlite3 * handle, const char *coverage,
2951 				  unsigned char sample, unsigned char pixel,
2952 				  unsigned char num_bands,
2953 				  unsigned char compression, int quality,
2954 				  unsigned int tile_width,
2955 				  unsigned int tile_height, int srid,
2956 				  double x_res, double y_res,
2957 				  rl2PixelPtr no_data, rl2PalettePtr palette);
2958 
2959     RL2_DECLARE int
2960 	rl2_delete_dbms_section (sqlite3 * handle, const char *coverage,
2961 				 sqlite3_int64 section_id);
2962 
2963     RL2_DECLARE int
2964 	rl2_get_dbms_section_id (sqlite3 * handle, const char *coverage,
2965 				 const char *section,
2966 				 sqlite3_int64 * section_id);
2967 
2968     RL2_DECLARE int
2969 	rl2_drop_dbms_coverage (sqlite3 * handle, const char *coverage);
2970 
2971     RL2_DECLARE int
2972 	rl2_update_dbms_coverage (sqlite3 * handle, const char *coverage);
2973 
2974     RL2_DECLARE int
2975 	rl2_serialize_dbms_palette (rl2PalettePtr palette, unsigned char **blob,
2976 				    int *blob_size);
2977 
2978     RL2_DECLARE int
2979 	rl2_is_valid_dbms_palette (const unsigned char *blob, int blob_size,
2980 				   unsigned char sample_type);
2981 
2982     RL2_DECLARE rl2PalettePtr
2983 	rl2_deserialize_dbms_palette (const unsigned char *blob, int blob_size);
2984 
2985     RL2_DECLARE rl2PalettePtr
2986 	rl2_get_dbms_palette (sqlite3 * handle, const char *coverage);
2987 
2988     RL2_DECLARE int
2989 	rl2_update_dbms_palette (sqlite3 * handle, const char *coverage,
2990 				 rl2PalettePtr palette);
2991 
2992     RL2_DECLARE int
2993 	rl2_compare_palettes (rl2PalettePtr palette_1, rl2PalettePtr palette_2);
2994 
2995     RL2_DECLARE int
2996 	rl2_check_dbms_palette (sqlite3 * handle, rl2CoveragePtr cvg,
2997 				rl2TiffOriginPtr tiff);
2998 
2999     RL2_DECLARE int
3000 	rl2_serialize_dbms_pixel (rl2PixelPtr pixel, unsigned char **blob,
3001 				  int *blob_size);
3002 
3003     RL2_DECLARE int
3004 	rl2_is_valid_dbms_pixel (const unsigned char *blob, int blob_size,
3005 				 unsigned char sample_type,
3006 				 unsigned char num_bands);
3007 
3008     RL2_DECLARE rl2PixelPtr
3009 	rl2_deserialize_dbms_pixel (const unsigned char *blob, int blob_size);
3010 
3011     RL2_DECLARE rl2AsciiGridOriginPtr rl2_create_ascii_grid_origin (const char
3012 								    *path,
3013 								    int srid,
3014 								    unsigned
3015 								    char
3016 								    sample_type);
3017 
3018     RL2_DECLARE void rl2_destroy_ascii_grid_origin (rl2AsciiGridOriginPtr
3019 						    ascii);
3020 
3021     RL2_DECLARE int
3022 	rl2_eval_ascii_grid_origin_compatibility (rl2CoveragePtr cvg,
3023 						  rl2AsciiGridOriginPtr ascii);
3024 
3025     RL2_DECLARE const char
3026 	*rl2_get_ascii_grid_origin_path (rl2AsciiGridOriginPtr ascii);
3027 
3028     RL2_DECLARE int
3029 	rl2_get_ascii_grid_origin_size (rl2AsciiGridOriginPtr ascii,
3030 					unsigned int *width,
3031 					unsigned int *height);
3032 
3033     RL2_DECLARE int
3034 	rl2_get_ascii_grid_origin_type (rl2AsciiGridOriginPtr ascii,
3035 					unsigned char *sample_type,
3036 					unsigned char *pixel_type,
3037 					unsigned char *num_bands);
3038 
3039     RL2_DECLARE int rl2_get_ascii_grid_origin_srid (rl2AsciiGridOriginPtr ascii,
3040 						    int *srid);
3041 
3042     RL2_DECLARE int rl2_get_ascii_grid_origin_resolution (rl2AsciiGridOriginPtr
3043 							  ascii,
3044 							  double *res_horz,
3045 							  double *res_vert);
3046 
3047     RL2_DECLARE int
3048 	rl2_get_ascii_grid_origin_extent (rl2AsciiGridOriginPtr ascii,
3049 					  double *minX, double *minY,
3050 					  double *maxX, double *maxY);
3051 
3052     RL2_DECLARE int
3053 	rl2_get_ascii_origin_resolution (rl2AsciiGridOriginPtr ascii,
3054 					 double *hResolution,
3055 					 double *vResolution);
3056 
3057     RL2_DECLARE rl2RasterPtr
3058 	rl2_get_tile_from_ascii_grid_origin (rl2CoveragePtr cvg,
3059 					     rl2AsciiGridOriginPtr ascii,
3060 					     unsigned int startRow,
3061 					     unsigned int startCol);
3062 
3063     RL2_DECLARE rl2AsciiGridDestinationPtr
3064 	rl2_create_ascii_grid_destination (const char *path,
3065 					   unsigned int width,
3066 					   unsigned int height,
3067 					   double resolution, double x,
3068 					   double y, int is_centered,
3069 					   double no_data, int decimal_digits,
3070 					   void *pixels, int pixels_size,
3071 					   unsigned char sample_type);
3072 
3073     RL2_DECLARE void
3074 	rl2_destroy_ascii_grid_destination (rl2AsciiGridDestinationPtr ascii);
3075 
3076     RL2_DECLARE const char
3077 	*rl2_get_ascii_grid_destination_path (rl2AsciiGridDestinationPtr ascii);
3078 
3079     RL2_DECLARE int
3080 	rl2_get_ascii_grid_destination_size (rl2AsciiGridDestinationPtr ascii,
3081 					     unsigned int *width,
3082 					     unsigned int *height);
3083 
3084     RL2_DECLARE int
3085 	rl2_get_ascii_grid_destination_type (rl2AsciiGridDestinationPtr ascii,
3086 					     unsigned char *sample_type,
3087 					     unsigned char *pixel_type,
3088 					     unsigned char *num_bands);
3089 
3090     RL2_DECLARE int
3091 	rl2_get_ascii_grid_destination_tiepoint (rl2AsciiGridDestinationPtr
3092 						 ascii, double *X, double *Y);
3093 
3094     RL2_DECLARE int
3095 	rl2_get_ascii_grid_destination_resolution (rl2AsciiGridDestinationPtr
3096 						   ascii, double *resolution);
3097 
3098     RL2_DECLARE int
3099 	rl2_write_ascii_grid_header (rl2AsciiGridDestinationPtr ascii);
3100 
3101     RL2_DECLARE int
3102 	rl2_write_ascii_grid_scanline (rl2AsciiGridDestinationPtr ascii,
3103 				       unsigned int *line_no);
3104 
3105     RL2_DECLARE rl2RasterPtr
3106 	rl2_get_tile_from_jpeg_origin (rl2CoveragePtr cvg, rl2RasterPtr rst,
3107 				       unsigned int startRow,
3108 				       unsigned int startCol,
3109 				       unsigned char forced_conversion);
3110 
3111     RL2_DECLARE int
3112 	rl2_load_raster_into_dbms (sqlite3 * handle, const char *src_path,
3113 				   rl2CoveragePtr coverage, int worldfile,
3114 				   int force_srid, int pyramidize);
3115 
3116     RL2_DECLARE int
3117 	rl2_load_mrasters_into_dbms (sqlite3 * handle, const char *dir_path,
3118 				     const char *file_ext,
3119 				     rl2CoveragePtr coverage, int worldfile,
3120 				     int force_srid, int pyramidize);
3121 
3122     RL2_DECLARE int
3123 	rl2_export_geotiff_from_dbms (sqlite3 * handle, const char *dst_path,
3124 				      rl2CoveragePtr coverage, double x_res,
3125 				      double y_res, double minx, double miny,
3126 				      double maxx, double maxy,
3127 				      unsigned int width,
3128 				      unsigned int height,
3129 				      unsigned char compression,
3130 				      unsigned int tile_sz, int with_worldfile);
3131 
3132     RL2_DECLARE int
3133 	rl2_export_tiff_worldfile_from_dbms (sqlite3 * handle,
3134 					     const char *dst_path,
3135 					     rl2CoveragePtr coverage,
3136 					     double x_res, double y_res,
3137 					     double minx, double miny,
3138 					     double maxx, double maxy,
3139 					     unsigned int width,
3140 					     unsigned int height,
3141 					     unsigned char compression,
3142 					     unsigned int tile_sz);
3143 
3144     RL2_DECLARE int
3145 	rl2_export_tiff_from_dbms (sqlite3 * handle, const char *dst_path,
3146 				   rl2CoveragePtr coverage, double x_res,
3147 				   double y_res, double minx, double miny,
3148 				   double maxx, double maxy,
3149 				   unsigned int width,
3150 				   unsigned int height,
3151 				   unsigned char compression,
3152 				   unsigned int tile_sz);
3153 
3154     RL2_DECLARE int
3155 	rl2_export_triple_band_geotiff_from_dbms (sqlite3 * handle,
3156 						  const char *dst_path,
3157 						  rl2CoveragePtr coverage,
3158 						  double x_res, double y_res,
3159 						  double minx, double miny,
3160 						  double maxx, double maxy,
3161 						  unsigned int width,
3162 						  unsigned int height,
3163 						  unsigned char red_band,
3164 						  unsigned char green_band,
3165 						  unsigned char blue_band,
3166 						  unsigned char compression,
3167 						  unsigned int tile_sz,
3168 						  int with_worldfile);
3169 
3170     RL2_DECLARE int
3171 	rl2_export_mono_band_geotiff_from_dbms (sqlite3 * handle,
3172 						const char *dst_path,
3173 						rl2CoveragePtr coverage,
3174 						double x_res, double y_res,
3175 						double minx, double miny,
3176 						double maxx, double maxy,
3177 						unsigned int width,
3178 						unsigned int height,
3179 						unsigned char mono_band,
3180 						unsigned char compression,
3181 						unsigned int tile_sz,
3182 						int with_worldfile);
3183 
3184     RL2_DECLARE int
3185 	rl2_export_triple_band_tiff_worldfile_from_dbms (sqlite3 * handle,
3186 							 const char *dst_path,
3187 							 rl2CoveragePtr
3188 							 coverage,
3189 							 double x_res,
3190 							 double y_res,
3191 							 double minx,
3192 							 double miny,
3193 							 double maxx,
3194 							 double maxy,
3195 							 unsigned int width,
3196 							 unsigned int
3197 							 height,
3198 							 unsigned char
3199 							 red_band,
3200 							 unsigned char
3201 							 green_band,
3202 							 unsigned char
3203 							 blue_band,
3204 							 unsigned char
3205 							 compression,
3206 							 unsigned int tile_sz);
3207 
3208     RL2_DECLARE int
3209 	rl2_export_mono_band_tiff_worldfile_from_dbms (sqlite3 * handle,
3210 						       const char *dst_path,
3211 						       rl2CoveragePtr
3212 						       coverage,
3213 						       double x_res,
3214 						       double y_res,
3215 						       double minx,
3216 						       double miny,
3217 						       double maxx,
3218 						       double maxy,
3219 						       unsigned int width,
3220 						       unsigned int
3221 						       height,
3222 						       unsigned char
3223 						       mono_band,
3224 						       unsigned char
3225 						       compression,
3226 						       unsigned int tile_sz);
3227 
3228     RL2_DECLARE int
3229 	rl2_export_triple_band_tiff_from_dbms (sqlite3 * handle,
3230 					       const char *dst_path,
3231 					       rl2CoveragePtr coverage,
3232 					       double x_res, double y_res,
3233 					       double minx, double miny,
3234 					       double maxx, double maxy,
3235 					       unsigned int width,
3236 					       unsigned int height,
3237 					       unsigned char red_band,
3238 					       unsigned char green_band,
3239 					       unsigned char blue_band,
3240 					       unsigned char compression,
3241 					       unsigned int tile_sz);
3242 
3243     RL2_DECLARE int
3244 	rl2_export_mono_band_tiff_from_dbms (sqlite3 * handle,
3245 					     const char *dst_path,
3246 					     rl2CoveragePtr coverage,
3247 					     double x_res, double y_res,
3248 					     double minx, double miny,
3249 					     double maxx, double maxy,
3250 					     unsigned int width,
3251 					     unsigned int height,
3252 					     unsigned char mono_band,
3253 					     unsigned char compression,
3254 					     unsigned int tile_sz);
3255 
3256     RL2_DECLARE int
3257 	rl2_export_ascii_grid_from_dbms (sqlite3 * handle, const char *dst_path,
3258 					 rl2CoveragePtr coverage, double res,
3259 					 double minx, double miny, double maxx,
3260 					 double maxy, unsigned int width,
3261 					 unsigned int height, int is_centered,
3262 					 int decimal_digits);
3263 
3264     RL2_DECLARE int
3265 	rl2_export_jpeg_from_dbms (sqlite3 * handle, const char *dst_path,
3266 				   rl2CoveragePtr coverage, double x_res,
3267 				   double y_res, double minx, double miny,
3268 				   double maxx, double maxy,
3269 				   unsigned int width, unsigned int height,
3270 				   int quality, int with_worldfile);
3271 
3272     RL2_DECLARE int
3273 	rl2_build_section_pyramid (sqlite3 * handle, const char *coverage,
3274 				   const char *section, int forced_rebuild);
3275 
3276     RL2_DECLARE int
3277 	rl2_build_monolithic_pyramid (sqlite3 * handle, const char *coverage,
3278 				      int virtual_levels);
3279 
3280     RL2_DECLARE int
3281 	rl2_build_all_section_pyramids (sqlite3 * handle, const char *coverage,
3282 					int forced_rebuild);
3283 
3284     RL2_DECLARE int
3285 	rl2_delete_section_pyramid (sqlite3 * handle, const char *coverage,
3286 				    const char *section);
3287 
3288     RL2_DECLARE int
3289 	rl2_delete_all_pyramids (sqlite3 * handle, const char *coverage);
3290 
3291 /**
3292  Exports an RGB buffer as an in-memory stored PNG image
3293 
3294  \param width the PNG image width.
3295  \param height the PNG image height.
3296  \param rgb pointer to the RGB buffer.
3297  \param png on completion will point to the memory block storing the created PNG image.
3298  \param png_size on completion the variable referenced by this
3299  pointer will contain the size (in bytes) of the PNG image.
3300 
3301  \return RL2_OK on success: RL2_ERROR on failure.
3302 
3303  \sa rl2_rgb_alpha_to_png, rl2_rgb_to_jpeg, rl2_rgb_to_tiff,
3304  rl2_rgb_to_geotiff, rl2_rgba_to_pdf
3305  */
3306     RL2_DECLARE int
3307 	rl2_rgb_to_png (unsigned int width, unsigned int height,
3308 			const unsigned char *rgb, unsigned char **png,
3309 			int *png_size);
3310 
3311 /**
3312  Exports two separate RGB + Alpha buffers as an in-memory stored PNG image
3313 
3314  \param width the PNG image width.
3315  \param height the PNG image height.
3316  \param rgb pointer to the RGB buffer.
3317  \param alpha pointer to the Alpha channel buffer.
3318  \param png on completion will point to the memory block storing the created PNG image.
3319  \param png_size on completion the variable referenced by this
3320  pointer will contain the size (in bytes) of the PNG image.
3321 
3322  \return RL2_OK on success: RL2_ERROR on failure.
3323 
3324  \sa rl2_rgb_to_png, rl2_rgb_to_jpeg, rl2_rgb_to_tiff, rl2_rgb_to_geotiff
3325  */
3326     RL2_DECLARE int
3327 	rl2_rgb_alpha_to_png (unsigned int width, unsigned int height,
3328 			      const unsigned char *rgb,
3329 			      const unsigned char *alpha, unsigned char **png,
3330 			      int *png_size, double opacity);
3331 
3332 /**
3333  Exports an RGB buffer as an in-memory stored JPEG image
3334 
3335  \param width the JPEG image width.
3336  \param height the JPEG image height.
3337  \param rgb pointer to the RGB buffer.
3338  \param quality compression quality factor (0-100)
3339  \param jpeg on completion will point to the memory block storing the created JPEG image.
3340  \param jpeg_size on completion the variable referenced by this
3341  pointer will contain the size (in bytes) of the JPEG image.
3342 
3343  \return RL2_OK on success: RL2_ERROR on failure.
3344 
3345  \sa rl2_rgb_to_png, rl2_rgb_alpha_to_png, rl2_rgb_to_tiff,
3346  rl2_rgb_to_geotiff, rl2_rgba_to_pdf
3347  */
3348     RL2_DECLARE int
3349 	rl2_rgb_to_jpeg (unsigned int width, unsigned int height,
3350 			 const unsigned char *rgb, int quality,
3351 			 unsigned char **jpeg, int *jpeg_size);
3352 
3353 /**
3354  Exports an RGB buffer as an in-memory stored TIFF image
3355 
3356  \param width the TIFF image width.
3357  \param height the TIFF image height.
3358  \param rgb pointer to the RGB buffer.
3359  \param tiff on completion will point to the memory block storing the created TIFF image.
3360  \param tiff_size on completion the variable referenced by this
3361  pointer will contain the size (in bytes) of the TIFF image.
3362 
3363  \return RL2_OK on success: RL2_ERROR on failure.
3364 
3365  \sa rl2_rgb_to_png, rl2_rgb_alpha_to_png, rl2_rgb_to_jpeg,
3366  rl2_rgb_to_geotiff, rl2_rgba_to_pdf
3367  */
3368     RL2_DECLARE int
3369 	rl2_rgb_to_tiff (unsigned int width, unsigned int height,
3370 			 const unsigned char *rgb, unsigned char **tiff,
3371 			 int *tiff_size);
3372 
3373 /**
3374  Exports an RGB buffer as an in-memory stored GeoTIFF image
3375 
3376  \param width the GeoTIFF image width.
3377  \param height the GeoTIFF image height.
3378  \param minx minimum X coordinate (BBOX - georeferencing).
3379  \param miny minimum Y coordinate (BBOX - georeferencing).
3380  \param maxx maximum X coordinate (BBOX - georeferencing).
3381  \param maxx maximum Y coordinate (BBOX - georeferencing).
3382  \param srid SRID code.
3383  \param rgb pointer to the RGB buffer.
3384  \param geotiff on completion will point to the memory block storing the created GeoTIFF image.
3385  \param geotiff_size on completion the variable referenced by this
3386  pointer will contain the size (in bytes) of the GeoTIFF image.
3387 
3388  \return RL2_OK on success: RL2_ERROR on failure.
3389 
3390  \sa rl2_rgb_to_png, rl2_rgb_alpha_to_png, rl2_rgb_to_jpeg,
3391  rl2_rgb_to_tiff, rl2_rgba_to_pdf
3392  */
3393     RL2_DECLARE int
3394 	rl2_rgb_to_geotiff (unsigned int width, unsigned int height,
3395 			    sqlite3 * handle, double minx, double miny,
3396 			    double maxx, double maxy, int srid,
3397 			    const unsigned char *rgb, unsigned char **geotiff,
3398 			    int *geotiff_size);
3399 
3400 /**
3401  Exports a Grayscale buffer as an in-memory stored PNG image
3402 
3403  \param width the PNG image width.
3404  \param height the PNG image height.
3405  \param gray pointer to the Grayscale buffer.
3406  \param png on completion will point to the memory block storing the created PNG image.
3407  \param png_size on completion the variable referenced by this
3408  pointer will contain the size (in bytes) of the PNG image.
3409 
3410  \return RL2_OK on success: RL2_ERROR on failure.
3411 
3412  \sa rl2_gray_alpha_to_png, rl2_gray_to_jpeg, rl2_gray_to_tiff,
3413  rl2_gray_to_geotiff, rl2_rgba_to_pdf
3414  */
3415     RL2_DECLARE int
3416 	rl2_gray_to_png (unsigned int width, unsigned int height,
3417 			 const unsigned char *gray, unsigned char **png,
3418 			 int *png_size);
3419 
3420 /**
3421  Exports two separate Grayscale + Alpha buffers as an in-memory stored PNG image
3422 
3423  \param width the PNG image width.
3424  \param height the PNG image height.
3425  \param gray pointer to the Grayscale buffer.
3426  \param alpha pointer to the Alpha channel buffer.
3427  \param png on completion will point to the memory block storing the created PNG image.
3428  \param png_size on completion the variable referenced by this
3429  pointer will contain the size (in bytes) of the PNG image.
3430 
3431  \return RL2_OK on success: RL2_ERROR on failure.
3432 
3433  \sa rl2_gray_to_png, rl2_gray_to_jpeg, rl2_gray_to_tiff
3434  rl2_gray_to_geotiff, rl2_rgba_to_pdf
3435  */
3436     RL2_DECLARE int
3437 	rl2_gray_alpha_to_png (unsigned int width, unsigned int height,
3438 			       const unsigned char *gray,
3439 			       const unsigned char *alpha, unsigned char **png,
3440 			       int *png_size, double opacity);
3441 
3442 /**
3443  Exports a Grayscale buffer as an in-memory stored JPEG image
3444 
3445  \param width the JPEG image width.
3446  \param height the JPEG image height.
3447  \param gray pointer to the Grayscale buffer.
3448  \param quality compression quality factor (0-100)
3449  \param jpeg on completion will point to the memory block storing the created JPEG image.
3450  \param jpeg_size on completion the variable referenced by this
3451  pointer will contain the size (in bytes) of the JPEG image.
3452 
3453  \return RL2_OK on success: RL2_ERROR on failure.
3454 
3455  \sa rl2_gray_to_png, rl2_gray_alpha_to_png, rl2_gray_to_tiff
3456  rl2_gray_to_geotiff, rl2_rgba_to_pdf
3457  */
3458     RL2_DECLARE int
3459 	rl2_gray_to_jpeg (unsigned int width, unsigned int height,
3460 			  const unsigned char *gray, int quality,
3461 			  unsigned char **jpeg, int *jpeg_size);
3462 
3463 /**
3464  Exports a Grayscale buffer as an in-memory stored TIFF image
3465 
3466  \param width the TIFF image width.
3467  \param height the TIFF image height.
3468  \param gray pointer to the Grayscale buffer.
3469  \param tiff on completion will point to the memory block storing the created TIFF image.
3470  \param tiff_size on completion the variable referenced by this
3471  pointer will contain the size (in bytes) of the TIFF image.
3472 
3473  \return RL2_OK on success: RL2_ERROR on failure.
3474 
3475  \sa rl2_gray_to_png, rl2_gray_alpha_to_png, rl2_gray_to_jpeg,
3476  rl2_gray_to_geotiff, rl2_rgba_to_pdf
3477  */
3478     RL2_DECLARE int
3479 	rl2_gray_to_tiff (unsigned int width, unsigned int height,
3480 			  const unsigned char *gray, unsigned char **tiff,
3481 			  int *tiff_size);
3482 
3483 /**
3484  Exports a Grayscale buffer as an in-memory stored GeoTIFF image
3485 
3486  \param width the GeoTIFF image width.
3487  \param height the GeoTIFF image height.
3488  \param minx minimum X coordinate (BBOX - georeferencing).
3489  \param miny minimum Y coordinate (BBOX - georeferencing).
3490  \param maxx maximum X coordinate (BBOX - georeferencing).
3491  \param maxx maximum Y coordinate (BBOX - georeferencing).
3492  \param srid SRID code.
3493  \param gray pointer to the Grayscale buffer.
3494  \param geotiff on completion will point to the memory block storing the created GeoTIFF image.
3495  \param geotiff_size on completion the variable referenced by this
3496  pointer will contain the size (in bytes) of the GeoTIFF image.
3497 
3498  \return RL2_OK on success: RL2_ERROR on failure.
3499 
3500  \sa rl2_gray_to_png, rl2_gray_alpha_to_png, rl2_gray_to_jpeg,
3501  rl2_gray_to_tiff, rl2_rgba_to_pdf
3502  */
3503     RL2_DECLARE int
3504 	rl2_gray_to_geotiff (unsigned int width, unsigned int height,
3505 			     sqlite3 * handle, double minx, double miny,
3506 			     double maxx, double maxy, int srid,
3507 			     const unsigned char *gray, unsigned char **geotiff,
3508 			     int *geotiff_size);
3509 
3510 /**
3511  Exports an RGBA buffer as an in-memory stored PDF document
3512 
3513  \param width the PDF image width.
3514  \param height the PDF image height.
3515  \param rgba pointer to the RGBA buffer.
3516  \param pdf on completion will point to the memory block storing the created PDF image.
3517  \param pdf_size on completion the variable referenced by this
3518  pointer will contain the size (in bytes) of the TIFF image.
3519 
3520  \return RL2_OK on success: RL2_ERROR on failure.
3521 
3522  \sa rl2_rgb_to_png, rl2_rgb_alpha_to_png, rl2_rgb_to_jpeg,
3523  rl2_rgb_to_tiff, rl2_rgb_to_geotiff, rl2_gray_to_pdf
3524 
3525  \note ownership of the rgba buffer will be definitely acquired by the
3526  internal PDF writer.
3527  */
3528     RL2_DECLARE int
3529 	rl2_rgba_to_pdf (unsigned int width, unsigned int height,
3530 			 unsigned char *rgba, unsigned char **pdf,
3531 			 int *pdf_size);
3532 
3533 /**
3534  Exports an all-Gray PDF document
3535 
3536  \param width the PDF image width.
3537  \param height the PDF image height.
3538  \param pdf on completion will point to the memory block storing the created PDF document.
3539  \param pdf_size on completion the variable referenced by this
3540  pointer will contain the size (in bytes) of the PDF document.
3541 
3542  \return RL2_OK on success: RL2_ERROR on failure.
3543 
3544  \sa rl2_rl2_rgba_to_pdf
3545  */
3546     RL2_DECLARE int
3547 	rl2_gray_pdf (unsigned int width, unsigned int height,
3548 		      unsigned char **pdf, int *pdf_size);
3549 
3550     RL2_DECLARE int
3551 	rl2_parse_hexrgb (const char *hex, unsigned char *red,
3552 			  unsigned char *green, unsigned char *blue);
3553 
3554     RL2_DECLARE rl2RasterStylePtr
3555 	rl2_create_raster_style_from_dbms (sqlite3 * handle,
3556 					   const char *coverage,
3557 					   const char *style);
3558 
3559     RL2_DECLARE rl2RasterStatisticsPtr
3560 	rl2_create_raster_statistics_from_dbms (sqlite3 * handle,
3561 						const char *coverage);
3562 
3563     RL2_DECLARE void rl2_destroy_raster_style (rl2RasterStylePtr style);
3564 
3565     RL2_DECLARE const char *rl2_get_raster_style_name (rl2RasterStylePtr style);
3566 
3567     RL2_DECLARE const char *rl2_get_raster_style_title (rl2RasterStylePtr
3568 							style);
3569 
3570     RL2_DECLARE const char *rl2_get_raster_style_abstract (rl2RasterStylePtr
3571 							   style);
3572 
3573     RL2_DECLARE int rl2_get_raster_style_opacity (rl2RasterStylePtr style,
3574 						  double *opacity);
3575 
3576     RL2_DECLARE int rl2_is_raster_style_mono_band_selected (rl2RasterStylePtr
3577 							    style,
3578 							    int *selected);
3579 
3580     RL2_DECLARE int rl2_get_raster_style_mono_band_selection (rl2RasterStylePtr
3581 							      style,
3582 							      unsigned char
3583 							      *gray_band);
3584 
3585     RL2_DECLARE int rl2_is_raster_style_triple_band_selected (rl2RasterStylePtr
3586 							      style,
3587 							      int *selected);
3588 
3589     RL2_DECLARE int
3590 	rl2_get_raster_style_triple_band_selection (rl2RasterStylePtr style,
3591 						    unsigned char *red_band,
3592 						    unsigned char *green_band,
3593 						    unsigned char *blue_band);
3594 
3595     RL2_DECLARE int
3596 	rl2_get_raster_style_overall_contrast_enhancement (rl2RasterStylePtr
3597 							   style,
3598 							   unsigned char
3599 							   *contrast_enhancement,
3600 							   double *gamma_value);
3601 
3602     RL2_DECLARE int
3603 	rl2_get_raster_style_red_band_contrast_enhancement (rl2RasterStylePtr
3604 							    style,
3605 							    unsigned char
3606 							    *contrast_enhancement,
3607 							    double
3608 							    *gamma_value);
3609 
3610     RL2_DECLARE int
3611 	rl2_get_raster_style_green_band_contrast_enhancement (rl2RasterStylePtr
3612 							      style,
3613 							      unsigned char
3614 							      *contrast_enhancement,
3615 							      double
3616 							      *gamma_value);
3617 
3618     RL2_DECLARE int
3619 	rl2_get_raster_style_blue_band_contrast_enhancement (rl2RasterStylePtr
3620 							     style,
3621 							     unsigned char
3622 							     *contrast_enhancement,
3623 							     double
3624 							     *gamma_value);
3625 
3626     RL2_DECLARE int
3627 	rl2_get_raster_style_gray_band_contrast_enhancement (rl2RasterStylePtr
3628 							     style,
3629 							     unsigned char
3630 							     *contrast_enhancement,
3631 							     double
3632 							     *gamma_value);
3633 
3634     RL2_DECLARE int
3635 	rl2_has_raster_style_color_map_interpolated (rl2RasterStylePtr style,
3636 						     int *interpolated);
3637 
3638     RL2_DECLARE int
3639 	rl2_has_raster_style_color_map_categorized (rl2RasterStylePtr style,
3640 						    int *categorized);
3641 
3642     RL2_DECLARE int rl2_get_raster_style_color_map_default (rl2RasterStylePtr
3643 							    style,
3644 							    unsigned char *red,
3645 							    unsigned char
3646 							    *green,
3647 							    unsigned char
3648 							    *blue);
3649 
3650     RL2_DECLARE int
3651 	rl2_get_raster_style_color_map_category_base (rl2RasterStylePtr style,
3652 						      unsigned char *red,
3653 						      unsigned char *green,
3654 						      unsigned char *blue);
3655 
3656     RL2_DECLARE int rl2_get_raster_style_color_map_count (rl2RasterStylePtr
3657 							  style, int *count);
3658 
3659     RL2_DECLARE int rl2_get_raster_style_color_map_entry (rl2RasterStylePtr
3660 							  style, int index,
3661 							  double *value,
3662 							  unsigned char *red,
3663 							  unsigned char *green,
3664 							  unsigned char *blue);
3665 
3666     RL2_DECLARE int rl2_has_raster_style_shaded_relief (rl2RasterStylePtr style,
3667 							int *shaded_relief);
3668 
3669     RL2_DECLARE int rl2_get_raster_style_shaded_relief (rl2RasterStylePtr style,
3670 							int *brightness_only,
3671 							double *relief_factor);
3672 
3673     RL2_DECLARE rl2GroupStylePtr
3674 	rl2_create_group_style_from_dbms (sqlite3 * handle, const char *group,
3675 					  const char *style);
3676 
3677     RL2_DECLARE void rl2_destroy_group_style (rl2GroupStylePtr style);
3678 
3679     RL2_DECLARE const char *rl2_get_group_style_name (rl2GroupStylePtr style);
3680 
3681     RL2_DECLARE const char *rl2_get_group_style_title (rl2GroupStylePtr style);
3682 
3683     RL2_DECLARE const char *rl2_get_group_style_abstract (rl2GroupStylePtr
3684 							  style);
3685 
3686     RL2_DECLARE int rl2_is_valid_group_style (rl2GroupStylePtr style,
3687 					      int *valid);
3688 
3689     RL2_DECLARE int rl2_get_group_style_count (rl2GroupStylePtr style,
3690 					       int *count);
3691 
3692     RL2_DECLARE const char *rl2_get_group_named_layer (rl2GroupStylePtr style,
3693 						       int index);
3694 
3695     RL2_DECLARE const char *rl2_get_group_named_style (rl2GroupStylePtr style,
3696 						       int index);
3697 
3698     RL2_DECLARE int rl2_is_valid_group_named_layer (rl2GroupStylePtr style,
3699 						    int index, int *valid);
3700 
3701     RL2_DECLARE int rl2_is_valid_group_named_style (rl2GroupStylePtr style,
3702 						    int index, int *valid);
3703 
3704     RL2_DECLARE rl2GroupRendererPtr rl2_create_group_renderer (sqlite3 * sqlite,
3705 							       rl2GroupStylePtr
3706 							       style);
3707 
3708     RL2_DECLARE void rl2_destroy_group_renderer (rl2GroupRendererPtr group);
3709 
3710 #ifdef __cplusplus
3711 }
3712 #endif
3713 
3714 #endif				/* _RASTERLITE2_H */
3715