Bagadeshkumar R
08/23/2022, 6:31 AMeygraber
08/23/2022, 11:55 AMjw
08/23/2022, 2:08 PMenighma
08/23/2022, 7:59 PMFont transform has NaN position
when I try to start the app. I can't understand what is causing it, or why it goes away after a while.
I see there's an issue for it: https://github.com/JetBrains/compose-jb/issues/2098
Does anyone know what causes it? and if there's a workaround?eygraber
08/24/2022, 1:03 AMoianmol
08/25/2022, 4:14 PMspierce7
08/26/2022, 1:55 PMspierce7
08/29/2022, 4:39 AMContents/MacOS/<app name>
file that is a unix binary. Somehow this unix binary is starting up the JVM, and running the JVM inside the same process as the unix binary (at least that’s what it looks like is happening externally).
How is this possible?
I’m asking because I’m wondering if I could replace the unix binary with a Kotlin Native application that checks for and watches for app updates, and then can restart my application to force an update if necessary.Radoslaw Juszczyk
08/29/2022, 7:34 AMnewWindow.initModality(Modality.WINDOW_MODAL)
newWindow.initOwner(parentStage)
Long Tran
08/29/2022, 10:06 AMloadOrNull { loadResourceAnimatedImage(path) }?.animate() ?: ImageBitmap.Blank
@Composable
actual fun AnimatedImage.animate(): ImageBitmap {
when (codec.frameCount) {
0 -> return ImageBitmap.Blank // No frames at all
1 -> {
// Just one frame, no animation
val bitmap = remember(codec) { Bitmap().apply { allocPixels(codec.imageInfo) } }
remember(bitmap) {
codec.readPixels(bitmap, 0)
}
return bitmap.asComposeImageBitmap()
}
else -> {
val transition = rememberInfiniteTransition()
val frameIndex by transition.animateValue(
initialValue = 0,
targetValue = codec.frameCount - 1,
Int.VectorConverter,
animationSpec = infiniteRepeatable(
animation = keyframes {
durationMillis = 0
for ((index, frame) in codec.framesInfo.withIndex()) {
index at durationMillis
val frameDuration = calcFrameDuration(frame)
durationMillis += frameDuration
}
}
)
)
val bitmap = remember(codec) { Bitmap().apply { allocPixels(codec.imageInfo) } }
remember(bitmap, frameIndex) {
codec.readPixels(bitmap, frameIndex)
}
return bitmap.asComposeImageBitmap()
}
}
}
Lucas
08/29/2022, 5:30 PMThomas
08/30/2022, 7:45 PMzt
08/30/2022, 8:33 PMSwingPanel
use a transparent background? I tried passing Color.Transparent
to the background parameter but that didn't workRadoslaw Juszczyk
08/30/2022, 9:51 PMrememberWindowState(size = DpSize(250.dp, 200.dp))
the window is not actually 250dp wide?
I mean state says it is, but it doesnt fit 250dp of content (five 50dp-wide boxes should be fully visible):Yevhen Tienkaiev
08/30/2022, 9:52 PMAdam Brown
08/30/2022, 10:55 PMcomposeUi
module, and commonMain
includes the multiplatform compose artifacts. And I'm able to write desktop specific compose code inside my desktopMain
JVM source set, but then when I try to write some Android specific compose in the androidMain
source set, it doesn't know about the compose dependencies at all. Has anyone else run into this?zt
08/31/2022, 1:49 AM@OptIn(ExperimentalComposeLibrary::class)
implementation(compose.material3)
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
}
Jerry Yion
08/31/2022, 2:11 AMjava.lang.ClassCastException: androidx.compose.runtime.internal.ComposableLambdaImpl cannot be cast to kotlin.jvm.functions.Function2
deviant
08/31/2022, 8:23 AMspierce7
08/31/2022, 8:23 PMenighma
08/31/2022, 11:34 PMRadoslaw Juszczyk
09/01/2022, 11:17 AMinterface AssetsFactory {
fun createTextImage(text:String, padding: Int, backgroundColor: Color): File
}
With JavaFX I would simply create a layout and use SwingFXUtils.fromFXImage
I want something like:
fun createImageFile(size: IntSize, content: @Composable ()-> Unit): BufferedImage
Any ideas/suggestions?David W
09/01/2022, 10:55 PM@Composable
fun SmolTooltipBackground(modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Box(
modifier = modifier
.pointerMoveFilter(
onEnter = {
println("On Mouse(pointer) Enter")
// can i cancel/hide this composable from here?
false
})
) {
content.invoke()
}
}
oianmol
09/03/2022, 4:16 PMJohn Aoussou
09/04/2022, 12:08 PMdarkmoon_uk
09/04/2022, 1:14 PMRuntimeEffect
doesn't resolve.spierce7
09/06/2022, 9:19 PMStefan Oltmann
09/07/2022, 9:53 AMImageComposeScene
with this code to take screenshots of my Composables which works fine for most things.
But now I got a Composable which shows an Image
Composable after a produceState()
loaded the BitmapPainter
.
As long as the bitmapPainter has the initialValue of null is just displays an empty Box
as placeholder.
My question now is how I can let ImageComposeScene
wait until the produceState()
executed and re-composed until taking the screenshot. Now the screenshot is taken immediately after the first composition which leaves me with an empty Box
.
val bitmapPainter = produceState<BitmapPainter?>(initialValue = null, thumbnailFileName) {
value = withContext(Dispatchers.Default) {
val image = imageLoader.loadThumbnailImage(thumbnailFileName)
?: return@withContext null
return@withContext BitmapPainter(image = image)
}
}
@OptIn(ExperimentalComposeUiApi::class)
fun takeScreenshot(content: @Composable () -> Unit): ByteArray {
ImageComposeScene(
width = 1024,
height = 768,
density = Density(1f),
content = content
).use {
return@takeScreenshot it.render().encodeToData(EncodedImageFormat.PNG)!!.bytes
}
}
Stefan Oltmann
09/09/2022, 9:51 AMImageComposeScene
on different devices I get different screenshots. Difference is in scale of the Composables. I suspect that the devices DPI plays a role here and try to find out if I can set that to a fixed value for rendering.Stefan Oltmann
09/09/2022, 12:38 PMswiftshader_indirect
).Stefan Oltmann
09/09/2022, 12:38 PMswiftshader_indirect
).Igor Demin
09/09/2022, 1:19 PMStefan Oltmann
09/09/2022, 1:21 PMIgor Demin
09/09/2022, 1:22 PMImageComposeScene
, that is always rendered with software renderer.Stefan Oltmann
09/09/2022, 1:22 PMprivate val imageVectorCache = mutableMapOf<VectorRes, ImageVector>()
@Composable
actual fun painter(res: VectorRes): Painter {
val imageVector = imageVectorCache.getOrPut(res) {
val inputSource = object : InputSource() {
override fun getByteStream() = openResource(res.path)
}
loadXmlImageVector(inputSource, LocalDensity.current)
}
return rememberVectorPainter(imageVector)
}
private fun openResource(resourcePath: String): InputStream {
val classLoader = Thread.currentThread().contextClassLoader!!
return requireNotNull(classLoader.getResourceAsStream(resourcePath)) {
"Resource $resourcePath not found"
}
}
Igor Demin
09/09/2022, 3:03 PMSystem preferences -> Display
Also, Skia can use some platform API’s for rasterisation. For example, for antialiasing. But I am not sure about it too.
Also, different platforms/versions can do math differently, and we can have some round error for colors (+-1)Stefan Oltmann
09/09/2022, 3:40 PMsaket
09/11/2022, 7:24 AMStefan Oltmann
09/12/2022, 8:06 AMAlso, different platforms/versions can do math differently, and we can have some round error for colors (+-1)
skia.Bitmap.getColor()
on CI.
I take that as the final sign that I'm just not supposed to compare screenshots on CI. 🙈
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000012f6949dd, pid=23658, tid=6147
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.4+8 (17.0.4+8) (build 17.0.4+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (17.0.4+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
# Problematic frame:
# C [libskiko-macos-x64.dylib+0xf69dd] _ZNK8SkPixmap8getColorEii+0x2cd
Compiled method (n/a) 19811 2768 n 0 org.jetbrains.skia.BitmapKt::Bitmap_nGetColor (native)
val expectedBitmap = Bitmap.makeFromImage(Image.makeFromEncoded(expectedImageBytes))
val actualBitmap = Bitmap.makeFromImage(Image.makeFromEncoded(actualImageBytes))
if (!expectedBitmap.isEquals(actualBitmap, tolerance = 3)) {
fail("Image $fileName is not equal to reference image.")
}
private fun Bitmap.isEquals(other: Bitmap, tolerance: Int = 0): Boolean {
if (this.width != other.width || this.height != other.height)
return false
for (x in 0..width) {
for (y in 0..height) {
val thisColor = this.getColor(x, y)
val otherColor = other.getColor(x, y)
if (thisColor != otherColor) {
val redDelta = abs(getRed(thisColor) - getRed(otherColor))
val greenDelta = abs(getGreen(thisColor) - getGreen(otherColor))
val blueDelta = abs(getBlue(thisColor) - getBlue(otherColor))
if (redDelta > tolerance || greenDelta > tolerance || blueDelta > tolerance)
return false
}
}
}
return true
}
private fun getRed(pixelValue: Int) =
pixelValue and (255 shl 16) shr 16
private fun getGreen(pixelValue: Int) =
pixelValue and (255 shl 8) shr 8
private fun getBlue(pixelValue: Int) =
pixelValue and 255