I am using the latest version of Coil:
implementation("io.coil-kt:coil-compose:2.0.0-rc01")
I would like to load a barcode label image to my Jetpack Compose file for example like so:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("https://www.researchgate.net/profile/Adnan-Ghaffar/publication/313103370/figure/fig3/AS:456489858015234@1485847071322/An-example-of-barcode.png")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
This works fine the issue appears when I try to load an image from a URI like the follow one:
http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz
But it does not work, for example code I tried:
Box(modifier = Modifier.background(Color.DarkGray).fillMaxSize()) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data("http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/^xa^cfa,50^fo100,100^fdHello World^fs^xz")
.crossfade(true)
.build(),
contentDescription = "barcode image",
contentScale = ContentScale.Crop,
modifier = Modifier
)
}
More info on how to create a label .png on labelary