This is an old revision of the document!
All ACS integers are 32-bit. Value packing functions let you store four 8-bit integers or two 16-bit integers in one 32-bit int
variable. This can be useful, for example, to store RGBA colors in a single variable. Or to store big arrays using less memory.
int PackBytes(int b1, int b2, int b3, int b4)
returns a 32-bit integer containing 4 bytes. Byte values must be in [0, 255] range.
int UnpackByte1(int packed)
– returns the first packed byte.int UnpackByte2(int packed)
– returns the second packed byte.int UnpackByte3(int packed)
– returns the third packed byte.int UnpackByte4(int packed)
– returns the fourth packed byte.Example:
int color = PackBytes(255, 128, 0, 255); // Orange int r = UnpackByte1(color); // 255 int g = UnpackByte2(color); // 128 int b = UnpackByte3(color); // 0 int alpha = UnpackByte4(color); // 255