This commit is contained in:
1415ddfer 2024-05-12 16:43:07 +08:00
parent 52393d8d67
commit ff2a27a08d
10 changed files with 192 additions and 199 deletions

View File

@ -12,6 +12,7 @@ namespace Zerolauncher.Manager
public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0"; public const string MasterMessage = "54aeb77c47b967d22c2c1396d00d91f0";
public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5"; public const string SummerMessage = "037846c482eddc948612b0d0f8ed98d5";
public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce"; public const string LoveMessage = "539e3389078daa765ac0abdcc97eebce";
public const string TWMasterMessage = "3ca068a2cdb1ee85fc1152ff6cabefcd";
} }
class UpDateData class UpDateData
@ -37,7 +38,7 @@ namespace Zerolauncher.Manager
try try
{ {
client.Timeout = TimeSpan.FromMinutes(3); client.Timeout = TimeSpan.FromMinutes(3);
response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.MasterMessage}"); response = await client.GetAsync($"{StaticUrl.QMessageMain}{StaticUrl.TWMasterMessage}");
} }
catch (Exception _ex) catch (Exception _ex)
{ {

View File

@ -71,8 +71,8 @@ namespace Zerolauncher.Manager
public class Account public class Account
{ {
public int providerId; public int providerId, serverId;
public string userName, userPWD, nickName, serverId; public string userName, userPWD, nickName;
} }
class Group class Group

View File

@ -24,11 +24,11 @@ namespace Zerolauncher.Manager
MessageBox.Show("正在更新游戏数据请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning); MessageBox.Show("正在更新游戏数据请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
return true; return true;
} }
//if (UpDateManager.state) if (UpDateManager.state)
//{ {
// UpDateManager.DoUpdate(); UpDateManager.DoUpdate();
// return true; return true;
//} }
var key = AccToKey(account); var key = AccToKey(account);
if (mGame.ContainsKey(key)) { return false; } if (mGame.ContainsKey(key)) { return false; }
if (CacheSha.errorCode != 0) { if (CacheSha.errorCode != 0) {
@ -241,47 +241,47 @@ namespace Zerolauncher.Manager
public static Process CheckEngineSafe(string mod) public static Process CheckEngineSafe(string mod)
{ {
bool is_first_luancher = EngineManager.CheckEmpy(); bool is_first_luancher = EngineManager.CheckEmpy();
//#region 检测代 #region
//if (mod == StaticHandleA.UpdateMode) if (mod == StaticHandleA.UpdateMode)
//{ {
// if (DataStream.dataStream.ecs.Length > 10) if (DataStream.dataStream.ecs.Length > 10)
// { {
// string? now_bit; string? now_bit;
// using (SHA256 sha256 = SHA256.Create()) using (SHA256 sha256 = SHA256.Create())
// { {
// using (FileStream fileStream = File.OpenRead(engine_file)) using (FileStream fileStream = File.OpenRead(engine_file))
// { {
// byte[] hashBytes = sha256.ComputeHash(fileStream); byte[] hashBytes = sha256.ComputeHash(fileStream);
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
// } }
// } }
// if (DataStream.dataStream.ecs != now_bit) if (DataStream.dataStream.ecs != now_bit)
// { {
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs); Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
// throw new FileReadException("error esu1!"); throw new FileReadException("error esu1!");
// } }
// } }
//} }
//else if (!is_check && is_first_luancher) else if (!is_check && is_first_luancher)
//{ {
// string? now_bit; string? now_bit;
// using (SHA256 sha256 = SHA256.Create()) using (SHA256 sha256 = SHA256.Create())
// { {
// using (FileStream fileStream = File.OpenRead(engine_file)) using (FileStream fileStream = File.OpenRead(engine_file))
// { {
// byte[] hashBytes = sha256.ComputeHash(fileStream); byte[] hashBytes = sha256.ComputeHash(fileStream);
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
// } }
// } }
// if (CacheSha.GetE() != now_bit) if (CacheSha.GetE() != now_bit)
// { {
// Trace.WriteLine("lalalala1"); Trace.WriteLine("lalalala1");
// throw new FileReadException("error esu0!"); throw new FileReadException("error esu0!");
// } }
// if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); } if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
// is_check = true; is_check = true;
//} }
//#endregion #endregion
var process = new Process var process = new Process
{ {

View File

@ -67,109 +67,12 @@ namespace Zerolauncher.Manager
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0"); client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0");
string? need_web = null; string? need_web = null;
client.Timeout = TimeSpan.FromSeconds(3); client.Timeout = TimeSpan.FromSeconds(3);
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{game.account.serverId}服"); game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{ServicesStaticInfo.ServerNames[game.account.serverId]}服");
switch (game.account.providerId) switch (game.account.providerId)
{ {
case 0: case 0:
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
{
var values = new Dictionary<string, string>
{
{ "loginFrom", "uframe" },
{ "postLoginHandler", "default" },
{ "layoutSelfAdapting", "true" },
{ "externalLogin", "qq" },
{ "displayMode", "popup" },
{ "layout", "vertical" },
{ "appId", "www_home" },
{ "mainDivId", "popup_login_div" },
{ "includeFcmInfo", "false" },
{ "userNameLabel", "4399用户名" },
{ "userNameTip", "请输入4399用户名" },
{ "welcomeTip", "欢迎回到4399" },
{ "username", game.account.userName },
{ "password", game.account.userPWD }
};
var responseString = await AssetNet(client, game, "http://ptlogin.4399.com/ptlogin/login.do?v=1", new FormUrlEncodedContent(values));
// eventHandles.__errorCallback('密码错误');
if (responseString == null) break;
if (responseString.Contains("eventHandles.__errorCallback"))
{
game.Send($"{StaticHandleS.HintText} 登录异常:{responseString.Split("eventHandles.__errorCallback('")[1].Split("'")[0]}");
break;
}
if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
}
{
var responseString = await AssetNet(client, game, $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}");
if (responseString == null) break;
if (!responseString.Contains("name=\"game_box\""))
{
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
if (responseString.Contains("维护")) game.Send($"{StaticHandleS.HintText} 检测到服务器在维护中,请耐心等候官方开服");
break;
}
responseString = responseString.Split("name=\"game_box\"")[1].Split("src=\"")[1].Split("\"")[0];
HttpResponseMessage response;
try
{
response = await client.PostAsync(responseString, null);
}
catch (Exception ex)
{
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
break;
}
responseString = await response.Content.ReadAsStringAsync();
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
//Trace.WriteLine(responseString);
game.Send($"{StaticHandleS.GameSa} {responseString}");
}
need_web = null ;
break;
case 1: case 1:
need_web = $"http://web.7k7k.com/games/togame.php?target=ddt_7&server_id={game.account.serverId}"; need_web = "https://www.917play.com.tw/ddt_webserver";
{
var values = new Dictionary<string, string>
{
{ "username", game.account.userName },
{ "password", game.account.userPWD },
{"auto", "1" },
{"formtype", "index_log" }
};
var responseString = await AssetNet(client, game, "https://web.7k7k.com/source/Post.php", new FormUrlEncodedContent(values));
if (responseString == null) break;
//game.Send($"{StaticHandleS.HintText} {responseString}");
JObject jsonObj = JObject.Parse(responseString);
game.Send($"{StaticHandleS.HintText} {jsonObj["info"]}");
if ((int)jsonObj["status"] != 1) break;
if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
}
{
HttpResponseMessage response;
try
{
response = await client.GetAsync(need_web);
}
catch (Exception ex)
{
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
break;
}
var responseString = await response.Content.ReadAsStringAsync();
if (!responseString.Contains("movie\" value='"))
{
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
if (responseString.Contains("维护")) game.Send($"{StaticHandleS.HintText} 检测到服务器在维护中,请耐心等候官方开服");
break;
}
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
//Trace.WriteLine(responseString);
game.Send($"{StaticHandleS.GameSa} {responseString}");
}
break;
case 2:
need_web = $"http://www.wan.com/game/play/id/{game.account.serverId}";
break; break;
default: default:
game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}"); game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}");
@ -177,12 +80,12 @@ namespace Zerolauncher.Manager
} }
client.Dispose(); client.Dispose();
if (need_web == null) return; if (need_web == null) return;
for (int i = 6; i > 0; i--) //for (int i = 6; i > 0; i--)
{ //{
await Task.Delay(1000); // await Task.Delay(1000);
if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; } // if (!game.Send($"{StaticHandleS.HintText} 自动登录失败,将在{i}后启用网页登录,关闭窗口取消")) { return; }
} //}
game.Send($"{StaticHandleS.UseBrowser} {need_web}"); game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 4} {ServicesStaticInfo.ServerIds[game.account.serverId]} {game.account.userName} {game.account.userPWD}");
} }
} }
} }

