Skip to content

Commit

Permalink
修复无法直接转换QQ图片的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liesauer committed Apr 8, 2022
1 parent d0cf987 commit 3206e0e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions pic2meme/ChangeLogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public ChangeLogWindow()
this.MinWidth = this.MaxWidth = this.Width;
this.MinHeight = this.MaxHeight = this.Height;
ChangeLog.Text = @"
v1.2.1 - 2022/04/08
1. 修复无法直接转换QQ图片的问题
v1.2.0 - 2022/03/21
1. 支持转换网页图片
Expand Down
2 changes: 1 addition & 1 deletion pic2meme/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:pic2meme" xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Title="微信表情包工具 v1.2" Height="499.632" Width="463.297" AllowDrop="True" Drop="Window_Drop" KeyDown="Window_KeyDown" ResizeMode="CanMinimize">
Title="微信表情包工具 v1.2.1" Height="499.632" Width="463.297" AllowDrop="True" Drop="Window_Drop" KeyDown="Window_KeyDown" ResizeMode="CanMinimize">
<Grid>
<Label x:Name="Notice" Content="拖动或粘贴图片到此处进行表情包转换" FontSize="22" Margin="30,20,0,0" VerticalAlignment="Top" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Width="395" />
<hc:GifImage x:Name="Preview" Stretch="Uniform" Height="201" Margin="127,144,0,126" HorizontalAlignment="Left" Width="201" />
Expand Down
21 changes: 13 additions & 8 deletions pic2meme/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ private async void pic2meme()
var bodyIndex = html.IndexOf("<!--StartFragment-->");
if (bodyIndex != -1)
{
var bodyIndex2 = html.IndexOf("<!--EndFragment-->", bodyIndex);
var startPos = bodyIndex + "<!--StartFragment-->".Length;

var bodyIndex2 = html.IndexOf("<!--EndFragment-->", startPos);
if (bodyIndex2 != -1)
{
var startPos = bodyIndex + "<!--StartFragment-->".Length;
body = html.Substring(startPos, bodyIndex2 - startPos);
}
}
Expand All @@ -123,15 +124,19 @@ private async void pic2meme()
return;
}

var xml = new XmlDocument();
xml.LoadXml(body);
var imgUrl = "";

if (xml.ChildNodes.Count != 1 || xml.FirstChild.Name != "img" || xml.FirstChild.Attributes["src"] == null)
var imgIndex = body.IndexOf(@"<img src=""");
if (imgIndex != -1)
{
return;
}
var startPos = imgIndex + @"<img src=""".Length;

var imgUrl = xml.FirstChild.Attributes["src"].Value;
var imgIndex2 = body.IndexOf(@"""", startPos);
if (imgIndex2 != -1)
{
imgUrl = body.Substring(startPos, imgIndex2 - startPos);
}
}

using (WebClient client = new WebClient())
{
Expand Down
2 changes: 0 additions & 2 deletions pic2meme/pic2meme.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
Expand Down

0 comments on commit 3206e0e

Please sign in to comment.