From 612a5b8645acc753ebb341b357051dafa8cc87c4 Mon Sep 17 00:00:00 2001 From: Mattuy Lee Date: Mon, 24 Dec 2018 17:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interact/Client-Handle.cs | 7 +- stormchat-client-csharp/Interact/Client.cs | 8 +- .../Interact/Interact.csproj | 140 +++++++++--------- stormchat-client-csharp/Interact/User.cs | 10 +- 4 files changed, 80 insertions(+), 85 deletions(-) diff --git a/stormchat-client-csharp/Interact/Client-Handle.cs b/stormchat-client-csharp/Interact/Client-Handle.cs index 4d66c96..827379c 100644 --- a/stormchat-client-csharp/Interact/Client-Handle.cs +++ b/stormchat-client-csharp/Interact/Client-Handle.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using System.Drawing; using System.IO; //StormClient对数据的处理相关内容 @@ -100,8 +99,7 @@ namespace Interact }; if (int.Parse(head[AttrNames.Photo].ToString()) > 0) { - MemoryStream ms = new MemoryStream(data); - user.Photo = Image.FromStream(ms); + user.Photo = new MemoryStream(data); } //用户头像数据 OnLoginDone?.Invoke(resultHead, user); } @@ -171,8 +169,7 @@ namespace Interact }; //基础数据 if (int.Parse(head[AttrNames.Photo].ToString()) > 0) { - MemoryStream ms = new MemoryStream(data); - user.Photo = Image.FromStream(ms); + user.Photo = new MemoryStream(data); } //头像数据 //加入临时用户列表缓存 User[] users; diff --git a/stormchat-client-csharp/Interact/Client.cs b/stormchat-client-csharp/Interact/Client.cs index c0560c5..e26d1ac 100644 --- a/stormchat-client-csharp/Interact/Client.cs +++ b/stormchat-client-csharp/Interact/Client.cs @@ -222,11 +222,9 @@ namespace Interact //将头像数据转换到字符数组 if (userInfo.Photo != null) { - MemoryStream memStream = new MemoryStream(); - userInfo.Photo.Save(memStream, userInfo.Photo.RawFormat); - photoData = new byte[memStream.Length]; - memStream.Seek(0, SeekOrigin.Begin); - memStream.Read(photoData, 0, photoData.Length); + photoData = new byte[userInfo.Photo.Length]; + userInfo.Photo.Seek(0, SeekOrigin.Begin); + userInfo.Photo.Read(photoData, 0, photoData.Length); } //构建数据包 JsonUserInfoHead jsonObj = new JsonUserInfoHead() diff --git a/stormchat-client-csharp/Interact/Interact.csproj b/stormchat-client-csharp/Interact/Interact.csproj index 7b2a3cb..1142023 100644 --- a/stormchat-client-csharp/Interact/Interact.csproj +++ b/stormchat-client-csharp/Interact/Interact.csproj @@ -1,71 +1,71 @@ - - - - - Debug - AnyCPU - {CEF054AF-95B7-4B88-934E-02705FEEA554} - Library - Properties - Interact - Interact - v4.0 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - .\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - + + + + + Debug + AnyCPU + {CEF054AF-95B7-4B88-934E-02705FEEA554} + Library + Properties + Interact + Interact + v4.0 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + .\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/stormchat-client-csharp/Interact/User.cs b/stormchat-client-csharp/Interact/User.cs index 5976cc1..642ec48 100644 --- a/stormchat-client-csharp/Interact/User.cs +++ b/stormchat-client-csharp/Interact/User.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Drawing; +using System.IO; namespace Interact { @@ -33,14 +33,14 @@ namespace Interact } internal static User[] Users; //用户列表。仅Interact内部访问 - public static User Me; //当前用户 - public static Image DefaultPhoto; //默认头像 + public static User Me; //当前用户 + public static Stream DefaultPhoto; //默认头像 public string Name; //用户名 public string NickName; //昵称 public string Motto; //个性签名 public UserGroup Group; //用户组 - public Image Photo; //头像 + public Stream Photo; //头像 } //更新用户信息时新的用户信息。如果项值为null则不更改相应的信息 @@ -49,7 +49,7 @@ namespace Interact public string Password = null; //新密码 public string NickName = null; //新昵称 public string Motto = null; //新签名 - public Image Photo = null; //新头像 + public Stream Photo = null; //新头像 } //用户类型