J-Van
(J-Van)
1
I have the following C struct:
typedef struct
{
short Elev; /* vertex elevation */
u_char Zone; /* terrain fearture type */
u_char Mono; /* monochrome brightness value */
ulong rgb; /* rgb color components of vertex */
} cell_type
The rgb values are bitshifted into the rgb ulong, and then the rgb
ulong is converted to a network long.
Then a bunch of those structs are written into a file.
What's the Ruby way of getting the RGB values out? Is the unpack
specification "sccN"? And then I'd unpack the network long with
"cccc"?
Joe Van Dyk wrote:
I have the following C struct:
typedef struct
{
short Elev; /* vertex elevation */
u_char Zone; /* terrain fearture type */
u_char Mono; /* monochrome brightness value */
ulong rgb; /* rgb color components of vertex */
} cell_type
The rgb values are bitshifted into the rgb ulong, and then the rgb
ulong is converted to a network long.
Then a bunch of those structs are written into a file.
What's the Ruby way of getting the RGB values out? Is the unpack
specification "sccN"? And then I'd unpack the network long with
"cccc"?
IIUC, just unpack "sC6", C for unsigned char.
···
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407