Class Image
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.impl.RefCnt
-
- io.github.humbleui.skija.Image
-
- All Implemented Interfaces:
IHasImageInfo,java.lang.AutoCloseable
public class Image extends RefCnt implements IHasImageInfo
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.RefCnt
RefCnt._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 Image(long ptr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ImageInfo_nGetImageInfo(long ptr)static long_nMakeDeferredFromEncodedBytes(byte[] bytes)static long_nMakeRasterFromBitmap(long bitmapPtr)static long_nMakeRasterFromBytes(int width, int height, int colorType, int alphaType, long colorSpacePtr, byte[] pixels, long rowBytes)static long_nMakeRasterFromData(int width, int height, int colorType, int alphaType, long colorSpacePtr, long dataPtr, long rowBytes)static long_nMakeRasterFromPixmap(long pixmapPtr)static long_nMakeShader(long ptr, int tmx, int tmy, long samplingMode, float[] localMatrix)static java.nio.ByteBuffer_nPeekPixels(long ptr)static boolean_nPeekPixelsToPixmap(long ptr, long pixmapPtr)static boolean_nReadPixelsBitmap(long ptr, long contextPtr, long bitmapPtr, int srcX, int srcY, boolean cache)static boolean_nReadPixelsPixmap(long ptr, long pixmapPtr, int srcX, int srcY, boolean cache)static boolean_nScalePixels(long ptr, long pixmapPtr, long samplingOptions, boolean cache)DataencodeToData()Deprecated.DataencodeToData(EncodedImageFormat format)Deprecated.DataencodeToData(EncodedImageFormat format, int quality)@NotNull ImageInfogetImageInfo()Returns a ImageInfo describing the width, height, color type, alpha type, and color space of the Image.static @NotNull ImagemakeDeferredFromEncodedBytes(byte[] bytes)static ImagemakeFromBitmap(@NotNull Bitmap bitmap)Deprecated.static ImagemakeFromEncoded(byte[] bytes)Deprecated.static ImagemakeFromPixmap(@NotNull Pixmap pixmap)Deprecated.static ImagemakeRaster(ImageInfo imageInfo, byte[] bytes, long rowBytes)Deprecated.static ImagemakeRaster(ImageInfo imageInfo, Data data, long rowBytes)Deprecated.static @NotNull ImagemakeRasterFromBitmap(@NotNull Bitmap bitmap)Creates Image from bitmap, sharing or copying bitmap pixels.static ImagemakeRasterFromBytes(ImageInfo imageInfo, byte[] bytes, long rowBytes)Creates Image from pixels.static ImagemakeRasterFromData(ImageInfo imageInfo, Data data, long rowBytes)Creates Image from pixels.static @NotNull ImagemakeRasterFromPixmap(@NotNull Pixmap pixmap)@NotNull ShadermakeShader()@NotNull ShadermakeShader(@NotNull FilterTileMode tm)@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy)@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy, @NotNull SamplingMode sampling, @Nullable Matrix33 localMatrix)@NotNull ShadermakeShader(@NotNull FilterTileMode tmx, @NotNull FilterTileMode tmy, @Nullable Matrix33 localMatrix)@NotNull ShadermakeShader(@Nullable Matrix33 localMatrix)@Nullable java.nio.ByteBufferpeekPixels()If pixel address is available, return ByteBuffer wrapping it.booleanpeekPixels(Pixmap pixmap)booleanreadPixels(@NotNull Bitmap dst)booleanreadPixels(@NotNull Bitmap dst, int srcX, int srcY)booleanreadPixels(@NotNull Pixmap dst, int srcX, int srcY, boolean cache)booleanreadPixels(@Nullable DirectContext context, @NotNull Bitmap dst, int srcX, int srcY, boolean cache)Copies Rect of pixels from Image to Bitmap.booleanscalePixels(@NotNull Pixmap dst, SamplingMode samplingMode, boolean cache)-
Methods inherited from class io.github.humbleui.skija.impl.RefCnt
_nGetFinalizer, _nGetRefCount, getRefCount, toString
-
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
-
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
-
makeRaster
@Deprecated public static Image makeRaster(ImageInfo imageInfo, byte[] bytes, long rowBytes)
Deprecated.
-
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- ImageInfobytes- pixels arrayrowBytes- how many bytes in a row- Returns:
- Image
- See Also:
- https://fiddle.skia.org/c/@Image_MakeRasterCopy
-
makeRaster
@Deprecated public static Image makeRaster(ImageInfo imageInfo, Data data, long rowBytes)
Deprecated.
-
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- ImageInfodata- pixels arrayrowBytes- how many bytes in a row- Returns:
- Image
-
makeFromBitmap
@Deprecated public static Image makeFromBitmap(@NotNull @NotNull Bitmap bitmap)
Deprecated.
-
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
-
makeFromPixmap
@Deprecated public static Image makeFromPixmap(@NotNull @NotNull Pixmap pixmap)
Deprecated.
-
makeRasterFromPixmap
@NotNull @Contract("_ -> new") public static @NotNull Image makeRasterFromPixmap(@NotNull @NotNull Pixmap pixmap)
-
makeFromEncoded
@Deprecated public static Image makeFromEncoded(byte[] bytes)
Deprecated.
-
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:
getImageInfoin interfaceIHasImageInfo- Returns:
- image info of Image.
-
encodeToData
@Deprecated public Data encodeToData()
Deprecated.
-
encodeToData
@Deprecated public Data encodeToData(EncodedImageFormat format)
Deprecated.
-
encodeToData
@Deprecated public Data encodeToData(EncodedImageFormat format, int quality)
-
makeShader
@NotNull public @NotNull Shader makeShader()
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tm)
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy)
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy, @Nullable @Nullable Matrix33 localMatrix)
-
makeShader
@NotNull public @NotNull Shader makeShader(@NotNull @NotNull FilterTileMode tmx, @NotNull @NotNull FilterTileMode tmy, @NotNull @NotNull SamplingMode sampling, @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 existsdst- destination bitmapsrcX- 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)
-
-