AndroidBrushFamilySerialization



Summary

Public functions

BrushFamily
decode(input: InputStream, 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
encode(
    brushFamily: BrushFamily,
    output: OutputStream,
    textureBitmapStore: TextureBitmapStore
)

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

android

Public functions

decode

fun decode(input: InputStream, 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. Kotlin callers should use BrushFamily.Companion.decode instead.

getClientTextureId is called synchronously as part of this function call, on the same thread.

Parameters
input: InputStream

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

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.

kotlin.IllegalArgumentException

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

encode

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

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

Parameters
brushFamily: 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.