1
1
package com.google.firebase.quickstart.ai
2
2
3
- import android.content.Context
4
- import android.content.res.Resources
5
3
import android.graphics.Bitmap
6
- import android.graphics.BitmapFactory
7
4
import com.google.firebase.ai.ImagenModel
8
5
import com.google.firebase.ai.type.Dimensions
9
6
import com.google.firebase.ai.type.FunctionDeclaration
@@ -170,8 +167,11 @@ val FIREBASE_AI_SAMPLES = listOf(
170
167
includeAttach = true ,
171
168
allowEmptyPrompt = true ,
172
169
radioOptions = listOf (" Background" , " Foreground" ),
173
- generateImages = { model: ImagenModel , inputText: String , bitmap: Bitmap ? , selectedRadioOption: String? ->
174
- val mask = when (selectedRadioOption) {
170
+ generateImages = { model: ImagenModel ,
171
+ inputText: String ,
172
+ bitmap: Bitmap ? ,
173
+ selectedRadioOption: String? ->
174
+ val mask = when (selectedRadioOption) {
175
175
" Foreground" -> ImagenForegroundMask ()
176
176
else -> ImagenBackgroundMask ()
177
177
}
@@ -193,8 +193,11 @@ val FIREBASE_AI_SAMPLES = listOf(
193
193
includeAttach = true ,
194
194
allowEmptyPrompt = true ,
195
195
radioOptions = listOf (" Center" , " Top" , " Bottom" , " Left" , " Right" ),
196
- generateImages = { model: ImagenModel , inputText: String , bitmap: Bitmap ? , selectedRadioOption: String? ->
197
- val position = when (selectedRadioOption) {
196
+ generateImages = { model: ImagenModel ,
197
+ inputText: String ,
198
+ bitmap: Bitmap ? ,
199
+ selectedRadioOption: String? ->
200
+ val position = when (selectedRadioOption) {
198
201
" Top" -> ImagenImagePlacement .TOP_CENTER
199
202
" Bottom" -> ImagenImagePlacement .BOTTOM_CENTER
200
203
" Left" -> ImagenImagePlacement .LEFT_CENTER
@@ -253,7 +256,8 @@ val FIREBASE_AI_SAMPLES = listOf(
253
256
model.editImage(
254
257
listOf (
255
258
ImagenRawImage (MainActivity .catImage.toImagenInlineImage()),
256
- ImagenStyleReference (bitmap!! .toImagenInlineImage(), 1 , " an art style" )),
259
+ ImagenStyleReference (bitmap!! .toImagenInlineImage(), 1 , " an art style" )
260
+ ),
257
261
" Generate an image in an art style [1] based on the following caption: $inputText " ,
258
262
)
259
263
}
0 commit comments