Hi,
I have a binary file that contains a bunch of unsigned longs in
network byte order. Each long contains 4 unsigned ints.
In C, I'd do:
rgb_long = ntohl(rgb_long);
/* Extract out the red, green, and blue elements from the
* RGB long. */
red = rgb_long << 0 >> 24;
green = rgb_long << 8 >> 24;
blue = rgb_long << 16 >> 24;
In Ruby, I have:
# I have the long in host byte order, but it's now a FixNum.
rgb = binary_data.unpack("N")[0]
# Works, but byte order is messed up
r, g, b = binary_data.unpack("CCCC")
Ideas?
Thanks,
joe