Class Codec
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.Codec
-
- All Implemented Interfaces:
IHasImageInfo,java.lang.AutoCloseable
public class Codec extends Managed implements IHasImageInfo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCodec._FinalizerHolder-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.Managed
Managed.CleanerThunk
-
-
Field Summary
Fields Modifier and Type Field Description ImageInfo_imageInfo-
Fields inherited from class io.github.humbleui.skija.impl.Managed
_cleanable
-
-
Constructor Summary
Constructors Constructor Description Codec(long ptr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int_nGetEncodedImageFormat(long ptr)static int_nGetEncodedOrigin(long ptr)static long_nGetFinalizer()static int_nGetFrameCount(long ptr)static AnimationFrameInfo_nGetFrameInfo(long ptr, int frame)static AnimationFrameInfo[]_nGetFramesInfo(long ptr)static ImageInfo_nGetImageInfo(long ptr)static int_nGetRepetitionCount(long ptr)static long_nGetSize(long ptr)static long_nMakeFromData(long dataPtr)static int_nReadPixels(long ptr, long bitmapPtr, int frame, int priorFrame)static void_validateResult(int result)@NotNull EncodedImageFormatgetEncodedImageFormat()@NotNull EncodedOrigingetEncodedOrigin()intgetFrameCount()Return the number of frames in the image.AnimationFrameInfogetFrameInfo(int frame)Return info about a single frame.AnimationFrameInfo[]getFramesInfo()Return info about all the frames in the image.@NotNull ImageInfogetImageInfo()intgetRepetitionCount()Return the number of times to repeat, if this image is animated.@NotNull io.github.humbleui.types.IPointgetSize()static CodecmakeFromData(Data data)If this data represents an encoded image that we know how to decode, return an Codec that can decode it.@NotNull BitmapreadPixels()Decodes an image into a bitmap.@NotNull CodecreadPixels(Bitmap bitmap)Decodes an image into a bitmap.@NotNull CodecreadPixels(Bitmap bitmap, int frame)Decodes a frame in a multi-frame image into a bitmap.@NotNull CodecreadPixels(Bitmap bitmap, int frame, int priorFrame)Decodes a frame in a multi-frame image into a bitmap.-
Methods inherited from class io.github.humbleui.skija.impl.Managed
_nInvokeFinalizer, close, isClosed
-
Methods inherited from class io.github.humbleui.skija.impl.Native
_nativeEquals, equals, getPtr, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.humbleui.skija.IHasImageInfo
getAlphaType, getBytesPerPixel, getColorInfo, getColorSpace, getColorType, getHeight, getShiftPerPixel, getWidth, isEmpty, isOpaque
-
-
-
-
Field Detail
-
_imageInfo
@Internal public ImageInfo _imageInfo
-
-
Method Detail
-
makeFromData
public static Codec makeFromData(Data data)
If this data represents an encoded image that we know how to decode, return an Codec that can decode it. Otherwise throws IllegalArgumentException.
-
getImageInfo
@NotNull public @NotNull ImageInfo getImageInfo()
- Specified by:
getImageInfoin interfaceIHasImageInfo
-
getSize
@NotNull @Contract("-> new") public @NotNull io.github.humbleui.types.IPoint getSize()
-
getEncodedOrigin
@NotNull public @NotNull EncodedOrigin getEncodedOrigin()
-
getEncodedImageFormat
@NotNull public @NotNull EncodedImageFormat getEncodedImageFormat()
-
readPixels
@NotNull @Contract("_ -> new") public @NotNull Bitmap readPixels()Decodes an image into a bitmap.
- Returns:
- decoded bitmap
-
readPixels
@NotNull @Contract("_ -> this") public @NotNull Codec readPixels(Bitmap bitmap)Decodes an image into a bitmap.
Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.
Bitmap specifies the description of the format (config, size) expected by the caller. This can simply be identical to the info returned by getImageInfo().
This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.
A size that does not match getImageInfo() implies a request to scale. If the generator cannot perform this scale, it will throw an exception.
If the info contains a non-null ColorSpace, the codec will perform the appropriate color space transformation.
If the caller passes in the ColorSpace that maps to the ICC profile reported by getICCProfile(), the color space transformation is a no-op.
If the caller passes a null SkColorSpace, no color space transformation will be done.
- Parameters:
bitmap- the description of the format (config, size) expected by the caller- Returns:
- this
-
readPixels
@NotNull @Contract("_ -> this") public @NotNull Codec readPixels(Bitmap bitmap, int frame)Decodes a frame in a multi-frame image into a bitmap.
Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.
Bitmap specifies the description of the format (config, size) expected by the caller. This can simply be identical to the info returned by getImageInfo().
This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.
A size that does not match getImageInfo() implies a request to scale. If the generator cannot perform this scale, it will throw an exception.
If the info contains a non-null ColorSpace, the codec will perform the appropriate color space transformation.
If the caller passes in the ColorSpace that maps to the ICC profile reported by getICCProfile(), the color space transformation is a no-op.
If the caller passes a null SkColorSpace, no color space transformation will be done.
- Parameters:
bitmap- the description of the format (config, size) expected by the callerframe- index of the frame in multi-frame image to decode- Returns:
- this
-
readPixels
@NotNull @Contract("_ -> this") public @NotNull Codec readPixels(Bitmap bitmap, int frame, int priorFrame)Decodes a frame in a multi-frame image into a bitmap.
Repeated calls to this function should give the same results, allowing the PixelRef to be immutable.
Bitmap specifies the description of the format (config, size) expected by the caller. This can simply be identical to the info returned by getImageInfo().
This contract also allows the caller to specify different output-configs, which the implementation can decide to support or not.
A size that does not match getImageInfo() implies a request to scale. If the generator cannot perform this scale, it will throw an exception.
If the info contains a non-null ColorSpace, the codec will perform the appropriate color space transformation.
If the caller passes in the ColorSpace that maps to the ICC profile reported by getICCProfile(), the color space transformation is a no-op.
If the caller passes a null SkColorSpace, no color space transformation will be done.
- Parameters:
bitmap- the description of the format (config, size) expected by the callerframe- index of the frame in multi-frame image to decodepriorFrame- index of the frame already in bitmap, might be used to optimize retrieving current frame- Returns:
- this
-
getFrameCount
public int getFrameCount()
Return the number of frames in the image.
May require reading through the stream.
-
getFrameInfo
public AnimationFrameInfo getFrameInfo(int frame)
Return info about a single frame.
Only supported by multi-frame images. Does not read through the stream, so it should be called after getFrameCount() to parse any frames that have not already been parsed.
-
getFramesInfo
public AnimationFrameInfo[] getFramesInfo()
Return info about all the frames in the image.
May require reading through the stream to determine info about the frames (including the count).
As such, future decoding calls may require a rewind.
For still (non-animated) image codecs, this will return an empty array.
-
getRepetitionCount
public int getRepetitionCount()
Return the number of times to repeat, if this image is animated. This number does not include the first play through of each frame. For example, a repetition count of 4 means that each frame is played 5 times and then the animation stops.
It can return -1, a negative number, meaning that the animation should loop forever.
May require reading the stream to find the repetition count.
As such, future decoding calls may require a rewind.
For still (non-animated) image codecs, this will return 0.
-
_validateResult
@Internal public static void _validateResult(int result)
-
_nGetFinalizer
@Internal public static long _nGetFinalizer()
-
_nMakeFromData
@Internal public static long _nMakeFromData(long dataPtr)
-
_nGetImageInfo
@Internal public static ImageInfo _nGetImageInfo(long ptr)
-
_nGetSize
@Internal public static long _nGetSize(long ptr)
-
_nGetEncodedOrigin
@Internal public static int _nGetEncodedOrigin(long ptr)
-
_nGetEncodedImageFormat
@Internal public static int _nGetEncodedImageFormat(long ptr)
-
_nReadPixels
@Internal public static int _nReadPixels(long ptr, long bitmapPtr, int frame, int priorFrame)
-
_nGetFrameCount
@Internal public static int _nGetFrameCount(long ptr)
-
_nGetFrameInfo
@Internal public static AnimationFrameInfo _nGetFrameInfo(long ptr, int frame)
-
_nGetFramesInfo
@Internal public static AnimationFrameInfo[] _nGetFramesInfo(long ptr)
-
_nGetRepetitionCount
@Internal public static int _nGetRepetitionCount(long ptr)
-
-