Interface SamplerConverter<A,​B>

  • Type Parameters:
    A - The type of values accessed by the Sampler.
    B - The type of the value returned by this SamplerConverter.
    All Known Implementing Classes:
    ARGBChannelSamplerConverter, CompositeARGBSamplerConverter, RealDoubleSamplerConverter, RealFloatSamplerConverter

    public interface SamplerConverter<A,​B>
    This interface converts a Sampler<A> into an instance of B, where A and B are typically Types.

    Its intended use is to create objects that wrap the provided Sampler itself instead of wrapping values obtained through the Sampler. In other words, if the Sampler is pointed at a different object, existing objects returned by this SamplerConverter should point at it as well.

    SamplerConverters are used in Converters to create on-the-fly converted images that are both readable and writable. For example, consider accessing a channel of an ARGBType image as UnsignedByteType. The converted image needs to provide converted samplers (e.g., RandomAccess<UnsignedByteType>) that "translate" to the samplers of the original image (e.g., RandomAccess<ARGBType>).

    The converted Sampler returns an UnsignedByteType instance on get(). If .setByte(10) is called on that UnsignedByteType instance, that must be translated back to the underlying ARGBType. To achieve this, SamplerConverter.convert(...) creates a special UnsignedByteType instance which knows about a specific source sampler (e.g., RandomAccess<ARGBType>). When the UnsignedByteType instance is written to (or read from), it gets the current ARGBType from the source sampler and performs the conversion.

    • Method Detail

      • convert

        B convert​(Sampler<? extends A> sampler)