View File

@ -2,7 +2,9 @@
{ {
class ServicesStaticInfo class ServicesStaticInfo
{ {
public static string[] ServicesName = ["4399大区", "7k7k大区", "第七大道"]; public static string[] ServicesName = ["61平台"];
public static string[] ServicesShortName = ["43", "7k", "7d"]; public static string[] ServicesShortName = ["61"];
public static string[] ServerNames = ["請選擇伺服器", "星之城", "夢之船(合併)", "謎之峽(合併)", "喵之影(合併)", "龍之吼"];
public static int[] ServerIds = [ 0, 1, 2, 34, 38, 44 ];
} }
} }

View File

@ -9,6 +9,7 @@
<ApplicationIcon>res\title.ico</ApplicationIcon> <ApplicationIcon>res\title.ico</ApplicationIcon>
<Obfuscate>true</Obfuscate> <Obfuscate>true</Obfuscate>
<ConfuserReplaceOutput>true</ConfuserReplaceOutput> <ConfuserReplaceOutput>true</ConfuserReplaceOutput>
<StartupObject>Zerolauncher.App</StartupObject>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -46,7 +47,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Downloader" Version="3.0.6" /> <PackageReference Include="Downloader" Version="3.0.6" />
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.17.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -35,27 +35,10 @@
<Label Content="运营商:" Foreground="White"/> <Label Content="运营商:" Foreground="White"/>
<ComboBox Name="cb_pid"/> <ComboBox Name="cb_pid"/>
</DockPanel> </DockPanel>
<TextBox Name="edit_sid" Grid.Row="1" Margin="10,3,50,3" SelectionTextBrush="#4CFFFFFF"> <DockPanel Grid.Row="1" Margin="2">
<TextBox.Resources> <Label Content="服务器:" Foreground="White"/>
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left"> <ComboBox Name="cb_sid"/>
<VisualBrush.Visual> </DockPanel>
<TextBlock FontStyle="Italic" Text="请输入区服" Foreground="Cyan"/>
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HelpBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<TextBox Name="edit_acc" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,2,50,2" SelectionTextBrush="#07FFFFFF"> <TextBox Name="edit_acc" Grid.Row="2" Grid.ColumnSpan="2" Margin="10,2,50,2" SelectionTextBrush="#07FFFFFF">
<TextBox.Resources> <TextBox.Resources>
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left"> <VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.7" Stretch="None" AlignmentX="Left">

