Module fipMemoryIO
Corona wrapper for fipMemoryIO, a memory handle class that allows you to load / save images from / to a memory stream.
Functions
fipMemoryIO:acquire (as_table) | Provides a direct buffer access to a memory stream. |
fipMemoryIO:close () | Free any allocated memory and invalidate the stream. |
fipMemoryIO:getFileType () | Returns the buffer image format. |
fipMemoryIO:isValid () | Indicates whether the memory handle is valid for use. |
fipMemoryIO:load (fif, flags) | Loads a dib from a memory stream. |
fipMemoryIO:loadMultiPage () | Loads a multi-page bitmap from a memory stream. |
fipMemoryIO:read (size, count) | Reads data from a memory stream. |
fipMemoryIO:save (fif, dib, flags) | Saves a dib to a memory stream. |
fipMemoryIO:saveMultiPage () | Saves a multi-page bitmap to a memory stream. |
fipMemoryIO:seek (offset, origin) | Moves the memory pointer to a specified location. |
fipMemoryIO:tell () | Gets the current position of a memory pointer. |
fipMemoryIO:write (buffer, size, count) | Writes data to a memory stream. |
Functions
- fipMemoryIO:acquire (as_table)
-
Provides a direct buffer access to a memory stream.
TODO: I suppose this is meant to be writeable...
NOTE: buggy if failed (returns too many results)
Parameters:
- as_table bool Get the bytes as a table? (TODO: users can already just do string.byte()...)
Returns:
- boolean Acquire succeeded?
- string Byte stream. (TODO: or table, but see other notes)
- fipMemoryIO:close ()
- Free any allocated memory and invalidate the stream.
- fipMemoryIO:getFileType ()
-
Returns the buffer image format.
Returns:
-
string
Format, cf. enums.FREE_IMAGE_FORMAT.
- fipMemoryIO:isValid ()
-
Indicates whether the memory handle is valid for use.
Returns:
-
boolean
Internal memory buffer is a valid buffer?
- fipMemoryIO:load (fif, flags)
-
Loads a dib from a memory stream.
Parameters:
- fif string Format identifier, cf. enums.FREE_IMAGE_FORMAT.
- flags {string,...}, string or nil Format-dependent flags.
Returns:
-
userdata or nil
On success, the loaded dib; otherwise nil. (TODO: More robust?)
- fipMemoryIO:loadMultiPage ()
- Loads a multi-page bitmap from a memory stream. NYI
- fipMemoryIO:read (size, count)
-
Reads data from a memory stream.
Parameters:
- size uint Item size in bytes.
- count uint Maximum number of items to be read.
Returns:
-
string
Bytes read. (TODO: okay? not what FreeImageType does "Returns the number of full items actually read,
which may be less than count if an error occurs")
- fipMemoryIO:save (fif, dib, flags)
-
Saves a dib to a memory stream.
Parameters:
- fif string Format identifier, cf. enums.FREE_IMAGE_FORMAT.
- dib userdata Dib to save. (TODO: More robust?)
- flags {string,...}, string or nil Format-dependent flags.
Returns:
-
boolean
Save succeeded?
- fipMemoryIO:saveMultiPage ()
- Saves a multi-page bitmap to a memory stream. NYI
- fipMemoryIO:seek (offset, origin)
-
Moves the memory pointer to a specified location.
Parameters:
- offset int
- origin int
Returns:
-
boolean
Seek succeeded?
- fipMemoryIO:tell ()
-
Gets the current position of a memory pointer.
Returns:
-
int
Position.
- fipMemoryIO:write (buffer, size, count)
-
Writes data to a memory stream.
Parameters:
- buffer string Pointer to data to be written. (TODO: use __bytes protocol?)
- size uint Item size in bytes
- count uint Maximum number of items to be written.
Returns:
-
uint
The number of full items actually written, which may be less than count if an error occurs.