public byte[] GetPacketData() // 바이트형 패킷(송신용) { ResourceDataSerializer serializer = new ResourceDataSerializer(); serializer.Serialize(m_data); return(serializer.GetSerializedData()); }
public bool SaveFont(string resourceFile, string fontName, string imageFileRoot) { if (Path.IsPathRooted(resourceFile) == false) { resourceFile = Path.Combine(Directory.GetCurrentDirectory(), resourceFile); } string localImagePartialPath; string dir = Path.GetDirectoryName(resourceFile); if (Path.IsPathRooted(imageFileRoot) == false) { localImagePartialPath = imageFileRoot; imageFileRoot = Path.Combine(Path.GetDirectoryName(resourceFile), imageFileRoot); } else { localImagePartialPath = GetRelativePath(dir, imageFileRoot); } localImagePartialPath = localImagePartialPath.Replace(Path.DirectorySeparatorChar.ToString(), "/"); FontResource fontResource = new FontResource(); foreach (var fs in Font.FontSurfaces) { var res = new FontSurfaceResource(); var localImagePath = localImagePartialPath + "-" + fs.Key.ToString() + ".png"; var impl = (BitmapFontImpl)fs.Value.Impl; res.Name = fontName; res.Image = localImagePath; res.Metrics = impl.FontMetrics.Clone(); res.Size = fs.Key.Size; res.Style = fs.Key.Style; var imagePath = Path.Combine(dir, localImagePath); var surface = (Surface)impl.Surface; surface.SaveTo(imagePath); fontResource.Add(res); } var fonts = new FontResourceCollection { { fontName, fontResource } }; var resLoader = new ResourceDataSerializer(); var result = resLoader.Serialize(fonts); File.WriteAllText(resourceFile, result); return(true); }