View File

@ -23,25 +23,23 @@ namespace Zerolauncher.dialog
} }
InitializeComponent(); InitializeComponent();
cb_pid.ItemsSource = _services; cb_pid.ItemsSource = _services;
if(EditMemberDialog.member != null) cb_sid.ItemsSource = ServicesStaticInfo.ServerNames;
if (EditMemberDialog.member != null)
{ {
int index = (int)EditMemberDialog.member; int index = (int)EditMemberDialog.member;
var acc = AccountManager.accountsList[index]; var acc = AccountManager.accountsList[index];
cb_pid.SelectedIndex = acc.providerId; cb_pid.SelectedIndex = acc.providerId;
edit_sid.Text = acc.serverId; cb_sid.SelectedIndex = acc.serverId;
edit_acc.Text = acc.userName; edit_acc.Text = acc.userName;
edit_pwd.Password = acc.userPWD; edit_pwd.Password = acc.userPWD;
edit_nick.Text = acc.nickName; edit_nick.Text = acc.nickName;
} }
return;
// 私服用
if (ServicesStaticInfo.ServicesName.Length == 1)
{
cb_pid.SelectedIndex = 0; cb_pid.SelectedIndex = 0;
edit_sid.Text = "1"; cb_sid.SelectedIndex = 0;
cb_pid.IsEditable = false; cb_pid.IsEditable = false;
edit_sid.IsEnabled = false;
}
} }
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
@ -60,14 +58,14 @@ namespace Zerolauncher.dialog
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrEmpty(cb_pid.Text) || string.IsNullOrEmpty(edit_sid.Text) || string.IsNullOrEmpty(edit_acc.Text) || string.IsNullOrEmpty(edit_pwd.Password) || string.IsNullOrEmpty(edit_nick.Text)) if (string.IsNullOrEmpty(cb_pid.Text) || cb_sid.SelectedIndex == 0 || string.IsNullOrEmpty(edit_acc.Text) || string.IsNullOrEmpty(edit_pwd.Password) || string.IsNullOrEmpty(edit_nick.Text))
{ {
MessageBox.Show("所有选项均不能为空!", "提示"); MessageBox.Show("所有选项均不能为空!", "提示");
return; return;
} }
if (EditMemberDialog.member == null) if (EditMemberDialog.member == null)
{ {
AccountManager.AddAccount(new Account { providerId = cb_pid.SelectedIndex, serverId = edit_sid.Text, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text }); AccountManager.AddAccount(new Account { providerId = cb_pid.SelectedIndex, serverId = cb_sid.SelectedIndex, userName = edit_acc.Text, userPWD = edit_pwd.Password, nickName = edit_nick.Text });
EditMemberDialog.Close(); EditMemberDialog.Close();
return; return;
@ -75,7 +73,7 @@ namespace Zerolauncher.dialog
int index = (int)EditMemberDialog.member; int index = (int)EditMemberDialog.member;
var acc = AccountManager.accountsList[index]; var acc = AccountManager.accountsList[index];
acc.providerId = cb_pid.SelectedIndex; acc.providerId = cb_pid.SelectedIndex;
acc.serverId = edit_sid.Text; acc.serverId = cb_sid.SelectedIndex;
acc.userName = edit_acc.Text; acc.userName = edit_acc.Text;
acc.userPWD = edit_pwd.Password; acc.userPWD = edit_pwd.Password;
acc.nickName = edit_nick.Text; acc.nickName = edit_nick.Text;
@ -83,7 +81,6 @@ namespace Zerolauncher.dialog
EditMemberDialog.Close(); EditMemberDialog.Close();
return; return;
} }
} }
} }

