# AndroidBrushFamilySerialization

Artifact: [androidx.ink:ink-storage](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/storage/AndroidBrushFamilyExtensions.android.kt+class:androidx.ink.storage.AndroidBrushFamilySerialization) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- android

  ```
  object AndroidBrushFamilySerialization
  ```

*** ** * ** ***

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.BrushFamilyDecodeCallback)(input: https://developer.android.com/reference/java/io/InputStream.html, getClientTextureId: https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilyDecodeCallback)` See `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.BrushFamilyDecodeCallback)` above. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.BrushFamilyDecodeCallback)( input: https://developer.android.com/reference/java/io/InputStream.html, maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version, getClientTextureId: https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilyDecodeCallback )` Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,java.io.OutputStream,androidx.ink.brush.TextureBitmapStore)( brushFamily: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily, output: https://developer.android.com/reference/java/io/OutputStream.html, textureBitmapStore: https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureBitmapStore )` Write a gzip-compressed `ink.proto.BrushFamily` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. | android |

## Public functions

### decode

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun decode(input: InputStream, getClientTextureId: BrushFamilyDecodeCallback): BrushFamily
```

See `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.storage.BrushFamilyDecodeCallback)` above. This overload uses `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version#MAX_SUPPORTED()`.

### decode

android Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

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

Read a serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, throwing an exception if parsing or validation was not successful. Kotlin callers should use `https://developer.android.com/reference/kotlin/androidx/ink/storage/package-summary#(androidx.ink.brush.BrushFamily.Companion).decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.BrushFamilyDecodeCallback)` instead.

`https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.BrushFamilyDecodeCallback)` is called synchronously as part of this function call, on the same thread.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/java/io/InputStream.html` | `https://developer.android.com/reference/java/io/InputStream.html` providing gzip-compressed `ink.proto.BrushFamily` binary proto messages, the same as written to `https://developer.android.com/reference/java/io/OutputStream.html` by `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#encode(androidx.ink.brush.BrushFamily,java.io.OutputStream,androidx.ink.brush.TextureBitmapStore)`. |
| `maxVersion: https://developer.android.com/reference/kotlin/androidx/ink/brush/Version` | The maximum `https://developer.android.com/reference/kotlin/androidx/ink/brush/Version` supported by the deserializer. If the serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` has a `min_version` of greater than maxVersion, deserialization will fail. |
| `getClientTextureId: https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilyDecodeCallback` | A callback to store the decoded texture image, if one were encoded inside the serialized `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily`, into a `https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureBitmapStore`. This is called synchronously as part of this function call on the same thread. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` parsed from the `https://developer.android.com/reference/java/io/InputStream.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if gzip-format bytes cannot be read from `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.BrushFamilyDecodeCallback)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/storage/AndroidBrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.BrushFamilyDecodeCallback)` does not provide a valid `ink.proto.BrushFamily` proto message, or the corresponding `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` is invalid. |

### encode

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

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

Write a gzip-compressed `ink.proto.BrushFamily` binary proto message representing the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. If `hasFallbacks` is true, then the stored, proto message including fallbacks for this `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` will be used instead of recomputing the proto from the `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` object.

| Parameters |
|---|---|
| `brushFamily: https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/BrushFamily` object to encode. |
| `output: https://developer.android.com/reference/java/io/OutputStream.html` | The `https://developer.android.com/reference/java/io/OutputStream.html` to write the gzip-compressed encoded bytes to. |
| `textureBitmapStore: https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureBitmapStore` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureBitmapStore` to use to encode the texture images within the encoded `https://developer.android.com/reference/kotlin/androidx/ink/brush/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 `https://developer.android.com/reference/kotlin/androidx/ink/brush/TextureBitmapStore` that always returns `null`. |