thorvg / thorvg

Thor Vector Graphics is a lightweight portable library used for drawing vector-based scenes and animations including SVG and Lottie. It can be freely utilized across various software platforms and applications to visualize graphical contents.
https://www.thorvg.org
MIT License
681 stars 104 forks source link

Picture raw load data format is unclear #2648

Closed QuLogic closed 3 weeks ago

QuLogic commented 1 month ago

The raw Picture::load overload takes a uint32_t *data described as "A pointer to a memory location where the content of the picture raw data is stored." However, that page does not define what "picture raw data" means.

Is it ARGB, or ABGR? Is it premultiplied or not? Given that SwCanvas accepts all combinations of those as its Colorspace but GlCanvas/WgCanvas don't, I don't know which one is expected.

Is it column major or row major order? Usually images are row-major order, so I expect that, but since it's a unspecified pointer shape, it's not clear.

There is also a premultiplied argument documented, but that isn't in the signature AFAICT.

QuLogic commented 1 month ago

There is also a premultiplied argument documented, but that isn't in the signature AFAICT.

Ah, this one is documented in the 0.14.4 release, but not actually there. However, it is in the API on main.

Still, the question of memory order remains.

hermet commented 1 month ago

@QuLogic Hello, currently, it supports only ARGB8888. The API should be revised to allow for different color spaces, but we haven’t done that yet. Also, you don’t need to worry about the GL/WG Canvas for this, as the renderer will handle the color format adjustments for the backend engines.

Issue: https://github.com/thorvg/thorvg/issues/1372 image

Please let us know if another specific format for raw data is necessary for you right now.

QuLogic commented 1 month ago

I think at this time, I can work with any colour space format; it just should be documented.

For the current 0.14.5 which doesn't have the premultiplied parameter, is the data premultiplied?

hermet commented 1 month ago

For the current 0.14.5 which doesn't have the premultiplied parameter, is the data premultiplied?

yes => https://github.com/thorvg/thorvg/commit/82563bf29a5be71178137611dbff305c7296b92c