SE_RASTERATTR
raster_attrib;
CLIENT_DATA *client_data;
SE_COMPRESSION_TYPE compression;
CHAR
name[8];
LONG
int_value;
FLOAT
flt_value;
/* Set
the compression type to one of its four possible values: */
/*
lz77, */
/*
jpeg, */
/* jpeg
2000 */
/* or
no compression. */
compression = SE_COMPRESSION_LZ77;
/*
compression = SE_COMPRESSION_JPEG; */
/*
compression = SE_COMPRESSION_JP2; */
/*
compression = SE_COMPRESSION_NONE; */
/*
Initialize the raster attribute structure for input. */
rc =
SE_rasterattr_create (raster_attrib,TRUE);
check_error (rc, NULL, NULL, "SE_rasterattr_create");
/* Set
the compression type on the raster attribute structure data */
rc =
SE_rasterattr_set_compression_type (raster_attrib, compression);
check_error (rc, NULL, NULL, "SE_rasterattr_set_compression_type");
/* If
the compression type is JPEG or JPEG 2000 the compression */
/*
property can also be set */
/* For
JPEG compression the name paramter is always set to "quality" */
/* and
the value can be an integer between 0 and 100 */
if
(compression == SE_COMPRESSION_JPEG)
{
strcpy(name,"quality");
int_value = 50;
rc = SE_rasterattr_set_compression_property (raster_attrib,
name,
&int_value);
check_error (rc, NULL, NULL,
"SE_rasterattr_set_compression_property");
}
/* For
JPEG 2000 compression the name parameter can be set to either */
/*
"quality" to use a variable bitrate algorithm, or "bitrate" to use */
/* a
fixed bitrate compression */
/* Use
a JPEG 2000 variable bitrate compression with a quality set to */
/* 120.
*/
if
(compression == SE_COMPRESSION_JP2)
{
strcpy(name,"quality");
int_value = 120;
rc = SE_rasterattr_set_compression_property (raster_attrib,
name,
&int_value);
check_error (rc, NULL, NULL,
"SE_rasterattr_set_compression_property");
}
/* Use
a JPEG 2000 fixed bitrate compression with a quality set to */
/* 1.6,
which equates to a fixed compression rate of 20 percent for */
/*
8-bit data (8 * 0.20 = 1.6) and 10 percent (16 * 0.10 = 1.6) for */
/* 16
bit data */
if
(compression == SE_COMPRESSION_JP2)
{
strcpy(name,"bitrate");
flt_value = 1.6;
rc = SE_rasterattr_set_compression_property (raster_attrib,
name,
&flt_value);
check_error (rc, NULL, NULL,
"SE_rasterattr_set_compression_property");
}