public void WritePicAbsCoord(ref PointShort p) { /* var prefix = stream.ReadB(); * p.X = (ushort)(stream.ReadB() + ((prefix & 0xf0) << 4)); * p.Y = (ushort)(stream.ReadB() + ((prefix & 0x0f) << 8)); */ byte prefix = (byte)((((p.X >> 8) & 0xf) << 4) | ((p.Y >> 8) & 0xf)); AddByte(prefix); AddByte((byte)(p.X & 0xff)); AddByte((byte)(p.Y & 0xff)); }
public static PointShort ReadPicRelCoord(this Stream stream, PointShort orig) { var i = stream.ReadB(); if ((i & 0x80) == 0x80) { orig.X = (ushort)(orig.X - ((i >> 4) & 0xf)); } else { orig.X = (ushort)(orig.X + ((i >> 4) & 0xf)); } if ((i & 0x08) == 0x08) { orig.Y = (ushort)(orig.Y - (i & 7)); } else { orig.Y = (ushort)(orig.Y + (i & 7)); } return(orig); }