androidx.ink.storage


Interfaces

BrushFamilyDecodeCallback

A callback to use with decode to manage texture image assets.

android

Objects

Extension functions summary

ImmutableStrokeInputBatch

Read a serialized gzip-compressed ink.proto.CodedStrokeInputBatch from the given InputStream and parse it into a ImmutableStrokeInputBatch, throwing an exception if parsing or validation was not successful.

android
BrushFamily
BrushFamily.Companion.decode(
    input: InputStream,
    getClientTextureId: BrushFamilyDecodeCallback
)

See decode above.

android
BrushFamily

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful.

android
BrushFamily
BrushFamily.Companion.decode(
    input: InputStream,
    maxVersion: Version,
    getClientTextureId: BrushFamilyDecodeCallback
)

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful.

android
Unit

Write a gzip-compressed serialized ink.proto.BrushFamily proto message representing the BrushFamily to the given OutputStream.

android
Unit

Write a gzip-compressed ink.proto.CodedStrokeInputBatch binary proto message representing the StrokeInputBatch to the given OutputStream.

android
Unit
BrushFamily.encode(
    output: OutputStream,
    textureBitmapStore: TextureBitmapStore
)

Write a gzip-compressed ink.proto.BrushFamily binary proto message representing the BrushFamily to the given OutputStream.

android

Extension functions

StrokeInputBatch.Companion.decode

fun StrokeInputBatch.Companion.decode(input: InputStream): ImmutableStrokeInputBatch

Read a serialized gzip-compressed ink.proto.CodedStrokeInputBatch from the given InputStream and parse it into a ImmutableStrokeInputBatch, throwing an exception if parsing or validation was not successful. Java callers should use StrokeInputBatchSerialization.decode instead.

Parameters
input: InputStream

InputStream providing gzip-compressed ink.proto.CodedStrokeInputBatch binary proto messages, the same as written to OutputStream by encode.

Throws
java.io.IOException

if gzip-format bytes cannot be read from input.

IllegalArgumentException

input does not provide a valid ink.proto.CodedStrokeInputBatch proto message, or the corresponding StrokeInputBatch is invalid.

BrushFamily.Companion.decode

fun BrushFamily.Companion.decode(
    input: InputStream,
    getClientTextureId: BrushFamilyDecodeCallback
): BrushFamily

See decode above. This overload uses Version.MAX_SUPPORTED.

BrushFamily.Companion.decode

fun BrushFamily.Companion.decode(
    input: InputStream,
    maxVersion: Version = Version.MAX_SUPPORTED
): BrushFamily

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful. Java callers should use BrushFamilySerialization.decode instead.

Parameters
input: InputStream

InputStream providing gzip-compressed ink.proto.BrushFamily binary proto messages, the same as written to OutputStream by encode.

maxVersion: Version = Version.MAX_SUPPORTED

The maximum Version supported by the deserializer. Proto objects with a min_version of greater than maxVersion will be rejected.

Returns
BrushFamily

The BrushFamily parsed from the InputStream.

Throws
java.io.IOException

if gzip-format bytes cannot be read from input.

IllegalArgumentException

input does not provide a valid ink.proto.BrushFamily proto message, or the corresponding BrushFamily is invalid.

BrushFamily.Companion.decode

fun BrushFamily.Companion.decode(
    input: InputStream,
    maxVersion: Version,
    getClientTextureId: BrushFamilyDecodeCallback
): BrushFamily

Read a serialized BrushFamily from the given InputStream and parse it into a BrushFamily, throwing an exception if parsing or validation was not successful. Java callers should use AndroidBrushFamilySerialization.decode instead.

Parameters
input: InputStream

InputStream providing gzip-compressed ink.proto.BrushFamily binary proto messages, the same as written to OutputStream by encode.

maxVersion: Version

The maximum Version to be supported by the deserializer. Proto objects with a min_version of greater than maxVersion will be rejected.

getClientTextureId: BrushFamilyDecodeCallback

A callback to store the decoded texture image, if one were encoded inside the serialized BrushFamily, into a TextureBitmapStore. This is called synchronously as part of this function call on the same thread.

Returns
BrushFamily

The BrushFamily parsed from the InputStream.

Throws
java.io.IOException

if gzip-format bytes cannot be read from input.

IllegalArgumentException

input does not provide a valid ink.proto.BrushFamily proto message, or the corresponding BrushFamily is invalid.

BrushFamily.encode

fun BrushFamily.encode(output: OutputStream): Unit

Write a gzip-compressed serialized ink.proto.BrushFamily proto message representing the BrushFamily to the given OutputStream. If hasFallbacks is true, then the stored, proto message including fallbacks for this BrushFamily will be used instead of recomputing the proto from the BrushFamily object.

StrokeInputBatch.encode

fun StrokeInputBatch.encode(output: OutputStream): Unit

Write a gzip-compressed ink.proto.CodedStrokeInputBatch binary proto message representing the StrokeInputBatch to the given OutputStream.

BrushFamily.encode

fun BrushFamily.encode(
    output: OutputStream,
    textureBitmapStore: TextureBitmapStore
): Unit

Write a gzip-compressed ink.proto.BrushFamily binary proto message representing the BrushFamily to the given OutputStream. If hasFallbacks is true, then the stored, proto message including fallbacks for this BrushFamily will be used instead of recomputing the proto from the BrushFamily object.

Parameters
BrushFamily

The BrushFamily object to encode.

output: OutputStream

The OutputStream to write the gzip-compressed encoded bytes to.

textureBitmapStore: TextureBitmapStore

The TextureBitmapStore to use to encode the texture images within the encoded BrushFamily. If this is not desired behavior, e.g. if the application has a static set of texture images that it includes as resources, then this can be a TextureBitmapStore that always returns null.