Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mahozad committed Feb 10, 2024
1 parent 243964b commit f220bb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,28 @@ fun Activity.captureToImageeee(comcon: CompositionContext, content: @Composable
composeView.createComposition()
composeView.setContent(content)
// composeView.setBackgroundColor(android.graphics.Color.BLUE)

// Trigger rendering of the composable; only needed for ComposeView; not needed for other view types like TextView
// setContentView(composeView)
addContentView(composeView, ViewGroup.LayoutParams(10000, 10000))
composeView.measure(
View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(10000, View.MeasureSpec.AT_MOST),
View.MeasureSpec.makeMeasureSpec(10000, View.MeasureSpec.AT_MOST),
)
composeView.layout(
0,
0,
composeView.measuredWidth,
composeView.measuredHeight
)
// this.setContentView(composeView)
// this.addContentView(composeView, ViewGroup.LayoutParams(0, 0))
@OptIn(InternalComposeUiApi::class)
composeView.showLayoutBounds = true
println("width: ${composeView.measuredWidth} height: ${composeView.measuredHeight}")
println("hasComposition: ${composeView.hasComposition}")

val bitmap = Bitmap.createBitmap(
composeView.measuredWidth, composeView.measuredHeight,
composeView.measuredWidth,
composeView.measuredHeight,
Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// https://stackoverflow.com/questions/1240967/draw-inflated-layout-xml-on-an-bitmap
// https://stackoverflow.com/questions/9062015/create-bitmap-of-layout-that-is-off-screen
// https://stackoverflow.com/questions/2661536/how-to-programmatically-take-a-screenshot-on-android
// https://stackoverflow.com/questions/29797590/android-webview-offscreen-rendering
// https://stackoverflow.com/questions/14631682/creating-and-using-a-fragments-view-whilst-not-visible-to-the-user

/**
* The compose-multiplatform-core/compose/ui/ui-test-junit4 depends on compose-multiplatform-core/compose/ui/ui-test
Expand Down

0 comments on commit f220bb6

Please sign in to comment.