Package icyllis.modernui.graphics

# Class BitmapFactory

java.lang.Object
icyllis.modernui.graphics.BitmapFactory

public final class BitmapFactory extends Object
Creates `Bitmaps` from encoded data.

Since:
  3.7

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `BitmapFactory.Options`
  Collects the options for the decoder and additional outputs from the decoder.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BitmapFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Bitmap`
  `decodeBuffer(ByteBuffer buffer, BitmapFactory.Options opts)`
  `static void`
  `decodeBufferInfo(ByteBuffer buffer, BitmapFactory.Options opts)`
  `static Bitmap`
  `decodeByteArray(byte[] data, int offset, int length)`
  Decode an immutable bitmap from the specified byte array.
  `static Bitmap`
  `decodeByteArray(byte[] data, int offset, int length, BitmapFactory.Options opts)`
  Decode an immutable bitmap from the specified byte array.
  `static Bitmap`
  `decodeChannel(ReadableByteChannel channel)`
  Decode a readable channel into a bitmap.
  `static Bitmap`
  `decodeChannel(ReadableByteChannel channel, BitmapFactory.Options opts)`
  Decode a readable channel into a bitmap.
  `static void`
  `decodeChannelInfo(ReadableByteChannel channel, BitmapFactory.Options opts)`
  Query the bitmap info from a readable channel, without allocating the memory for its pixels.
  `static Bitmap`
  `decodeFile(File file)`
  Decode a file path into a bitmap.
  `static Bitmap`
  `decodeFile(File file, BitmapFactory.Options opts)`
  Decode a file path into a bitmap.
  `static void`
  `decodeFileInfo(File file, BitmapFactory.Options opts)`
  Query the bitmap info from a file path, without allocating the memory for its pixels.
  `static void`
  `decodeMimeType(BitmapFactory.Options opts, Object input)`
  `static Bitmap`
  `decodePath(Path path)`
  Decode a file path into a bitmap.
  `static Bitmap`
  `decodePath(Path path, BitmapFactory.Options opts)`
  Decode a file path into a bitmap.
  `static void`
  `decodePathInfo(Path path, BitmapFactory.Options opts)`
  Query the bitmap info from a file path, without allocating the memory for its pixels.
  `static Bitmap`
  `decodeStream(InputStream stream)`
  Decode an input stream into a bitmap.
  `static Bitmap`
  `decodeStream(InputStream stream, BitmapFactory.Options opts)`
  Decode an input stream into a bitmap.
  `static void`
  `decodeStreamInfo(InputStream stream, BitmapFactory.Options opts)`
  Query the bitmap info from an input stream, without allocating the memory for its pixels.
  `static boolean`
  `filterHDR(ImageInputStream stream)`
  `static boolean`
  `filterPGM(ImageInputStream stream)`
  `static boolean`
  `filterPIC(ImageInputStream stream)`
  `static boolean`
  `filterPPM(ImageInputStream stream)`
  `static boolean`
  `filterPSD(ImageInputStream stream)`
  `static boolean`
  `filterTGA(ImageInputStream stream)`
  `static boolean`
  `test(ImageInputStream stream, Predicate<ImageInputStream> filter)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BitmapFactory

    public BitmapFactory()