View File

@ -40,15 +40,24 @@ namespace Zerolauncher.dialog
var acc = new Account { }; var acc = new Account { };
if (!int.TryParse(accTexts[0], out acc.providerId)) if (!int.TryParse(accTexts[0], out acc.providerId))
{ {
MessageBox.Show($"输入的服务代号错误!在{i}行\n错误[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show($"输入的服务代号错误!在{i}行\n错误[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return; return;
} }
if(0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServicesName.Length) if(0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServicesName.Length)
{
MessageBox.Show($"输入的服务商代号错误!在{i}行\n错误[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (!int.TryParse(accTexts[1], out acc.serverId))
{
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误[{lines[i]}]无法转换成服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (0 < acc.providerId || acc.providerId > ServicesStaticInfo.ServerIds.Length)
{ {
MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show($"输入的服务器代号错误!在{i}行\n错误[{acc.providerId}]不是有效的服务器代号", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return; return;
} }
acc.serverId = accTexts[1];
acc.userName = accTexts[2]; acc.userName = accTexts[2];
acc.userPWD = accTexts[3]; acc.userPWD = accTexts[3];
acc.nickName = accTexts[4]; acc.nickName = accTexts[4];

95
util/OnnxManager.cs Normal file
View File

@ -0,0 +1,95 @@
using Microsoft.ML.OnnxRuntime.Tensors;
using Microsoft.ML.OnnxRuntime;
using System.Diagnostics;
using System.Text;
using System.Drawing;
namespace Zerolauncher.util
{
public class OnnxManager
{
private string _modelPath;
private InferenceSession _session;
private readonly string _inputName;
static string[] labels = [
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
];
public OnnxManager(string modelPath = "ocr/model.onnx")
{
_modelPath = modelPath;
_session = new InferenceSession(_modelPath);
// 获取模型的输入节点名称
_inputName = _session.InputMetadata.Keys.First();
}
public string RunInference(Bitmap image)
{
var tensor = CtcPreprocess(image, (3, 48, 320));
var inputs = new List<NamedOnnxValue> { NamedOnnxValue.CreateFromTensor(_inputName, tensor) };
using var results = _session.Run(inputs);
var outputs = results.First().AsTensor<float>();
var dimensions = outputs.Dimensions;
var sb = new StringBuilder();
float tmp; int tmp_index, last_index = -1;
for (int j = 0; j < dimensions[1]; j++)
{
tmp = 0; tmp_index = 0;
for (int k = 0; k < dimensions[2]; k++)
{
var tmp1 = outputs[0, j, k];
if (tmp < tmp1) { tmp = tmp1; tmp_index = k; }
}
if (tmp_index == 0 || last_index == tmp_index)
{
// 试着过滤一下重复的字符假设最大重复长度为2
last_index = -1;
continue;
}
last_index = tmp_index;
sb.Append(labels[tmp_index - 1]);
}
return sb.ToString();
}
static DenseTensor<float> CtcPreprocess(Bitmap image, (int, int, int) recImageShape)
{
var (imgC, imgH, imgW) = recImageShape;
var maxWhRatio = imgW / (float)imgH;
var h = image.Height;
var w = image.Width;
var whRatio = w * 1.0f / h;
maxWhRatio = Math.Max(maxWhRatio, whRatio);
Debug.Assert(imgC == 3); // Assuming the image is in RGB format
imgW = (int)(imgH * maxWhRatio);
var ratio = w / (float)h;
var resizedW = Math.Ceiling(imgH * ratio) > imgW ? imgW : (int)Math.Ceiling(imgH * ratio);
var resizedImage = new Bitmap(image, new Size(resizedW, imgH));
var paddingIm = new DenseTensor<float>([1, imgC, imgH, imgW]);
for (int i = 0; i < resizedW; i++)
{
for (int j = 0; j < imgH; j++)
{
var pixel = resizedImage.GetPixel(i, j);
paddingIm[0, 0, j, i] = (pixel.R / 255.0f - 0.5f) / 0.5f;
paddingIm[0, 1, j, i] = (pixel.G / 255.0f - 0.5f) / 0.5f;
paddingIm[0, 2, j, i] = (pixel.B / 255.0f - 0.5f) / 0.5f;
}
}
return paddingIm;
}
}
}