JetBrains / skija

Java bindings for Skia
Apache License 2.0
2.63k stars 127 forks source link

Get memory buffer for the Canvas/Bitmap #138

Closed igr closed 2 years ago

igr commented 2 years ago

I would like to get a memory buffer for the Canvas.

For example, if I create:

    val surface = Surface.makeRasterN32Premul(width, height)
    val canvas = surface.canvas

how can I get a pixel matrix i.e. pixel array, where I can set pixel colors directly in memory? So I can write something likeraw[x*width + y]=0xff00ff00. Is there anything similar?

If not possible: how can I set individual pixel at some coordinate? Why there is no bitmap.setPixel?

tonsky commented 2 years ago

I think what you need is Bitmap + peekPixels