|
Purpose
|
Set the type of compression to use when writing the next 24-bit raster image. |
|
Return value
|
Returns SUCCEED (or 0) if successful and FAIL (or -1) otherwise. |
|
Description
|
This routines provides a method for compressing the next raster image written. The type can be one of the following values: COMP_NONE, COMP_JPEG, COMP_RLE, COMP_IMCOMP, COMP_NONE is the default for storing images if this routine is not called, therefore images are not compressed by default. COMP_JPEG compresses images with a JPEG algorithm, which is a lossy method. COMP_RLE uses lossless run-length encoding to store the image. COMP_IMCOMP uses a lossy compression algorithm called IMCOMP, and is included for backward compatibility only. |
|
|
The comp_info union contains algorithm-specific information for the library routines that perform the compression and is defined in the hcomp.h header file as follows: |
|
| typedef union tag_comp_info
{
struct
{
intn quality;
intn force_baseline;
} jpeg;
struct
{
int32 nt;
intn sign_ext;
intn fill_one;
intn start_bit;
intn bit_len;
} nbit;
struct
{
intn skp_size;
} skphuff;
struct
{
intn level;
} deflate;
}
comp_info
|
|
|
This union is defined to provide future expansion, but is currently only used by the COMP_JPEG compression type. A pointer to a valid comp_info union is required for all compression types other than COMP_JPEG, but the values in the union are not used. The comp_info union is declared in the header file hdf.h and is shown here for informative purposes only, it should not be re-declared in a user program. |
|
|
For COMP_JPEG compression, the quality member of the jpeg structure must be set to the quality of the stored image. This number can vary from 100, the best quality, to 0, terrible quality. All images stored with COMP_JPEG compression are stored in a lossy manner, even images stored with a quality of 100. The ratio of size to perceived image quality varies from image to image, some experimentation may be required to determine an acceptable quality factor for a given application. The force_baseline parameter determines whether the quantization tables used during compression are forced to the range 0-255. The force_baseline parameter should normally be set to 1 (forcing baseline results), unless special applications require non-baseline images to be used. |
|
|
If the compression type is JPEG, d2scomp defines the default JPEG compression parameters to be used. If these parameters must be changed later, the d2sjpeg routine must be used. (See the Reference Manual entry for d2sjpeg) |