The mapping between source and destination Y coordinates is given by the equations:
dx = (sx - sourceXOffset)/subsampleX + dstXOffset; dy = (sy - sourceYOffset)/subsampleY + dstYOffset;Note that the mapping from source coordinates to destination coordinates is not one-to-one if subsampling is being used, since only certain source pixels are to be copied to the destination. However, * the inverse mapping is always one-to-one:
sx = (dx - dstXOffset)*subsampleX + sourceXOffset; sy = (dy - dstYOffset)*subsampleY + sourceYOffset;
Decompressors may be written with various levels of complexity. The most complex decompressors will override the decode
method, and will perform all the work of decoding, subsampling, offsetting, clipping, and format conversion. This approach may be the most efficient, since it is possible to avoid the use of extra image buffers, and it may be possible to avoid decoding portions of the image that will not be copied into the destination.
Less ambitious decompressors may override the decodeRaw
method, which is responsible for decompressing the entire tile or strip into a byte array (or other appropriate datatype). The default implementation of decode
will perform all necessary setup of buffers, call decodeRaw
to perform the actual decoding, perform subsampling, and copy the results into the final destination image. Where possible, it will pass the real image buffer to decodeRaw
in order to avoid making an extra copy.
Slightly more ambitious decompressors may override decodeRaw
, but avoid writing pixels that will be discarded in the subsampling phase.
|
|