Manel Martos
06/10/2024, 3:29 PMManel Martos
06/10/2024, 3:30 PMuniform float2 iResolution;
uniform shader iBitmap;
half4 main(vec2 fragCoord) {
half4 col = iBitmap.eval(fragCoord);
return half4(col.rgb, 1.);
}
Manel Martos
06/10/2024, 3:32 PMchild
function:
child("iBitmap", ImageShader(imageBitmap))
Kirill Grouchnikov
06/10/2024, 7:43 PMKirill Grouchnikov
06/10/2024, 7:49 PMManel Martos
06/11/2024, 7:29 AMManel Martos
06/11/2024, 11:58 AMchild(it.name, Shader.Companion.makeColor(Color.RED))
Manel Martos
06/11/2024, 11:58 AMKirill Grouchnikov
06/11/2024, 1:37 PMManel Martos
06/11/2024, 1:50 PMcomposeResources
using imageResource
. After adding some logs around the returned bitmap, I realised that the image size was 1x1. Probably some asynchronous loading mechanism is in place for the web. I tried to load and decode the image explicitly, and the issue is now sorted out. This is the code I'm using for loading and decoding it:
var bitmap by remember { mutableStateOf<Image?>(null) }
LaunchedEffect(Unit) {
val byteArray = getDrawableResourceBytes(
getSystemResourceEnvironment(),
Res.drawable.img_03
)
bitmap = makeFromEncoded(byteArray)
}
Not the best code but works fine on my use case.