Draget
11/23/2022, 8:29 PMDraget
11/23/2022, 9:15 PMCasey Brooks
11/23/2022, 9:36 PMImageBitmap
is just that, a bitmap, it’s not meant to be the interface to an image-editing subsystem. What you can do though is draw it to a Canvas
, draw your changes to that same canvas, and then capture the output with ImageComposeScene
to save it back to fileCasey Brooks
11/23/2022, 9:38 PMCanvas
element), you’ll probably want to move outside of the realm of Compose and use the Java ImageIO API insteadKirill Grouchnikov
11/23/2022, 9:42 PMDraget
11/24/2022, 6:32 AMDraget
11/24/2022, 6:39 AMimport androidx.compose.ui.res.imageResource
- something my compose desktop project simply lacks. The blog is not even that old.Draget
11/24/2022, 6:48 AMCasey Brooks
11/24/2022, 1:30 PMBitmap
class which do slightly different things. Some frameworks might allow you to modify that Bitmap in-memory, others might require you to draw it on a canvas and make the changes there. It’s a bit tricky, but in general, the way things work with Bitmaps, Canvas
, and other graphics features are probably going to to be very different in Compose vs most other things you’ll find on the internet, because Compose is declarative in its approach to drawing on the canvas.
So don’t take what you see on other frameworks as the same general principle of what you’d do in Compose. Honestly, your best bet here is to dig into the source code for Skiko (the Skia bindings used by Compose Desktop) and Compose Desktop, and see what APIs are available to you. IntelliJ’s auto-complete popup and “Jump to declaration” is your best friend here.Casey Brooks
11/24/2022, 1:38 PMDraget
11/24/2022, 3:58 PMKirill Grouchnikov
11/24/2022, 4:32 PMImageBitmap.asSkiaBitmap
to get a org.jetbrains.skia.Bitmap
. From there you can call readPixels
and installPixels
.Kirill Grouchnikov
11/24/2022, 4:39 PMImageBitmap
completely in codeKirill Grouchnikov
11/24/2022, 4:39 PMKirill Grouchnikov
11/24/2022, 4:48 PM