question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to manipulate raw pixel data?

See original GitHub issue

I was wondering how I can access the raw pixel byte array of an Image in Skija. After loading an Image via Image.makeFromEncoded I somehow could not find a good way to convert the Image to a Bitmap. And even if I would be able to create a Bitmap there seems no accessor for the raw byte[] of the image representing the pixels. I need to do some raw pixel manipulation (for diffing purposes).

On SkiaSharp you can create a SKBitmap either by using SKBitmap.Decode() or via SKBitmap.FromImage. The raw pixels are then accessible via skBitmap.Bytes.

Is this missing in Skija?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tonskycommented, Mar 5, 2021

Added everything except SKBitmap.Decode (will add later). Check out https://github.com/JetBrains/skija/blob/3fda7b5b74a42b2b015bebe2031fccff631fb409/examples/scenes/src/BitmapImageScene.java for examples. From your description, you should be able to do what you set up to do. Jar version 0.89.32

Screenshot 2021-03-05 at 23 40 41
1reaction
Danielku15commented, Feb 28, 2021

Thanks for the fast reply. Digging deeper I saw that there are quite some essentials missing. My use cases would be:

  1. Converting Image to Bitmap for accessing the actual image contents. Related SkiaSharp methods: SKBitmap.Decode(SKData), SKBitmap.FromImage(SKImage)
  2. Converting Bitmap to Image for saving the bitmap again to disk after manipulations. Related SkiaSharp method: SKImage.FromBitmap(SKBitmap)
  3. Access the binary data of a Bitmap for raw pixel manipulations. I want to do diffing of images with anti-alias detection, basically a port of PixelMatch. Related SkiaSharp property: SKBitmap.Bytes
  4. Converting a raw pixel byte array to a Bitmap/Image for further saving. The pixels which differ are written to a raw byte array. To save these “diff” pixels as PNG to disk I need to create an image out of it. Related SkiaSharp method: SKImage.FromPixels(SKImageInfo, SKData)

Hope this helps as input to cover my needs 😁 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pixel manipulation with canvas - Web APIs | MDN
The data property returns a Uint8ClampedArray which can be accessed to look at the raw pixel data; each pixel is represented by four...
Read more >
Manipulating Raw Pixel Data in Canvas: HTML5 - YouTube
http://technotip.com/3421/accessing- raw - pixel - data -in-canvas-html5/Today lets learn how to access individual pixel data on canvas, ...
Read more >
D Raw Pixel Format
The raw pixel format is useful for applications that need direct access to the pixel data without the encumbrance of the complex computations...
Read more >
Modifying raw image data for experiments
Modifying raw image data for experiments ; Convert the raw file to a PGM by running unprocessed_raw <raw filename> ; Load the PGM...
Read more >
Accessing Raw Pixel Data in Canvas: HTML5 - Technotip.com
We draw an image on to the canvas using drawImage() method. Once we draw the image, we get all the raw pixel data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found