The GDAL implementation uses a single data type for all the bands in an output
raster. Therefore, if an output raster's pixel class has different sized
bands, then all the bands are written using the largest data type. For
example, if a pixel has two bands, one that is a short (signed 16-bit integer)
and another that is a float (32-bit single precision), then data for both bands
are written as float values.
For an input raster, each pixel band must have a data type that is equal to or
larger than the type of its corresponding raster band. For example, if the
raster band is a float, then the corresponding pixel band must be either a
float or a double (64-bit). If the pixel band is smaller (e.g., a short), then
an exception occurs.
Consequently, it is not currently possible to open certain rasters for reading
with the same pixel class that was used to write them. It would be much more
useful for developers to be able to do so.
To support this, the restriction on input pixel bands based on their
corresponding raster bands must be lifted. One alternative is to have a type
conversion delegate for each pixel band. The delegate would convert the larger
raster band data into the smaller data type used by the pixel band. For
convenience, the default converters would simply do range checking: if the
raster band data value is within the [min,max] range of the pixel band's data
type, then return the value (possibly rounded if converting a floating point
type to an integer type); otherwise, throw some exception.
A developer could specify an explicit conversion method if she wants some other
action (for example, clipping values outside the pixel band's data type to the
range limits, so as to avoid any exceptions).