BitmapFactory
open class BitmapFactory
Creates Bitmap objects from various sources, including files, streams, and byte-arrays.
Summary
Public constructors
BitmapFactory
BitmapFactory()
Public methods
decodeByteArray
open static fun decodeByteArray(
data: ByteArray!,
offset: Int,
length: Int,
opts: BitmapFactory.Options!
): Bitmap!
Decode an immutable bitmap from the specified byte array.
Parameters |
data |
ByteArray!: byte array of compressed image data |
offset |
Int: offset into imageData for where the decoder should begin parsing. |
length |
Int: the number of bytes, beginning at offset, to parse |
opts |
BitmapFactory.Options!: null-ok; Options that control downsampling and whether the image should be completely decoded, or just is size returned. |
Return |
Bitmap! |
The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight) |
decodeByteArray
open static fun decodeByteArray(
data: ByteArray!,
offset: Int,
length: Int
): Bitmap!
Decode an immutable bitmap from the specified byte array.
Parameters |
data |
ByteArray!: byte array of compressed image data |
offset |
Int: offset into imageData for where the decoder should begin parsing. |
length |
Int: the number of bytes, beginning at offset, to parse |
Return |
Bitmap! |
The decoded bitmap, or null if the image could not be decoded. |
decodeFile
open static fun decodeFile(
pathName: String!,
opts: BitmapFactory.Options!
): Bitmap!
Decode a file path into a bitmap. If the specified file name is null, or cannot be decoded into a bitmap, the function returns null.
Parameters |
pathName |
String!: complete path name for the file to be decoded. |
opts |
BitmapFactory.Options!: null-ok; Options that control downsampling and whether the image should be completely decoded, or just is size returned. |
Return |
Bitmap! |
The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight) |
decodeFile
open static fun decodeFile(pathName: String!): Bitmap!
Decode a file path into a bitmap. If the specified file name is null, or cannot be decoded into a bitmap, the function returns null.
Parameters |
pathName |
String!: complete path name for the file to be decoded. |
Return |
Bitmap! |
the resulting decoded bitmap, or null if it could not be decoded. |
decodeFileDescriptor
open static fun decodeFileDescriptor(
fd: FileDescriptor!,
outPadding: Rect!,
opts: BitmapFactory.Options!
): Bitmap!
Decode a bitmap from the file descriptor. If the bitmap cannot be decoded return null. The position within the descriptor will not be changed when this returns, so the descriptor can be used again as-is.
Parameters |
fd |
FileDescriptor!: The file descriptor containing the bitmap data to decode |
outPadding |
Rect!: If not null, return the padding rect for the bitmap if it exists, otherwise set padding to [-1,-1,-1,-1]. If no bitmap is returned (null) then padding is unchanged. |
opts |
BitmapFactory.Options!: null-ok; Options that control downsampling and whether the image should be completely decoded, or just its size returned. |
Return |
Bitmap! |
the decoded bitmap, or null |
decodeFileDescriptor
open static fun decodeFileDescriptor(fd: FileDescriptor!): Bitmap!
Decode a bitmap from the file descriptor. If the bitmap cannot be decoded return null. The position within the descriptor will not be changed when this returns, so the descriptor can be used again as is.
Parameters |
fd |
FileDescriptor!: The file descriptor containing the bitmap data to decode |
Return |
Bitmap! |
the decoded bitmap, or null |
decodeResource
open static fun decodeResource(
res: Resources!,
id: Int,
opts: BitmapFactory.Options!
): Bitmap!
Synonym for opening the given resource and calling decodeResourceStream
.
Parameters |
res |
Resources!: The resources object containing the image data |
id |
Int: The resource id of the image data |
opts |
BitmapFactory.Options!: null-ok; Options that control downsampling and whether the image should be completely decoded, or just is size returned. |
Return |
Bitmap! |
The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight) |
decodeResourceStream
open static fun decodeResourceStream(
res: Resources?,
value: TypedValue?,
is: InputStream?,
pad: Rect?,
opts: BitmapFactory.Options?
): Bitmap?
Decode a new Bitmap from an InputStream. This InputStream was obtained from resources, which we pass to be able to scale the bitmap accordingly.
Return |
Bitmap? |
This value may be null . |
decodeStream
open static fun decodeStream(
is: InputStream?,
outPadding: Rect?,
opts: BitmapFactory.Options?
): Bitmap?
Decode an input stream into a bitmap. If the input stream is null, or cannot be used to decode a bitmap, the function returns null. The stream's position will be where ever it was after the encoded data was read.
Parameters |
is |
InputStream?: The input stream that holds the raw data to be decoded into a bitmap. This value may be null . |
outPadding |
Rect?: If not null, return the padding rect for the bitmap if it exists, otherwise set padding to [-1,-1,-1,-1]. If no bitmap is returned (null) then padding is unchanged. |
opts |
BitmapFactory.Options?: null-ok; Options that control downsampling and whether the image should be completely decoded, or just is size returned. |
Return |
Bitmap? |
The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight) |
decodeStream
open static fun decodeStream(is: InputStream!): Bitmap!
Decode an input stream into a bitmap. If the input stream is null, or cannot be used to decode a bitmap, the function returns null. The stream's position will be where ever it was after the encoded data was read.
Parameters |
is |
InputStream!: The input stream that holds the raw data to be decoded into a bitmap. |
Return |
Bitmap! |
The decoded bitmap, or null if the image data could not be decoded. |