Tangent128 / luasdl2

A pure C binding of SDL 2.0 for Lua 5.1, Lua 5.2, and LuaJIT.
ISC License
385 stars 74 forks source link

Implement getRawPixel() surface method #34

Closed basiliscos closed 9 years ago

basiliscos commented 9 years ago

Hi there!

I need to split the sprite (joint image) into separate textures before using them. The single image frame has special markers (see http://www.deviantsart.com/mn541c.png ); there is need to find those markers to determine frame size.

I have implemented Surface:getRawPixel() method to get "opaque" pixel value, the actual RGB-components aren't used/analyzed

I promise update wiki-docs (as I already done) if you accept the PR :)

WBR, basiliscos

Tangent128 commented 9 years ago

Sorry for delay.

It looks acceptable for now; the limitations of getting an opaque pixel are obvious, but if you know the format, you can decode it in Lua with string.unpack.

(Long-term, I have been thinking that a common "image" userdata that multiple projects could use would be useful, for better interoperability between SDL/GL/V4L/image codecs/etc. I'll need to pick that up eventually.)