修改用户头像数据类型

This commit is contained in:
Mattuy Lee
2018-12-24 17:54:50 +08:00
parent f28ad69067
commit 612a5b8645
4 changed files with 80 additions and 85 deletions
@@ -4,7 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Drawing;
using System.IO; using System.IO;
//StormClient对数据的处理相关内容 //StormClient对数据的处理相关内容
@@ -100,8 +99,7 @@ namespace Interact
}; };
if (int.Parse(head[AttrNames.Photo].ToString()) > 0) if (int.Parse(head[AttrNames.Photo].ToString()) > 0)
{ {
MemoryStream ms = new MemoryStream(data); user.Photo = new MemoryStream(data);
user.Photo = Image.FromStream(ms);
} //用户头像数据 } //用户头像数据
OnLoginDone?.Invoke(resultHead, user); OnLoginDone?.Invoke(resultHead, user);
} }
@@ -171,8 +169,7 @@ namespace Interact
}; //基础数据 }; //基础数据
if (int.Parse(head[AttrNames.Photo].ToString()) > 0) if (int.Parse(head[AttrNames.Photo].ToString()) > 0)
{ {
MemoryStream ms = new MemoryStream(data); user.Photo = new MemoryStream(data);
user.Photo = Image.FromStream(ms);
} //头像数据 } //头像数据
//加入临时用户列表缓存 //加入临时用户列表缓存
User[] users; User[] users;
+3 -5
View File
@@ -222,11 +222,9 @@ namespace Interact
//将头像数据转换到字符数组 //将头像数据转换到字符数组
if (userInfo.Photo != null) if (userInfo.Photo != null)
{ {
MemoryStream memStream = new MemoryStream(); photoData = new byte[userInfo.Photo.Length];
userInfo.Photo.Save(memStream, userInfo.Photo.RawFormat); userInfo.Photo.Seek(0, SeekOrigin.Begin);
photoData = new byte[memStream.Length]; userInfo.Photo.Read(photoData, 0, photoData.Length);
memStream.Seek(0, SeekOrigin.Begin);
memStream.Read(photoData, 0, photoData.Length);
} }
//构建数据包 //构建数据包
JsonUserInfoHead jsonObj = new JsonUserInfoHead() JsonUserInfoHead jsonObj = new JsonUserInfoHead()
@@ -1,71 +1,71 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CEF054AF-95B7-4B88-934E-02705FEEA554}</ProjectGuid> <ProjectGuid>{CEF054AF-95B7-4B88-934E-02705FEEA554}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Interact</RootNamespace> <RootNamespace>Interact</RootNamespace>
<AssemblyName>Interact</AssemblyName> <AssemblyName>Interact</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>.\Newtonsoft.Json.dll</HintPath> <HintPath>.\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Client.cs" /> <Compile Include="Client.cs" />
<Compile Include="Exception.cs" /> <Compile Include="Exception.cs" />
<Compile Include="Client-Fields.cs" /> <Compile Include="Client-Fields.cs" />
<Compile Include="Client-Handle.cs" /> <Compile Include="Client-Handle.cs" />
<Compile Include="jsonObject.cs" /> <Compile Include="jsonObject.cs" />
<Compile Include="Message.cs" /> <Compile Include="Message.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Client-Read.cs" /> <Compile Include="Client-Read.cs" />
<Compile Include="Client-Send.cs" /> <Compile Include="Client-Send.cs" />
<Compile Include="AttrNames.cs" /> <Compile Include="AttrNames.cs" />
<Compile Include="User.cs" /> <Compile Include="User.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
+5 -5
View File
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Drawing; using System.IO;
namespace Interact namespace Interact
{ {
@@ -33,14 +33,14 @@ namespace Interact
} }
internal static User[] Users; //用户列表。仅Interact内部访问 internal static User[] Users; //用户列表。仅Interact内部访问
public static User Me; //当前用户 public static User Me; //当前用户
public static Image DefaultPhoto; //默认头像 public static Stream DefaultPhoto; //默认头像
public string Name; //用户名 public string Name; //用户名
public string NickName; //昵称 public string NickName; //昵称
public string Motto; //个性签名 public string Motto; //个性签名
public UserGroup Group; //用户组 public UserGroup Group; //用户组
public Image Photo; //头像 public Stream Photo; //头像
} }
//更新用户信息时新的用户信息。如果项值为null则不更改相应的信息 //更新用户信息时新的用户信息。如果项值为null则不更改相应的信息
@@ -49,7 +49,7 @@ namespace Interact
public string Password = null; //新密码 public string Password = null; //新密码
public string NickName = null; //新昵称 public string NickName = null; //新昵称
public string Motto = null; //新签名 public string Motto = null; //新签名
public Image Photo = null; //新头像 public Stream Photo = null; //新头像
} }
//用户类型 //用户类型