Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e49e38f
Added example for sharing bitmap from composables.
riggaroo Aug 18, 2023
2ffa59e
Apply Spotless
riggaroo Aug 18, 2023
df271d5
Added example for sharing bitmap from composables.
riggaroo Aug 18, 2023
51c231c
Added example for sharing bitmap from composables.
riggaroo Aug 18, 2023
ab0da68
Added example for sharing bitmap from composables.
riggaroo Aug 18, 2023
10490b1
Apply Spotless
riggaroo Aug 18, 2023
b0959e3
Added example for sharing bitmap from composables.
riggaroo Aug 18, 2023
0ebbdeb
Merge branch 'draw-into-bitmap' of https://github.com/android/snippet…
riggaroo Aug 18, 2023
e461bf1
Apply Spotless
riggaroo Aug 18, 2023
2b2008e
Add image in the shared storage instead of relying on a FileProvider …
yrezgui Aug 18, 2023
01d5734
Remove additional PictureDrawable that isn't needed.
riggaroo Aug 21, 2023
7f56801
Merge branch 'main' into draw-into-bitmap
riggaroo Aug 21, 2023
ea2fbab
Remove additional PictureDrawable that isn't needed.
riggaroo Aug 21, 2023
73edad9
add example showing how to convert between picture -> bitmap
riggaroo Aug 21, 2023
c7de49a
Add graphicsLayer transformations
riggaroo Aug 25, 2023
a24128e
Apply Spotless
riggaroo Aug 25, 2023
6d8499d
add example showing how to convert between picture -> bitmap
riggaroo Aug 25, 2023
756fc30
Merge branch 'test-graphics-layer-screenshot' of https://github.com/a…
riggaroo Aug 25, 2023
f96b68b
add example showing how to convert between picture -> bitmap
riggaroo Aug 29, 2023
9f2709c
Apply Spotless
riggaroo Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ดันคับ

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SnippetsActivity : ComponentActivity() {
TopComponentsDestination.ButtonExamples -> ButtonExamples()
TopComponentsDestination.ProgressIndicatorExamples -> ProgressIndicatorExamples()
TopComponentsDestination.ScaffoldExample -> ScaffoldExample()
TopComponentsDestination.AppBarExamples -> AppBarExamples()
TopComponentsDestination.AppBarExamples -> AppBarExamples()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.Context
import android.content.Intent
import android.content.Intent.createChooser
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Picture
import android.media.MediaScannerConnection
import android.net.Uri
Expand Down Expand Up @@ -165,6 +166,7 @@ fun BitmapFromComposableSnippet() {
drawIntoCanvas { canvas -> canvas.nativeCanvas.drawPicture(picture) }
}
}

) {
ScreenContentToCapture()
}
Expand Down Expand Up @@ -205,15 +207,19 @@ private fun ScreenContentToCapture() {

private fun createBitmapFromPicture(picture: Picture): Bitmap {
// [START android_compose_draw_into_bitmap_convert_picture]
val bitmap = Bitmap.createBitmap(
picture.width,
picture.height,
Bitmap.Config.ARGB_8888
)

val canvas = android.graphics.Canvas(bitmap)
canvas.drawColor(android.graphics.Color.WHITE)
canvas.drawPicture(picture)
val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Bitmap.createBitmap(picture)
} else {
val bitmap = Bitmap.createBitmap(
picture.width,
picture.height,
Bitmap.Config.ARGB_8888
)
val canvas = android.graphics.Canvas(bitmap)
canvas.drawColor(android.graphics.Color.WHITE)
canvas.drawPicture(picture)
bitmap
}
// [END android_compose_draw_into_bitmap_convert_picture]
return bitmap
}
Expand Down