Class BitmapFactory
Bitmaps
from encoded data.- Since:
- 3.7
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Collects the options for the decoder and additional outputs from the decoder. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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)
-
Constructor Details
-
BitmapFactory
public BitmapFactory()
-
-
Method Details
-
decodeFile
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 notRGB
, or if the specified color space's transfer function is not anICC parametric curve
, the method throwsIllegalArgumentException
.- Parameters:
file
- the file to be decodedopts
- the decoder options- Returns:
- the decoded bitmap
- Throws:
IllegalArgumentException
- the options are invalidIOException
- 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 decodedopts
- the out values- Throws:
IOException
- the file cannot be decoded into a bitmap
-
decodePath
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 notRGB
, or if the specified color space's transfer function is not anICC parametric curve
, the method throwsIllegalArgumentException
.- Parameters:
path
- the file to be decodedopts
- the decoder options- Returns:
- the decoded bitmap
- Throws:
IllegalArgumentException
- the options are invalidIOException
- 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 decodedopts
- the out values- Throws:
IOException
- the file cannot be decoded into a bitmap
-
decodeStream
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 notRGB
, or if the specified color space's transfer function is not anICC parametric curve
, the method throwsIllegalArgumentException
.- Parameters:
stream
- the input stream to be decodedopts
- the decoder options- Returns:
- the decoded bitmap
- Throws:
IllegalArgumentException
- the options are invalidIOException
- 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 decodedopts
- 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 notRGB
, or if the specified color space's transfer function is not anICC parametric curve
, the method throwsIllegalArgumentException
.- Parameters:
channel
- the readable channel to be decodedopts
- the decoder options- Returns:
- the decoded bitmap
- Throws:
IllegalArgumentException
- the options are invalidIOException
- 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 decodedopts
- 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 dataoffset
- offset into image data for where the decoder should begin parsinglength
- 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 notRGB
, or if the specified color space's transfer function is not anICC parametric curve
, the method throwsIllegalArgumentException
.- Parameters:
data
- byte array of compressed image dataoffset
- offset into image data for where the decoder should begin parsinglength
- the number of bytes, beginning at offset, to parseopts
- the decoder options- Returns:
- the decoded bitmap
- Throws:
IllegalArgumentException
- the options are invalidIOException
- 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
-
filterPIC
-
filterPGM
-
filterPPM
-
filterHDR
-
filterTGA
-