Package 

Class ImageSource

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public class ImageSource
     implements Closeable
                        

    Provides access to the image data to be decoded.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public abstract class ImageSource.Metadata

      A marker class for metadata for an ImageSource.

      Heavily prefer using source or file to decode the image's data instead of relying on information provided in the metadata. It's the responsibility of a Fetcher to create a BufferedSource or File that can be easily read irrespective of where the image data is located. A Decoder should be as decoupled as possible from where the image is being fetched from.

      This method is provided as a way to pass information to decoders that don't support decoding a BufferedSource and want to avoid creating a temporary file (e.g. ImageDecoder, MediaMetadataRetriever, etc.).

    • Method Summary

      Modifier and Type Method Description
      abstract FileSystem getFileSystem() The FileSystem which contains the file.
      abstract ImageSource.Metadata getMetadata() Return the Metadata for this ImageSource.
      abstract BufferedSource source() Return a BufferedSource to read this ImageSource.
      abstract BufferedSource sourceOrNull() Return the BufferedSource to read this ImageSource if one has already been created.
      abstract Path file() Return a Path that resolves to a file containing this ImageSource's data.
      abstract Path fileOrNull() Return a Path that resolves to a file containing this ImageSource's data if one has already been created.
      • Methods inherited from class coil.decode.ImageSource

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getFileSystem

         abstract FileSystem getFileSystem()

        The FileSystem which contains the file.

      • source

         abstract BufferedSource source()

        Return a BufferedSource to read this ImageSource.

      • sourceOrNull

         abstract BufferedSource sourceOrNull()

        Return the BufferedSource to read this ImageSource if one has already been created. Else, return 'null'.

      • file

         abstract Path file()

        Return a Path that resolves to a file containing this ImageSource's data.

        If this image source is backed by a BufferedSource, a temporary file containing this ImageSource's data will be created.

      • fileOrNull

         abstract Path fileOrNull()

        Return a Path that resolves to a file containing this ImageSource's data if one has already been created. Else, return 'null'.