I need a bit of help.
I have a simple binary file type i need to write out from love2d, http://www.adobe.com/devnet-apps/photos ... 7411_20528 ctrl+f and do a search for aco, and you will get to the fomat spec.
It's a super simple spec, but i'm having a few issues. On the irc i've been told to get the correct data types i can use ffi, which i've done.
Code: Select all
local ffi = require("ffi")
ffi.cdef[[
typedef struct {
double version;
double colcount;
} header;
typedef struct {
double colourid;
unsigned short int r;
unsigned short int g;
unsigned short int b;
unsigned short int undefined;
} color;
]]
colour = ffi.typeof("color")
Code: Select all
0001 0002 0000 0202 0302 2222 0000 0000
3030 4746 3d3c 0000 0002 0002 0000 0202
0302 2222 0000 0000 0009 006d 0069 0064
006e 0069 0067 0068 0074 0000 0000 3030
4746 3d3c 0000 0000 000b 0067 0072 0065
0065 006e 0020 0066 0061 0064 0065 0000
That's not everything i need but it's a start. Now my issues are, i have no idea how to convert the ffi data types to their binary counterpart and save it out as a file. It's proving to be a very difficult thing to search for.
And also of course, i can't just save a txt file with the binary data in it, (tried that) it needs to be a proper binary file which i have no idea how to save.
Any help you can give would be greatly appreciated!