[Community Suggestion] Defining a Common Image Buffer Userdata

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Community Suggestion] Defining a Common Image Buffer Userdata

Tangent 128
Observation:
------------

The Lua ecosystem is currently rather weak in providing image support.

Every library I'm aware of that has use for images (Lua-SDL2, Löve[1],
G4L, Magick) implements its own image decoders, which produce an image
type unique to that library.

These libraries sometimes have provisions for exporting an image blob to
a string or lightuserdata, but often they can't reimport, and it's
hardly a common interface.

Suggestion:
-----------

Have a discussion to define a common struct layout and well-known
userdata metatable name for image rasters, to allow modules to
interoperate more easily.

Eventually then publish a reference header file that can be incorporated
into projects.

I'm working on an example I can post later, if anybody's interested.

Open Questions:
---------------

How to balance between usefulness and complexity, especially in regard
to things like stride and pixel formats?

How to keep memory safety, given this will almost certainly feature a
*data pointer?

Is it worth the work? How many projects need patches before anybody
actually sees benefit from this?

Welcoming Feedback,
~ Joseph Wallace

[1] Löve is more a custom interpreter than a library, but close enough
to be relevant.