- ## Method Details

  - ### decodeFile

    @NonNull public static Bitmap decodeFile(@NonNull File file) throws IOException
    Decode a file path into a bitmap.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `file` - the file to be decoded
    Returns:
      the decoded bitmap
    Throws:
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodeFile

    @NonNull public static Bitmap decodeFile(@NonNull File file, @Nullable BitmapFactory.Options opts) throws IOException
    Decode a file path into a bitmap.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway. If the specified color space is not `RGB`, or if the specified color space's transfer function is not an `ICC parametric curve`, the method throws `IllegalArgumentException`.

    Parameters:
      `file` - the file to be decoded
      `opts` - the decoder options
    Returns:
      the decoded bitmap
    Throws:
      `IllegalArgumentException` - the options are invalid
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodeFileInfo

    public static void decodeFileInfo(@NonNull File file, @NonNull BitmapFactory.Options opts) throws IOException
    Query the bitmap info from a file path, without allocating the memory for its pixels.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `file` - the file to be decoded
      `opts` - the out values
    Throws:
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodePath

    @NonNull public static Bitmap decodePath(@NonNull Path path) throws IOException
    Decode a file path into a bitmap.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `path` - the file to be decoded
    Returns:
      the decoded bitmap
    Throws:
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodePath

    @NonNull public static Bitmap decodePath(@NonNull Path path, @Nullable BitmapFactory.Options opts) throws IOException
    Decode a file path into a bitmap.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway. If the specified color space is not `RGB`, or if the specified color space's transfer function is not an `ICC parametric curve`, the method throws `IllegalArgumentException`.

    Parameters:
      `path` - the file to be decoded
      `opts` - the decoder options
    Returns:
      the decoded bitmap
    Throws:
      `IllegalArgumentException` - the options are invalid
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodePathInfo

    public static void decodePathInfo(@NonNull Path path, @NonNull BitmapFactory.Options opts) throws IOException
    Query the bitmap info from a file path, without allocating the memory for its pixels.

    If the file cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `path` - the file to be decoded
      `opts` - the out values
    Throws:
      `IOException` - the file cannot be decoded into a bitmap

  - ### decodeStream

    @NonNull public static Bitmap decodeStream(@NonNull InputStream stream) throws IOException
    Decode an input stream into a bitmap.

    The stream's position will be at the end of the encoded data. This method does not closed the given stream after read operation has completed.

    If the stream cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `stream` - the input stream to be decoded
    Returns:
      the decoded bitmap
    Throws:
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeStream

    @NonNull public static Bitmap decodeStream(@NonNull InputStream stream, @Nullable BitmapFactory.Options opts) throws IOException
    Decode an input stream into a bitmap.

    The stream's position will be at the end of the encoded data. This method does not closed the given stream after read operation has completed.

    If the stream cannot be decoded into a bitmap, the method throws `IOException` on the halfway. If the specified color space is not `RGB`, or if the specified color space's transfer function is not an `ICC parametric curve`, the method throws `IllegalArgumentException`.

    Parameters:
      `stream` - the input stream to be decoded
      `opts` - the decoder options
    Returns:
      the decoded bitmap
    Throws:
      `IllegalArgumentException` - the options are invalid
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeStreamInfo

    public static void decodeStreamInfo(@NonNull InputStream stream, @NonNull BitmapFactory.Options opts) throws IOException
    Query the bitmap info from an input stream, without allocating the memory for its pixels.

    If the stream cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `stream` - the input stream to be decoded
      `opts` - the out values
    Throws:
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeChannel

    @NonNull public static Bitmap decodeChannel(@NonNull ReadableByteChannel channel) throws IOException
    Decode a readable channel into a bitmap.

    The channel's position will be at the end of the encoded data. This method does not closed the given channel after read operation has completed.

    If the channel cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `channel` - the readable channel to be decoded
    Returns:
      the decoded bitmap
    Throws:
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeChannel

    @NonNull public static Bitmap decodeChannel(@NonNull ReadableByteChannel channel, @Nullable BitmapFactory.Options opts) throws IOException
    Decode a readable channel into a bitmap.

    The channel's position will be at the end of the encoded data. This method does not closed the given channel after read operation has completed.

    If the channel cannot be decoded into a bitmap, the method throws `IOException` on the halfway. If the specified color space is not `RGB`, or if the specified color space's transfer function is not an `ICC parametric curve`, the method throws `IllegalArgumentException`.

    Parameters:
      `channel` - the readable channel to be decoded
      `opts` - the decoder options
    Returns:
      the decoded bitmap
    Throws:
      `IllegalArgumentException` - the options are invalid
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeChannelInfo

    public static void decodeChannelInfo(@NonNull ReadableByteChannel channel, @NonNull BitmapFactory.Options opts) throws IOException
    Query the bitmap info from a readable channel, without allocating the memory for its pixels.

    If the channel cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `channel` - the readable channel to be decoded
      `opts` - the out values
    Throws:
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeByteArray

    @NonNull public static Bitmap decodeByteArray(byte[] data, int offset, int length) throws IOException
    Decode an immutable bitmap from the specified byte array.

    If the data cannot be decoded into a bitmap, the method throws `IOException` on the halfway.

    Parameters:
      `data` - byte array of compressed image data
      `offset` - offset into image data for where the decoder should begin parsing
      `length` - the number of bytes, beginning at offset, to parse
    Returns:
      the decoded bitmap
    Throws:
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeByteArray

    @NonNull public static Bitmap decodeByteArray(byte[] data, int offset, int length, @Nullable BitmapFactory.Options opts) throws IOException
    Decode an immutable bitmap from the specified byte array.

    If the data cannot be decoded into a bitmap, the method throws `IOException` on the halfway. If the specified color space is not `RGB`, or if the specified color space's transfer function is not an `ICC parametric curve`, the method throws `IllegalArgumentException`.

    Parameters:
      `data` - byte array of compressed image data
      `offset` - offset into image data for where the decoder should begin parsing
      `length` - the number of bytes, beginning at offset, to parse
      `opts` - the decoder options
    Returns:
      the decoded bitmap
    Throws:
      `IllegalArgumentException` - the options are invalid
      `IOException` - the data cannot be decoded into a bitmap

  - ### decodeBuffer

    @Internal @NonNull public static Bitmap decodeBuffer(@NonNull ByteBuffer buffer, @Nullable BitmapFactory.Options opts) throws IOException
    Throws:
      `IOException`

  - ### decodeBufferInfo

    @Internal public static void decodeBufferInfo(@NonNull ByteBuffer buffer, @NonNull BitmapFactory.Options opts) throws IOException
    Throws:
      `IOException`

  - ### decodeMimeType

    @Internal public static void decodeMimeType(@NonNull BitmapFactory.Options opts, @NonNull Object input)

  - ### test

    @Internal public static boolean test(@NonNull ImageInputStream stream, @NonNull Predicate<ImageInputStream> filter)

  - ### filterPSD

    @Internal public static boolean filterPSD(@NonNull ImageInputStream stream)

  - ### filterPIC

    public static boolean filterPIC(@NonNull ImageInputStream stream)

  - ### filterPGM

    @Internal public static boolean filterPGM(@NonNull ImageInputStream stream)

  - ### filterPPM

    @Internal public static boolean filterPPM(@NonNull ImageInputStream stream)

  - ### filterHDR

    @Internal public static boolean filterHDR(@NonNull ImageInputStream stream)

  - ### filterTGA

    @Internal public static boolean filterTGA(@NonNull ImageInputStream stream)