Skip to content

Commit 5d70c86

Browse files
committed
[Vertex AI] Return ImagenInlineImage.data as binary
1 parent c1ca021 commit 5d70c86

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenGenerationResponse.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.firebase.vertexai.type
1818

19+
import android.util.Base64
1920
import com.google.firebase.vertexai.ImagenModel
2021
import kotlinx.serialization.Serializable
2122

@@ -53,7 +54,7 @@ internal constructor(public val images: List<T>, public val filteredReason: Stri
5354
val raiFilteredReason: String? = null,
5455
) {
5556
internal fun toPublicInline() =
56-
ImagenInlineImage(bytesBase64Encoded!!.toByteArray(), mimeType!!)
57+
ImagenInlineImage(Base64.decode(bytesBase64Encoded!!, Base64.NO_WRAP), mimeType!!)
5758

5859
internal fun toPublicGCS() = ImagenGCSImage(gcsUri!!, mimeType!!)
5960
}

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ImagenInlineImage.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package com.google.firebase.vertexai.type
1818

1919
import android.graphics.Bitmap
2020
import android.graphics.BitmapFactory
21-
import android.util.Base64
2221

2322
/**
2423
* Represents an Imagen-generated image that is contained inline
@@ -34,7 +33,6 @@ internal constructor(public val data: ByteArray, public val mimeType: String) {
3433
* Returns the image as an Android OS native [Bitmap] so that it can be saved or sent to the UI.
3534
*/
3635
public fun asBitmap(): Bitmap {
37-
val data = Base64.decode(data, Base64.NO_WRAP)
3836
return BitmapFactory.decodeByteArray(data, 0, data.size)
3937
}
4038
}

0 commit comments

Comments
 (0)