Class Codec

    • Field Detail

      • _imageInfo

        @Internal
        public ImageInfo _imageInfo
    • Constructor Detail

      • Codec

        @Internal
        public Codec​(long ptr)
    • 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.
      • 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 caller
        frame - 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 caller
        frame - index of the frame in multi-frame image to decode
        priorFrame - 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)