Status Update
Comments
so...@google.com <so...@google.com>
nj...@google.com <nj...@google.com> #2
Hi. Thanks for reporting this. Fixed in alpha-04
ma...@gmail.com <ma...@gmail.com> #3
Branch: androidx-main
commit e782987543a9f8ccd485e970ddc74564b24378db
Author: Vighnesh Raut <vighnesh.raut13@gmail.com>
Date: Mon Jan 02 15:27:40 2023
fix: tab row crashes when only 1 tab is added
Bug:
Test: Added unit test
Change-Id: I6381dbac304fc1d69d3708c6655f8b595668e93f
M tv/tv-material/src/androidTest/java/androidx/tv/material/TabRowTest.kt
M tv/tv-material/src/main/java/androidx/tv/material/TabRow.kt
nj...@google.com <nj...@google.com> #4
ma...@gmail.com <ma...@gmail.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.tv:tv-material:1.0.0-alpha04
nj...@google.com <nj...@google.com> #6
Thanks! Can you share the code for these snippets as well?
From the screenshots it looks like you may need to have a higher resolution image per resource drawable buckets as well. Would you happen to know the display density of the Android device that this is running on?
ma...@gmail.com <ma...@gmail.com> #7
The resource is a 16x16 pixel art. I cannot have an higher resolution version. The resources are taken from a pixel art game because the app is a sort of companion for that game so it uses the same resources of the game.
ma...@gmail.com <ma...@gmail.com> #8
I cannot share a code snippet now but I've used the same approach exposed in that answer on Stack overflow
nj...@google.com <nj...@google.com> #9
Thanks for the screenshots.
I think you can do the following as a workaround to draw the pixel art image directly with anti-aliasing disabled:
val imageBitmap = BitmapFactory.decodeResource(
LocalContext.current.resources,
R.drawable.my_pixel_art
).asImageBitmap()
val paint = remember {
Paint().apply {
isAntiAlias = false
}
}
Canvas(modifier = Modifier.fillMaxSize()) { // DrawScope
drawIntoCanvas { canvas ->
canvas.drawImage(imageBitmap, Offset.Zero, paint)
}
}
ro...@google.com <ro...@google.com> #10
It's filtering you want to disable for pixel art, not anti-aliasing (although you may want that too when the image is rotated or uses subpixel positioning).
ma...@gmail.com <ma...@gmail.com> #11
I ended up using a custom Painter. The painter is almost identical to BitmapPainter
, I have overwritten only DrawScope.onDraw
private val customPaint = Paint().apply {
asFrameworkPaint().apply {
this.isDither = false
this.isFilterBitmap = false
this.isAntiAlias = false
}
}
override fun DrawScope.onDraw() {
drawIntoCanvas {
it.drawImageRect(
image = image,
srcSize = srcSize,
srcOffset = srcOffset,
dstSize = IntSize(
this@onDraw.size.width.roundToInt(),
this@onDraw.size.height.roundToInt()
),
paint = customPaint
)
}
}
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 5df92271b6eac729464aea71f9691acd21983777
Author: Nader Jawad <njawad@google.com>
Date: Tue Jul 13 12:35:20 2021
Add support for FilterQuality in DrawScope
Relnote: "Updated DrawScope#drawImage method that
consumes source and destination rects
to consume an optional FilterQuality
parameter. This is useful for pixel
art that is intended to be pixelated
when scaled up for pixel based art.
Updated BitmapPainter + Image composable
to also consume an optional FilterQuality
parameter"
Fixes: 180311607
Test: Added various tests to DrawScopeTest,
BitmapPainterTest and ImageTest
Change-Id: Ie4fb04013701add0fba1c5c6bb9da2812d6436e7
M compose/foundation/foundation/api/current.ignore
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.ignore
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Image.kt
D compose/material/material/api/current.ignore
D compose/material/material/api/restricted_current.ignore
D compose/ui/ui-graphics/api/current.ignore
M compose/ui/ui-graphics/api/current.txt
M compose/ui/ui-graphics/api/public_plus_experimental_current.txt
D compose/ui/ui-graphics/api/restricted_current.ignore
M compose/ui/ui-graphics/api/restricted_current.txt
M compose/ui/ui-graphics/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/drawscope/DrawScopeTest.kt
M compose/ui/ui-graphics/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/painter/BitmapPainterTest.kt
M compose/ui/ui-graphics/src/commonMain/kotlin/androidx/compose/ui/graphics/Paint.kt
M compose/ui/ui-graphics/src/commonMain/kotlin/androidx/compose/ui/graphics/drawscope/CanvasDrawScope.kt
M compose/ui/ui-graphics/src/commonMain/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope.kt
M compose/ui/ui-graphics/src/commonMain/kotlin/androidx/compose/ui/graphics/painter/BitmapPainter.kt
D compose/ui/ui-text/api/current.ignore
D compose/ui/ui-text/api/restricted_current.ignore
Description
Jetpack Compose release version: 1.0.0-alpha12
I would like to ask to allow to disable the antialiasing when using the
Image
composable. Paint has an antialiasing property but it's not exposed by the painter object used to draw the image.There is currently no easy way to disable the antialiasing without creating a custom painter and using a Paint object that is not the one passed to the DrawScope of the painter.
With SwiftUi I can simply use
func antialiased(Bool) -> Image
that is an extension ofImage