BrushFamilySerialization



Summary

Public functions

BrushFamily
decode(input: ByteArray, onDecodeTexture: OnDecodeTexturePngBytes)

See decode above.

android
BrushFamily
decode(input: InputStream, onDecodeTexture: OnDecodeTexturePngBytes)

See decode above.

android
BrushFamily
decode(
    input: ByteArray,
    maxVersion: Version,
    onDecodeTexture: OnDecodeTexturePngBytes?
)

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

android
BrushFamily
decode(
    input: InputStream,
    maxVersion: Version,
    onDecodeTexture: OnDecodeTexturePngBytes?
)

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
ByteArray
encode(
    brushFamily: BrushFamily,
    textureIdToPngBytes: TexturePngBytesLookup?
)

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

android
Unit
encode(
    brushFamily: BrushFamily,
    output: OutputStream,
    textureIdToPngBytes: TexturePngBytesLookup?
)

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

android

Public functions

decode

fun decode(input: ByteArray, onDecodeTexture: OnDecodeTexturePngBytes): BrushFamily

See decode above. This overload uses Version.MAX_SUPPORTED.

decode

fun decode(input: InputStream, onDecodeTexture: OnDecodeTexturePngBytes): BrushFamily

See decode above. This overload uses Version.MAX_SUPPORTED.

decode

fun decode(
    input: ByteArray,
    maxVersion: Version = Version.MAX_SUPPORTED,
    onDecodeTexture: OnDecodeTexturePngBytes? = null
): BrushFamily

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

Parameters
input: ByteArray

ByteArray providing gzip-compressed ink.proto.BrushFamily binary proto messages, the same as written 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.

onDecodeTexture: OnDecodeTexturePngBytes? = null

A callback to store any decoded texture image, if any were encoded inside the serialized BrushFamilys. This is called synchronously as part of this function call, on the same thread, once for each texture image.

Returns
BrushFamily

The BrushFamily parsed from the ByteArray.

Throws
IllegalArgumentException

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

decode

fun decode(
    input: InputStream,
    maxVersion: Version = Version.MAX_SUPPORTED,
    onDecodeTexture: OnDecodeTexturePngBytes? = null
): 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. Kotlin callers should use BrushFamily.Companion.decode instead.

Parameters
input: InputStream

InputStream providing gzip-compressed ink.proto.BrushFamily binary proto messages, the same as written 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.

onDecodeTexture: OnDecodeTexturePngBytes? = null

A callback to store any decoded texture image, if any were encoded inside the serialized BrushFamilys. This is called synchronously as part of this function call, on the same thread, once for each texture image.

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.

encode

fun encode(
    brushFamily: BrushFamily,
    textureIdToPngBytes: TexturePngBytesLookup? = null
): ByteArray

Write a gzip-compressed serialized ink.proto.BrushFamily proto message representing the BrushFamily to a ByteArray. If BrushFamily.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.

encode

fun encode(
    brushFamily: BrushFamily,
    output: OutputStream,
    textureIdToPngBytes: TexturePngBytesLookup? = null
): Unit

Write a gzip-compressed serialized ink.proto.BrushFamily proto message representing the BrushFamily to the given OutputStream. If BrushFamily.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.