# StrokeInputBatchExtensions

Added in 1.0.0

*** ** * ** ***


```
public final class StrokeInputBatchExtensions
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` | `@https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throws/index.html(exceptionClasses = [https://developer.android.com/reference/androidx/ink/storage/IOException]) https://developer.android.com/reference/androidx/ink/storage/StrokeInputBatchExtensions#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(kotlin.ByteArray)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch.Companion receiver, @https://developer.android.com/reference/androidx/annotation/NonNull byte[] input)` Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` | `https://developer.android.com/reference/androidx/ink/storage/StrokeInputBatchExtensions#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(java.io.InputStream)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch.Companion receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/InputStream.html input )` Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull byte[]` | `https://developer.android.com/reference/androidx/ink/storage/StrokeInputBatchExtensions#(androidx.ink.strokes.StrokeInputBatch).encode()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch receiver)` Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` to the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. |
| `static final void` | `https://developer.android.com/reference/androidx/ink/storage/StrokeInputBatchExtensions#(androidx.ink.strokes.StrokeInputBatch).encode(java.io.OutputStream)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/OutputStream.html output)` Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` to the given `https://developer.android.com/reference/java/io/OutputStream.html`. |

## Public methods

### decode

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/StrokeInputBatchExtensions.kt+function:decode) Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
@Throws(exceptionClasses = [IOException])
public static final @NonNull ImmutableStrokeInputBatch decode(@NonNull StrokeInputBatch.Companion receiver, @NonNull byte[] input)
```

Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` and parse it into a `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[] input` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html` providing gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto messages, the same as written by `https://developer.android.com/reference/androidx/ink/storage/package-summary#(androidx.ink.brush.BrushFamily).encode(androidx.ink.storage.TexturePngBytesLookup)`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` | The `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` parsed from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/ink/storage/IOException` | if gzip-format bytes cannot be read from `https://developer.android.com/reference/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(kotlin.ByteArray)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(kotlin.ByteArray)` does not provide a valid `ink.proto.CodedStrokeInputBatch` proto message, or the corresponding `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` is invalid. |

### decode

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/StrokeInputBatchExtensions.jvmAndAndroid.kt+function:decode) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final @NonNull ImmutableStrokeInputBatch decode(
    @NonNull StrokeInputBatch.Companion receiver,
    @NonNull InputStream input
)
```

Read a serialized gzip-compressed `ink.proto.CodedStrokeInputBatch` from the given `https://developer.android.com/reference/java/io/InputStream.html` and parse it into a `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch`, throwing an exception if parsing or validation was not successful. Java callers should use `https://developer.android.com/reference/androidx/ink/storage/StrokeInputBatchSerialization#decode(java.io.InputStream)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/InputStream.html input` | `https://developer.android.com/reference/java/io/InputStream.html` providing gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto messages, the same as written by `https://developer.android.com/reference/androidx/ink/storage/package-summary#(androidx.ink.brush.BrushFamily).encode(java.io.OutputStream,androidx.ink.storage.TexturePngBytesLookup)`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` | The `https://developer.android.com/reference/androidx/ink/strokes/ImmutableStrokeInputBatch` 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/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(java.io.InputStream)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/androidx/ink/storage/package-summary#(androidx.ink.strokes.StrokeInputBatch.Companion).decode(java.io.InputStream)` does not provide a valid `ink.proto.CodedStrokeInputBatch` proto message, or the corresponding `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` is invalid. |

### encode

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/StrokeInputBatchExtensions.kt+function:encode) Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
public static final @NonNull byte[] encode(@NonNull StrokeInputBatch receiver)
```

Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` to the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html`.

### encode

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/StrokeInputBatchExtensions.jvmAndAndroid.kt+function:encode) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public static final void encode(@NonNull StrokeInputBatch receiver, @NonNull OutputStream output)
```

Write a gzip-compressed `ink.proto.CodedStrokeInputBatch` binary proto message representing the `https://developer.android.com/reference/androidx/ink/strokes/StrokeInputBatch` to the given `https://developer.android.com/reference/java/io/OutputStream.html`.