Class VBlob
Represents a VipsBlob, which is backed by a contiguous area of off-heap memory
Its constructor is package private to prevent leaking MemorySegments in to the vips-ffm API
Use its static helper methods to create new blobs
-
Method Summary
Modifier and TypeMethodDescriptionByteBuffer representation of the data in this blobByteBuffer representation of the data in this bloblongbyteSize()Size of the data in this blobbyte[]getBytes()byte[] representation of the data in this VipsBlobNot recommended for use, useasArenaScopedByteBuffer()orasClonedByteBuffer()insteadGets the rawMemorySegment(C pointer) for this VipsBlob structstatic VBlobnewFromBytes(Arena arena, byte[] bytes) Creates a new VBlob from a fixed array of bytes
-
Method Details
-
newFromBytes
Creates a new VBlob from a fixed array of bytes
This must copy the data - it's generally more efficient to use
VImage.newFromFile(java.lang.foreign.Arena, java.lang.String, app.photofox.vipsffm.VipsOption...),VImage.newFromSource(java.lang.foreign.Arena, app.photofox.vipsffm.VSource, java.lang.String, app.photofox.vipsffm.VipsOption...), and friends- Parameters:
arena- An arena constraining the lifetime of this blobbytes- The bytes to wrap- Throws:
VipsError
-
getUnsafeStructAddress
Gets the raw
MemorySegment(C pointer) for this VipsBlob structYou might want the data address instead
getUnsafeDataAddress()The memory address' lifetime is bound to the scope of the
arenaUsage of the memory address is strongly discouraged, but it is available if some functionality is missing and you need to use it with
VipsHelper- Throws:
VipsError
-
getUnsafeDataAddress
Not recommended for use, use
asArenaScopedByteBuffer()orasClonedByteBuffer()insteadGets the raw
MemorySegment(C pointer) for the data in this blobSliced to the length of the data, which isn't always null terminated
- Throws:
VipsError
-
byteSize
public long byteSize()Size of the data in this blob -
asArenaScopedByteBuffer
ByteBuffer representation of the data in this blob
Mapped to native memory via DirectByteBuffer, hence does not make a copy, so the data has the same data lifetime as
arenaNote that because this is backed by native memory, you cannot use the
ByteBuffer.array()method on the resulting buffer. UseasClonedByteBuffer()orgetBytes()if you're looking for a full copy of the data. -
asClonedByteBuffer
ByteBuffer representation of the data in this blob
A full copy of the data is taken, so that its contents are not coupled to the scope of
arena -
getBytes
public byte[] getBytes()byte[] representation of the data in this VipsBlob
Useful if you're working with metadata stored on an image, like an ICC profile
Note that a full copy of the data is taken
-