natiny.resource.from_data
Lua
local resource = natiny.resource.from_data(data)
Creates a resource from bytes already in memory.
Parameters
| Name |
Type |
Description |
data |
string |
Raw bytes as a binary-safe Lua string |
Returns
| Type |
Description |
number |
Resource handle |
Example
Lua
local embedded = string.char(0x89, 0x50, 0x4E, 0x47) -- PNG signature bytes
local res = natiny.resource.from_data(embedded)
natiny.resource.destroy(res)
Notes
- The bytes are copied. The original Lua string can be released or changed
after this function returns.