bitmap resize for fortbyte challenges + fixed colors

This commit is contained in:
Asval 2019-05-22 11:45:14 +02:00
parent 36bf16d2a9
commit 3890db712b
3 changed files with 18 additions and 24 deletions

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8FABCD3A-9D55-4B54-B237-B259D815DEB8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<RootNamespace>FModel</RootNamespace>
<AssemblyName>FModel</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>

View File

@ -2435,19 +2435,18 @@ namespace FModel
int sBlue;
string seasonFolder = questJson.Substring(questJson.Substring(0, questJson.LastIndexOf("\\", StringComparison.Ordinal)).LastIndexOf("\\", StringComparison.Ordinal) + 1).ToUpper();
sRed = (int)(myBundle.DisplayStyle.AccentColor.R * 255);
sGreen = (int)(myBundle.DisplayStyle.AccentColor.G * 255);
sBlue = (int)(myBundle.DisplayStyle.AccentColor.B * 255);
if (seasonFolder.Substring(0, seasonFolder.LastIndexOf("\\", StringComparison.Ordinal)) != "LTM")
if (sRed <= 25 && sGreen <= 25 && sBlue <= 25)
{
sRed = (int)(myBundle.DisplayStyle.SecondaryColor.R * 255);
sGreen = (int)(myBundle.DisplayStyle.SecondaryColor.G * 255);
sBlue = (int)(myBundle.DisplayStyle.SecondaryColor.B * 255);
}
else
{
sRed = (int)(myBundle.DisplayStyle.AccentColor.R * 255);
sGreen = (int)(myBundle.DisplayStyle.AccentColor.G * 255);
sBlue = (int)(myBundle.DisplayStyle.AccentColor.B * 255);
}
Console.WriteLine(sRed + " " + sGreen + " " + sBlue);
int seasonRed = Convert.ToInt32(sRed / 1.5);
int seasonGreen = Convert.ToInt32(sGreen / 1.5);
@ -2964,7 +2963,7 @@ namespace FModel
}
private void CreateFortByteChallengesIcon(ItemsIdParser theItem, string theParsedJson, string questJson = null)
{
Bitmap bmp = new Bitmap(2500, 7500);
Bitmap bmp = new Bitmap(2500, 10000);
Graphics g = Graphics.FromImage(bmp);
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
g.SmoothingMode = SmoothingMode.HighQuality;

View File

@ -42,8 +42,6 @@ namespace FModel
public static string ExtractAsset(string currentPak, string currentItem)
{
string toReturn = string.Empty;
MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, Settings.Default.AESKey);
string[] myArray = MyExtractor.GetFileList().ToArray();
@ -53,6 +51,7 @@ namespace FModel
else
results = Array.FindAll(myArray, s => s.Contains("/" + currentItem + "."));
string AssetPath = string.Empty;
for (int i = 0; i < results.Length; i++)
{
int index = Array.IndexOf(myArray, results[i]);
@ -60,21 +59,20 @@ namespace FModel
uint y = (uint)index;
byte[] b = MyExtractor.GetData(y);
toReturn = WriteFile(currentItem, results[i], b);
AssetPath = WriteFile(currentItem, results[i], b).Replace("/", "\\");
}
return toReturn.Replace("/", "\\");
return AssetPath;
}
public static string AssetToTexture2D(string AssetName)
{
string toReturn = string.Empty;
string textureFilePath;
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
textureFilePath = ExtractAsset(ThePak.CurrentUsedPak, AssetName);
else
textureFilePath = ExtractAsset(ThePak.AllpaksDictionary[AssetName ?? throw new InvalidOperationException()], AssetName);
string TexturePath = string.Empty;
if (textureFilePath != null && (textureFilePath.Contains("MI_UI_FeaturedRenderSwitch_") || textureFilePath.Contains("M_UI_ChallengeTile_PCB")))
{
return GetRenderSwitchMaterialTexture(AssetName, textureFilePath);
@ -83,15 +81,13 @@ namespace FModel
{
MyAsset = new PakAsset(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)));
MyAsset.SaveTexture(textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png");
toReturn = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
TexturePath = textureFilePath.Substring(0, textureFilePath.LastIndexOf(".", StringComparison.Ordinal)) + ".png";
}
return toReturn;
return TexturePath;
}
public static string GetRenderSwitchMaterialTexture(string AssetName, string AssetPath)
{
string toReturn = string.Empty;
string TexturePath = string.Empty;
if (AssetPath.Contains(".uasset") || AssetPath.Contains(".uexp") || AssetPath.Contains(".ubulk"))
{
MyAsset = new PakAsset(AssetPath.Substring(0, AssetPath.LastIndexOf('.')));
@ -107,15 +103,14 @@ namespace FModel
{
string textureFile = rsmid[i].TextureParameterValues.FirstOrDefault()?.ParameterValue;
toReturn = AssetToTexture2D(textureFile);
TexturePath = AssetToTexture2D(textureFile);
}
}
}
}
catch (JsonSerializationException) { }
}
return toReturn;
return TexturePath;
}
}
}