Class Image

    • Field Detail

      • _imageInfo

        @Internal
        public ImageInfo _imageInfo
    • Constructor Detail

      • Image

        @Internal
        public Image​(long ptr)
    • Method Detail

      • makeRasterFromBytes

        public static Image makeRasterFromBytes​(ImageInfo imageInfo,
                                                byte[] bytes,
                                                long rowBytes)

        Creates Image from pixels.

        Image is returned if pixels are valid. Valid Pixmap parameters include:

        • dimensions are greater than zero;
        • each dimension fits in 29 bits;
        • ColorType and AlphaType are valid, and ColorType is not ColorType.UNKNOWN;
        • row bytes are large enough to hold one row of pixels;
        • pixel address is not null.
        Parameters:
        imageInfo - ImageInfo
        bytes - pixels array
        rowBytes - how many bytes in a row
        Returns:
        Image
        See Also:
        https://fiddle.skia.org/c/@Image_MakeRasterCopy
      • makeRasterFromData

        public static Image makeRasterFromData​(ImageInfo imageInfo,
                                               Data data,
                                               long rowBytes)

        Creates Image from pixels.

        Image is returned if pixels are valid. Valid Pixmap parameters include:

        • dimensions are greater than zero;
        • each dimension fits in 29 bits;
        • ColorType and AlphaType are valid, and ColorType is not ColorType.UNKNOWN;
        • row bytes are large enough to hold one row of pixels;
        • pixel address is not null.
        Parameters:
        imageInfo - ImageInfo
        data - pixels array
        rowBytes - how many bytes in a row
        Returns:
        Image
      • makeRasterFromBitmap

        @NotNull
        @Contract("_ -> new")
        public static @NotNull Image makeRasterFromBitmap​(@NotNull
                                                          @NotNull Bitmap bitmap)

        Creates Image from bitmap, sharing or copying bitmap pixels. If the bitmap is marked immutable, and its pixel memory is shareable, it may be shared instead of copied.

        Image is returned if bitmap is valid. Valid Bitmap parameters include:

        • dimensions are greater than zero;
        • each dimension fits in 29 bits;
        • ColorType and AlphaType are valid, and ColorType is not ColorType.UNKNOWN;
        • row bytes are large enough to hold one row of pixels;
        • pixel address is not nullptr.
        Parameters:
        bitmap - ImageInfo, row bytes, and pixels
        Returns:
        created Image
        See Also:
        https://fiddle.skia.org/c/@Image_MakeFromBitmap
      • makeRasterFromPixmap

        @NotNull
        @Contract("_ -> new")
        public static @NotNull Image makeRasterFromPixmap​(@NotNull
                                                          @NotNull Pixmap pixmap)
      • makeDeferredFromEncodedBytes

        @NotNull
        @Contract("_ -> new")
        public static @NotNull Image makeDeferredFromEncodedBytes​(byte[] bytes)
      • getImageInfo

        @NotNull
        public @NotNull ImageInfo getImageInfo()
        Returns a ImageInfo describing the width, height, color type, alpha type, and color space of the Image.
        Specified by:
        getImageInfo in interface IHasImageInfo
        Returns:
        image info of Image.
      • makeShader

        @NotNull
        public @NotNull Shader makeShader()
      • makeShader

        @NotNull
        public @NotNull Shader makeShader​(@Nullable
                                          @Nullable Matrix33 localMatrix)
      • peekPixels

        @Nullable
        public @Nullable java.nio.ByteBuffer peekPixels()
        If pixel address is available, return ByteBuffer wrapping it. If pixel address is not available, return null.
        Returns:
        ByteBuffer with direct access to pixels, or null
        See Also:
        https://fiddle.skia.org/c/@Image_peekPixels
      • peekPixels

        public boolean peekPixels​(Pixmap pixmap)
      • readPixels

        public boolean readPixels​(@NotNull
                                  @NotNull Bitmap dst)
      • readPixels

        public boolean readPixels​(@NotNull
                                  @NotNull Bitmap dst,
                                  int srcX,
                                  int srcY)
      • readPixels

        public boolean readPixels​(@Nullable
                                  @Nullable DirectContext context,
                                  @NotNull
                                  @NotNull Bitmap dst,
                                  int srcX,
                                  int srcY,
                                  boolean cache)

        Copies Rect of pixels from Image to Bitmap. Copy starts at offset (srcX, srcY), and does not exceed Image (getWidth(), getHeight()).

        dst specifies width, height, ColorType, AlphaType, and ColorSpace of destination.

        Returns true if pixels are copied. Returns false if:

        • dst has no pixels allocated.

        Pixels are copied only if pixel conversion is possible. If Image ColorType is ColorType.GRAY_8, or ColorType.ALPHA_8; dst.getColorType() must match. If Image ColorType is ColorType.GRAY_8, dst.getColorSpace() must match. If Image AlphaType is AlphaType.OPAQUE, dst.getAlphaType() must match. If Image ColorSpace is null, dst.getColorSpace() must match. Returns false if pixel conversion is not possible.

        srcX and srcY may be negative to copy only top or left of source. Returns false if getWidth() or getHeight() is zero or negative.

        Returns false if abs(srcX) >= Image.getWidth(), or if abs(srcY) >= Image.getHeight().

        If cache is true, pixels may be retained locally, otherwise pixels are not added to the local cache.

        Parameters:
        context - the DirectContext in play, if it exists
        dst - destination bitmap
        srcX - column index whose absolute value is less than getWidth()
        srcY - row index whose absolute value is less than getHeight()
        cache - whether the pixels should be cached locally
        Returns:
        true if pixels are copied to dstPixels
      • readPixels

        public boolean readPixels​(@NotNull
                                  @NotNull Pixmap dst,
                                  int srcX,
                                  int srcY,
                                  boolean cache)
      • scalePixels

        public boolean scalePixels​(@NotNull
                                   @NotNull Pixmap dst,
                                   SamplingMode samplingMode,
                                   boolean cache)
      • _nMakeRasterFromBytes

        @Internal
        public static long _nMakeRasterFromBytes​(int width,
                                                 int height,
                                                 int colorType,
                                                 int alphaType,
                                                 long colorSpacePtr,
                                                 byte[] pixels,
                                                 long rowBytes)
      • _nMakeRasterFromData

        @Internal
        public static long _nMakeRasterFromData​(int width,
                                                int height,
                                                int colorType,
                                                int alphaType,
                                                long colorSpacePtr,
                                                long dataPtr,
                                                long rowBytes)
      • _nMakeRasterFromBitmap

        @Internal
        public static long _nMakeRasterFromBitmap​(long bitmapPtr)
      • _nMakeRasterFromPixmap

        @Internal
        public static long _nMakeRasterFromPixmap​(long pixmapPtr)
      • _nMakeDeferredFromEncodedBytes

        @Internal
        public static long _nMakeDeferredFromEncodedBytes​(byte[] bytes)
      • _nGetImageInfo

        @Internal
        public static ImageInfo _nGetImageInfo​(long ptr)
      • _nMakeShader

        @Internal
        public static long _nMakeShader​(long ptr,
                                        int tmx,
                                        int tmy,
                                        long samplingMode,
                                        float[] localMatrix)
      • _nPeekPixels

        @Internal
        public static java.nio.ByteBuffer _nPeekPixels​(long ptr)
      • _nPeekPixelsToPixmap

        @Internal
        public static boolean _nPeekPixelsToPixmap​(long ptr,
                                                   long pixmapPtr)
      • _nScalePixels

        @Internal
        public static boolean _nScalePixels​(long ptr,
                                            long pixmapPtr,
                                            long samplingOptions,
                                            boolean cache)
      • _nReadPixelsBitmap

        @Internal
        public static boolean _nReadPixelsBitmap​(long ptr,
                                                 long contextPtr,
                                                 long bitmapPtr,
                                                 int srcX,
                                                 int srcY,
                                                 boolean cache)
      • _nReadPixelsPixmap

        @Internal
        public static boolean _nReadPixelsPixmap​(long ptr,
                                                 long pixmapPtr,
                                                 int srcX,
                                                 int srcY,
                                                 boolean cache)