public void Write(Stream output)
{
BitStream bits = new BitStream(output);
if (_HasScale)
{
int scaleBitsX = bits.CountNeededBitsFB(_xScaleF);
int scaleBitsY = bits.CountNeededBitsFB(_yScaleF);
int scaleBits = scaleBitsX > scaleBitsY ? scaleBitsX : scaleBitsY;
bits.WriteBits(1, 1); // HasScale
bits.WriteBits(5, scaleBits);
bits.WriteBitsFB(scaleBits, _xScaleF);
bits.WriteBitsFB(scaleBits, _yScaleF);
}
else
{
bits.WriteBits(1, 0); // Has no Scale
}
bits.WriteBits(1, 0); // has no Rotate
int translateBits = bits.CountMaximumBits(_translateX, _translateY);
bits.WriteBits(5, translateBits);
bits.WriteBits(translateBits, _translateX);
bits.WriteBits(translateBits, _translateY);
bits.WriteFlush();
}