public static void WriteImageEntity(this Stream stream, ImageEntity entity) { var data = entity.Picture.ToArray(); if (entity.Compress != Compress.NONE) { data = FreeImage.Compress(data); } stream.WriteString(ENTITY_FLAG); stream.WriteInt((int)entity.Type); stream.WriteInt((int)entity.Compress); stream.WriteInt(entity.Width); stream.WriteInt(entity.Height); stream.WriteInt(data.Length); stream.WriteInt(entity.X); stream.WriteInt(entity.Y); stream.WriteInt(entity.Canvas_Width); stream.WriteInt(entity.Canvas_Height); stream.Write(data); }