Class BitmapFactory
Bitmaps from encoded data.- Since:
- 3.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCollects the options for the decoder and additional outputs from the decoder. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BitmapdecodeBuffer(ByteBuffer buffer, BitmapFactory.Options opts) static voiddecodeBufferInfo(ByteBuffer buffer, BitmapFactory.Options opts) static BitmapdecodeByteArray(byte[] data, int offset, int length) Decode an immutable bitmap from the specified byte array.static BitmapdecodeByteArray(byte[] data, int offset, int length, BitmapFactory.Options opts) Decode an immutable bitmap from the specified byte array.static BitmapdecodeChannel(ReadableByteChannel channel) Decode a readable channel into a bitmap.static BitmapdecodeChannel(ReadableByteChannel channel, BitmapFactory.Options opts) Decode a readable channel into a bitmap.static voiddecodeChannelInfo(ReadableByteChannel channel, BitmapFactory.Options opts) Query the bitmap info from a readable channel, without allocating the memory for its pixels.static BitmapdecodeFile(File file) Decode a file path into a bitmap.static BitmapdecodeFile(File file, BitmapFactory.Options opts) Decode a file path into a bitmap.static voiddecodeFileInfo(File file, BitmapFactory.Options opts) Query the bitmap info from a file path, without allocating the memory for its pixels.static voiddecodeMimeType(BitmapFactory.Options opts, Object input) static BitmapdecodePath(Path path) Decode a file path into a bitmap.static BitmapdecodePath(Path path, BitmapFactory.Options opts) Decode a file path into a bitmap.static voiddecodePathInfo(Path path, BitmapFactory.Options opts) Query the bitmap info from a file path, without allocating the memory for its pixels.static BitmapdecodeStream(InputStream stream) Decode an input stream into a bitmap.static BitmapdecodeStream(InputStream stream, BitmapFactory.Options opts) Decode an input stream into a bitmap.static voiddecodeStreamInfo(InputStream stream, BitmapFactory.Options opts) Query the bitmap info from an input stream, without allocating the memory for its pixels.static booleanfilterHDR(ImageInputStream stream) static booleanfilterPGM(ImageInputStream stream) static booleanfilterPIC(ImageInputStream stream) static booleanfilterPPM(ImageInputStream stream) static booleanfilterPSD(ImageInputStream stream) static booleanfilterTGA(ImageInputStream stream) static booleantest(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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
IOExceptionon 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
-