mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Use ImageSharp to process textures
This commit is contained in:
parent
d963d71b12
commit
bedee240be
@ -19,6 +19,7 @@ using System.Timers;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using static AssetStudioGUI.Studio;
|
using static AssetStudioGUI.Studio;
|
||||||
using Font = AssetStudio.Font;
|
using Font = AssetStudio.Font;
|
||||||
|
using ImageFormat = AssetStudio.ImageFormat;
|
||||||
using PixelFormat = System.Drawing.Imaging.PixelFormat;
|
using PixelFormat = System.Drawing.Imaging.PixelFormat;
|
||||||
using Vector3 = OpenTK.Vector3;
|
using Vector3 = OpenTK.Vector3;
|
||||||
using Vector4 = OpenTK.Vector4;
|
using Vector4 = OpenTK.Vector4;
|
||||||
@ -741,9 +742,10 @@ namespace AssetStudioGUI
|
|||||||
|
|
||||||
private void PreviewTexture2D(AssetItem assetItem, Texture2D m_Texture2D)
|
private void PreviewTexture2D(AssetItem assetItem, Texture2D m_Texture2D)
|
||||||
{
|
{
|
||||||
var bitmap = m_Texture2D.ConvertToBitmap(true);
|
var stream = m_Texture2D.ConvertToStream(ImageFormat.Png, true);
|
||||||
if (bitmap != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
|
var bitmap = new Bitmap(stream);
|
||||||
assetItem.InfoText = $"Width: {m_Texture2D.m_Width}\nHeight: {m_Texture2D.m_Height}\nFormat: {m_Texture2D.m_TextureFormat}";
|
assetItem.InfoText = $"Width: {m_Texture2D.m_Width}\nHeight: {m_Texture2D.m_Height}\nFormat: {m_Texture2D.m_TextureFormat}";
|
||||||
switch (m_Texture2D.m_TextureSettings.m_FilterMode)
|
switch (m_Texture2D.m_TextureSettings.m_FilterMode)
|
||||||
{
|
{
|
||||||
@ -1151,11 +1153,11 @@ namespace AssetStudioGUI
|
|||||||
|
|
||||||
private void PreviewSprite(AssetItem assetItem, Sprite m_Sprite)
|
private void PreviewSprite(AssetItem assetItem, Sprite m_Sprite)
|
||||||
{
|
{
|
||||||
var bitmap = m_Sprite.GetImage();
|
var stream = m_Sprite.GetImage(ImageFormat.Png);
|
||||||
if (bitmap != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
|
var bitmap = new Bitmap(stream);
|
||||||
assetItem.InfoText = $"Width: {bitmap.Width}\nHeight: {bitmap.Height}\n";
|
assetItem.InfoText = $"Width: {bitmap.Width}\nHeight: {bitmap.Height}\n";
|
||||||
|
|
||||||
PreviewTexture(bitmap);
|
PreviewTexture(bitmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
140
AssetStudioGUI/ExportOptions.Designer.cs
generated
140
AssetStudioGUI/ExportOptions.Designer.cs
generated
@ -72,9 +72,9 @@
|
|||||||
//
|
//
|
||||||
// OKbutton
|
// OKbutton
|
||||||
//
|
//
|
||||||
this.OKbutton.Location = new System.Drawing.Point(309, 381);
|
this.OKbutton.Location = new System.Drawing.Point(318, 351);
|
||||||
this.OKbutton.Name = "OKbutton";
|
this.OKbutton.Name = "OKbutton";
|
||||||
this.OKbutton.Size = new System.Drawing.Size(75, 23);
|
this.OKbutton.Size = new System.Drawing.Size(75, 21);
|
||||||
this.OKbutton.TabIndex = 6;
|
this.OKbutton.TabIndex = 6;
|
||||||
this.OKbutton.Text = "OK";
|
this.OKbutton.Text = "OK";
|
||||||
this.OKbutton.UseVisualStyleBackColor = true;
|
this.OKbutton.UseVisualStyleBackColor = true;
|
||||||
@ -83,9 +83,9 @@
|
|||||||
// Cancel
|
// Cancel
|
||||||
//
|
//
|
||||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.Cancel.Location = new System.Drawing.Point(390, 381);
|
this.Cancel.Location = new System.Drawing.Point(399, 351);
|
||||||
this.Cancel.Name = "Cancel";
|
this.Cancel.Name = "Cancel";
|
||||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
this.Cancel.Size = new System.Drawing.Size(75, 21);
|
||||||
this.Cancel.TabIndex = 7;
|
this.Cancel.TabIndex = 7;
|
||||||
this.Cancel.Text = "Cancel";
|
this.Cancel.Text = "Cancel";
|
||||||
this.Cancel.UseVisualStyleBackColor = true;
|
this.Cancel.UseVisualStyleBackColor = true;
|
||||||
@ -101,9 +101,9 @@
|
|||||||
this.groupBox1.Controls.Add(this.convertAudio);
|
this.groupBox1.Controls.Add(this.convertAudio);
|
||||||
this.groupBox1.Controls.Add(this.panel1);
|
this.groupBox1.Controls.Add(this.panel1);
|
||||||
this.groupBox1.Controls.Add(this.converttexture);
|
this.groupBox1.Controls.Add(this.converttexture);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(12, 13);
|
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(232, 362);
|
this.groupBox1.Size = new System.Drawing.Size(232, 334);
|
||||||
this.groupBox1.TabIndex = 9;
|
this.groupBox1.TabIndex = 9;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Export";
|
this.groupBox1.Text = "Export";
|
||||||
@ -113,9 +113,9 @@
|
|||||||
this.openAfterExport.AutoSize = true;
|
this.openAfterExport.AutoSize = true;
|
||||||
this.openAfterExport.Checked = true;
|
this.openAfterExport.Checked = true;
|
||||||
this.openAfterExport.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.openAfterExport.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.openAfterExport.Location = new System.Drawing.Point(6, 173);
|
this.openAfterExport.Location = new System.Drawing.Point(6, 160);
|
||||||
this.openAfterExport.Name = "openAfterExport";
|
this.openAfterExport.Name = "openAfterExport";
|
||||||
this.openAfterExport.Size = new System.Drawing.Size(137, 17);
|
this.openAfterExport.Size = new System.Drawing.Size(168, 16);
|
||||||
this.openAfterExport.TabIndex = 10;
|
this.openAfterExport.TabIndex = 10;
|
||||||
this.openAfterExport.Text = "Open folder after export";
|
this.openAfterExport.Text = "Open folder after export";
|
||||||
this.openAfterExport.UseVisualStyleBackColor = true;
|
this.openAfterExport.UseVisualStyleBackColor = true;
|
||||||
@ -125,9 +125,9 @@
|
|||||||
this.restoreExtensionName.AutoSize = true;
|
this.restoreExtensionName.AutoSize = true;
|
||||||
this.restoreExtensionName.Checked = true;
|
this.restoreExtensionName.Checked = true;
|
||||||
this.restoreExtensionName.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.restoreExtensionName.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.restoreExtensionName.Location = new System.Drawing.Point(6, 63);
|
this.restoreExtensionName.Location = new System.Drawing.Point(6, 58);
|
||||||
this.restoreExtensionName.Name = "restoreExtensionName";
|
this.restoreExtensionName.Name = "restoreExtensionName";
|
||||||
this.restoreExtensionName.Size = new System.Drawing.Size(190, 17);
|
this.restoreExtensionName.Size = new System.Drawing.Size(216, 16);
|
||||||
this.restoreExtensionName.TabIndex = 9;
|
this.restoreExtensionName.TabIndex = 9;
|
||||||
this.restoreExtensionName.Text = "Restore TextAsset extension name";
|
this.restoreExtensionName.Text = "Restore TextAsset extension name";
|
||||||
this.restoreExtensionName.UseVisualStyleBackColor = true;
|
this.restoreExtensionName.UseVisualStyleBackColor = true;
|
||||||
@ -141,17 +141,17 @@
|
|||||||
"container path",
|
"container path",
|
||||||
"source file name",
|
"source file name",
|
||||||
"do not group"});
|
"do not group"});
|
||||||
this.assetGroupOptions.Location = new System.Drawing.Point(6, 35);
|
this.assetGroupOptions.Location = new System.Drawing.Point(6, 32);
|
||||||
this.assetGroupOptions.Name = "assetGroupOptions";
|
this.assetGroupOptions.Name = "assetGroupOptions";
|
||||||
this.assetGroupOptions.Size = new System.Drawing.Size(149, 21);
|
this.assetGroupOptions.Size = new System.Drawing.Size(149, 20);
|
||||||
this.assetGroupOptions.TabIndex = 8;
|
this.assetGroupOptions.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// label6
|
// label6
|
||||||
//
|
//
|
||||||
this.label6.AutoSize = true;
|
this.label6.AutoSize = true;
|
||||||
this.label6.Location = new System.Drawing.Point(6, 18);
|
this.label6.Location = new System.Drawing.Point(6, 17);
|
||||||
this.label6.Name = "label6";
|
this.label6.Name = "label6";
|
||||||
this.label6.Size = new System.Drawing.Size(127, 13);
|
this.label6.Size = new System.Drawing.Size(149, 12);
|
||||||
this.label6.TabIndex = 7;
|
this.label6.TabIndex = 7;
|
||||||
this.label6.Text = "Group exported assets by";
|
this.label6.Text = "Group exported assets by";
|
||||||
//
|
//
|
||||||
@ -160,9 +160,9 @@
|
|||||||
this.convertAudio.AutoSize = true;
|
this.convertAudio.AutoSize = true;
|
||||||
this.convertAudio.Checked = true;
|
this.convertAudio.Checked = true;
|
||||||
this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.convertAudio.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.convertAudio.Location = new System.Drawing.Point(6, 150);
|
this.convertAudio.Location = new System.Drawing.Point(6, 138);
|
||||||
this.convertAudio.Name = "convertAudio";
|
this.convertAudio.Name = "convertAudio";
|
||||||
this.convertAudio.Size = new System.Drawing.Size(179, 17);
|
this.convertAudio.Size = new System.Drawing.Size(198, 16);
|
||||||
this.convertAudio.TabIndex = 6;
|
this.convertAudio.TabIndex = 6;
|
||||||
this.convertAudio.Text = "Convert AudioClip to WAV(PCM)";
|
this.convertAudio.Text = "Convert AudioClip to WAV(PCM)";
|
||||||
this.convertAudio.UseVisualStyleBackColor = true;
|
this.convertAudio.UseVisualStyleBackColor = true;
|
||||||
@ -173,51 +173,51 @@
|
|||||||
this.panel1.Controls.Add(this.tojpg);
|
this.panel1.Controls.Add(this.tojpg);
|
||||||
this.panel1.Controls.Add(this.topng);
|
this.panel1.Controls.Add(this.topng);
|
||||||
this.panel1.Controls.Add(this.tobmp);
|
this.panel1.Controls.Add(this.tobmp);
|
||||||
this.panel1.Location = new System.Drawing.Point(20, 111);
|
this.panel1.Location = new System.Drawing.Point(20, 102);
|
||||||
this.panel1.Name = "panel1";
|
this.panel1.Name = "panel1";
|
||||||
this.panel1.Size = new System.Drawing.Size(202, 33);
|
this.panel1.Size = new System.Drawing.Size(202, 30);
|
||||||
this.panel1.TabIndex = 5;
|
this.panel1.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// totga
|
// totga
|
||||||
//
|
//
|
||||||
this.totga.AutoSize = true;
|
this.totga.AutoSize = true;
|
||||||
this.totga.Location = new System.Drawing.Point(150, 7);
|
this.totga.Location = new System.Drawing.Point(150, 6);
|
||||||
this.totga.Name = "totga";
|
this.totga.Name = "totga";
|
||||||
this.totga.Size = new System.Drawing.Size(47, 17);
|
this.totga.Size = new System.Drawing.Size(41, 16);
|
||||||
this.totga.TabIndex = 2;
|
this.totga.TabIndex = 2;
|
||||||
this.totga.Text = "TGA";
|
this.totga.Text = "Tga";
|
||||||
this.totga.UseVisualStyleBackColor = true;
|
this.totga.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// tojpg
|
// tojpg
|
||||||
//
|
//
|
||||||
this.tojpg.AutoSize = true;
|
this.tojpg.AutoSize = true;
|
||||||
this.tojpg.Location = new System.Drawing.Point(97, 7);
|
this.tojpg.Location = new System.Drawing.Point(97, 6);
|
||||||
this.tojpg.Name = "tojpg";
|
this.tojpg.Name = "tojpg";
|
||||||
this.tojpg.Size = new System.Drawing.Size(52, 17);
|
this.tojpg.Size = new System.Drawing.Size(47, 16);
|
||||||
this.tojpg.TabIndex = 4;
|
this.tojpg.TabIndex = 4;
|
||||||
this.tojpg.Text = "JPEG";
|
this.tojpg.Text = "Jpeg";
|
||||||
this.tojpg.UseVisualStyleBackColor = true;
|
this.tojpg.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// topng
|
// topng
|
||||||
//
|
//
|
||||||
this.topng.AutoSize = true;
|
this.topng.AutoSize = true;
|
||||||
this.topng.Checked = true;
|
this.topng.Checked = true;
|
||||||
this.topng.Location = new System.Drawing.Point(50, 7);
|
this.topng.Location = new System.Drawing.Point(50, 6);
|
||||||
this.topng.Name = "topng";
|
this.topng.Name = "topng";
|
||||||
this.topng.Size = new System.Drawing.Size(48, 17);
|
this.topng.Size = new System.Drawing.Size(41, 16);
|
||||||
this.topng.TabIndex = 3;
|
this.topng.TabIndex = 3;
|
||||||
this.topng.TabStop = true;
|
this.topng.TabStop = true;
|
||||||
this.topng.Text = "PNG";
|
this.topng.Text = "Png";
|
||||||
this.topng.UseVisualStyleBackColor = true;
|
this.topng.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// tobmp
|
// tobmp
|
||||||
//
|
//
|
||||||
this.tobmp.AutoSize = true;
|
this.tobmp.AutoSize = true;
|
||||||
this.tobmp.Location = new System.Drawing.Point(3, 7);
|
this.tobmp.Location = new System.Drawing.Point(3, 6);
|
||||||
this.tobmp.Name = "tobmp";
|
this.tobmp.Name = "tobmp";
|
||||||
this.tobmp.Size = new System.Drawing.Size(48, 17);
|
this.tobmp.Size = new System.Drawing.Size(41, 16);
|
||||||
this.tobmp.TabIndex = 2;
|
this.tobmp.TabIndex = 2;
|
||||||
this.tobmp.Text = "BMP";
|
this.tobmp.Text = "Bmp";
|
||||||
this.tobmp.UseVisualStyleBackColor = true;
|
this.tobmp.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// converttexture
|
// converttexture
|
||||||
@ -225,9 +225,9 @@
|
|||||||
this.converttexture.AutoSize = true;
|
this.converttexture.AutoSize = true;
|
||||||
this.converttexture.Checked = true;
|
this.converttexture.Checked = true;
|
||||||
this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.converttexture.Location = new System.Drawing.Point(6, 87);
|
this.converttexture.Location = new System.Drawing.Point(6, 80);
|
||||||
this.converttexture.Name = "converttexture";
|
this.converttexture.Name = "converttexture";
|
||||||
this.converttexture.Size = new System.Drawing.Size(116, 17);
|
this.converttexture.Size = new System.Drawing.Size(126, 16);
|
||||||
this.converttexture.TabIndex = 1;
|
this.converttexture.TabIndex = 1;
|
||||||
this.converttexture.Text = "Convert Texture2D";
|
this.converttexture.Text = "Convert Texture2D";
|
||||||
this.converttexture.UseVisualStyleBackColor = true;
|
this.converttexture.UseVisualStyleBackColor = true;
|
||||||
@ -252,9 +252,9 @@
|
|||||||
this.groupBox2.Controls.Add(this.castToBone);
|
this.groupBox2.Controls.Add(this.castToBone);
|
||||||
this.groupBox2.Controls.Add(this.exportAllNodes);
|
this.groupBox2.Controls.Add(this.exportAllNodes);
|
||||||
this.groupBox2.Controls.Add(this.eulerFilter);
|
this.groupBox2.Controls.Add(this.eulerFilter);
|
||||||
this.groupBox2.Location = new System.Drawing.Point(250, 13);
|
this.groupBox2.Location = new System.Drawing.Point(250, 12);
|
||||||
this.groupBox2.Name = "groupBox2";
|
this.groupBox2.Name = "groupBox2";
|
||||||
this.groupBox2.Size = new System.Drawing.Size(214, 362);
|
this.groupBox2.Size = new System.Drawing.Size(224, 334);
|
||||||
this.groupBox2.TabIndex = 11;
|
this.groupBox2.TabIndex = 11;
|
||||||
this.groupBox2.TabStop = false;
|
this.groupBox2.TabStop = false;
|
||||||
this.groupBox2.Text = "Fbx";
|
this.groupBox2.Text = "Fbx";
|
||||||
@ -263,9 +263,9 @@
|
|||||||
//
|
//
|
||||||
this.exportAllUvsAsDiffuseMaps.AccessibleDescription = "";
|
this.exportAllUvsAsDiffuseMaps.AccessibleDescription = "";
|
||||||
this.exportAllUvsAsDiffuseMaps.AutoSize = true;
|
this.exportAllUvsAsDiffuseMaps.AutoSize = true;
|
||||||
this.exportAllUvsAsDiffuseMaps.Location = new System.Drawing.Point(6, 184);
|
this.exportAllUvsAsDiffuseMaps.Location = new System.Drawing.Point(6, 171);
|
||||||
this.exportAllUvsAsDiffuseMaps.Name = "exportAllUvsAsDiffuseMaps";
|
this.exportAllUvsAsDiffuseMaps.Name = "exportAllUvsAsDiffuseMaps";
|
||||||
this.exportAllUvsAsDiffuseMaps.Size = new System.Drawing.Size(168, 17);
|
this.exportAllUvsAsDiffuseMaps.Size = new System.Drawing.Size(204, 16);
|
||||||
this.exportAllUvsAsDiffuseMaps.TabIndex = 23;
|
this.exportAllUvsAsDiffuseMaps.TabIndex = 23;
|
||||||
this.exportAllUvsAsDiffuseMaps.Text = "Export all UVs as diffuse maps";
|
this.exportAllUvsAsDiffuseMaps.Text = "Export all UVs as diffuse maps";
|
||||||
this.exportUvsTooltip.SetToolTip(this.exportAllUvsAsDiffuseMaps, "Unchecked: UV1 exported as normal map. Check this if your export is missing a UV " +
|
this.exportUvsTooltip.SetToolTip(this.exportAllUvsAsDiffuseMaps, "Unchecked: UV1 exported as normal map. Check this if your export is missing a UV " +
|
||||||
@ -277,9 +277,9 @@
|
|||||||
this.exportBlendShape.AutoSize = true;
|
this.exportBlendShape.AutoSize = true;
|
||||||
this.exportBlendShape.Checked = true;
|
this.exportBlendShape.Checked = true;
|
||||||
this.exportBlendShape.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.exportBlendShape.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.exportBlendShape.Location = new System.Drawing.Point(6, 138);
|
this.exportBlendShape.Location = new System.Drawing.Point(6, 127);
|
||||||
this.exportBlendShape.Name = "exportBlendShape";
|
this.exportBlendShape.Name = "exportBlendShape";
|
||||||
this.exportBlendShape.Size = new System.Drawing.Size(114, 17);
|
this.exportBlendShape.Size = new System.Drawing.Size(126, 16);
|
||||||
this.exportBlendShape.TabIndex = 22;
|
this.exportBlendShape.TabIndex = 22;
|
||||||
this.exportBlendShape.Text = "Export blendshape";
|
this.exportBlendShape.Text = "Export blendshape";
|
||||||
this.exportBlendShape.UseVisualStyleBackColor = true;
|
this.exportBlendShape.UseVisualStyleBackColor = true;
|
||||||
@ -289,9 +289,9 @@
|
|||||||
this.exportAnimations.AutoSize = true;
|
this.exportAnimations.AutoSize = true;
|
||||||
this.exportAnimations.Checked = true;
|
this.exportAnimations.Checked = true;
|
||||||
this.exportAnimations.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.exportAnimations.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.exportAnimations.Location = new System.Drawing.Point(6, 114);
|
this.exportAnimations.Location = new System.Drawing.Point(6, 105);
|
||||||
this.exportAnimations.Name = "exportAnimations";
|
this.exportAnimations.Name = "exportAnimations";
|
||||||
this.exportAnimations.Size = new System.Drawing.Size(109, 17);
|
this.exportAnimations.Size = new System.Drawing.Size(126, 16);
|
||||||
this.exportAnimations.TabIndex = 21;
|
this.exportAnimations.TabIndex = 21;
|
||||||
this.exportAnimations.Text = "Export animations";
|
this.exportAnimations.Text = "Export animations";
|
||||||
this.exportAnimations.UseVisualStyleBackColor = true;
|
this.exportAnimations.UseVisualStyleBackColor = true;
|
||||||
@ -304,9 +304,9 @@
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
131072});
|
131072});
|
||||||
this.scaleFactor.Location = new System.Drawing.Point(83, 237);
|
this.scaleFactor.Location = new System.Drawing.Point(83, 224);
|
||||||
this.scaleFactor.Name = "scaleFactor";
|
this.scaleFactor.Name = "scaleFactor";
|
||||||
this.scaleFactor.Size = new System.Drawing.Size(60, 20);
|
this.scaleFactor.Size = new System.Drawing.Size(60, 21);
|
||||||
this.scaleFactor.TabIndex = 20;
|
this.scaleFactor.TabIndex = 20;
|
||||||
this.scaleFactor.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
this.scaleFactor.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.scaleFactor.Value = new decimal(new int[] {
|
this.scaleFactor.Value = new decimal(new int[] {
|
||||||
@ -318,9 +318,9 @@
|
|||||||
// label5
|
// label5
|
||||||
//
|
//
|
||||||
this.label5.AutoSize = true;
|
this.label5.AutoSize = true;
|
||||||
this.label5.Location = new System.Drawing.Point(6, 239);
|
this.label5.Location = new System.Drawing.Point(6, 226);
|
||||||
this.label5.Name = "label5";
|
this.label5.Name = "label5";
|
||||||
this.label5.Size = new System.Drawing.Size(64, 13);
|
this.label5.Size = new System.Drawing.Size(71, 12);
|
||||||
this.label5.TabIndex = 19;
|
this.label5.TabIndex = 19;
|
||||||
this.label5.Text = "ScaleFactor";
|
this.label5.Text = "ScaleFactor";
|
||||||
//
|
//
|
||||||
@ -331,17 +331,17 @@
|
|||||||
this.fbxFormat.Items.AddRange(new object[] {
|
this.fbxFormat.Items.AddRange(new object[] {
|
||||||
"Binary",
|
"Binary",
|
||||||
"Ascii"});
|
"Ascii"});
|
||||||
this.fbxFormat.Location = new System.Drawing.Point(77, 270);
|
this.fbxFormat.Location = new System.Drawing.Point(77, 254);
|
||||||
this.fbxFormat.Name = "fbxFormat";
|
this.fbxFormat.Name = "fbxFormat";
|
||||||
this.fbxFormat.Size = new System.Drawing.Size(61, 21);
|
this.fbxFormat.Size = new System.Drawing.Size(61, 20);
|
||||||
this.fbxFormat.TabIndex = 18;
|
this.fbxFormat.TabIndex = 18;
|
||||||
//
|
//
|
||||||
// label4
|
// label4
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.label4.AutoSize = true;
|
||||||
this.label4.Location = new System.Drawing.Point(6, 274);
|
this.label4.Location = new System.Drawing.Point(6, 258);
|
||||||
this.label4.Name = "label4";
|
this.label4.Name = "label4";
|
||||||
this.label4.Size = new System.Drawing.Size(59, 13);
|
this.label4.Size = new System.Drawing.Size(59, 12);
|
||||||
this.label4.TabIndex = 17;
|
this.label4.TabIndex = 17;
|
||||||
this.label4.Text = "FBXFormat";
|
this.label4.Text = "FBXFormat";
|
||||||
//
|
//
|
||||||
@ -356,25 +356,25 @@
|
|||||||
"7.3",
|
"7.3",
|
||||||
"7.4",
|
"7.4",
|
||||||
"7.5"});
|
"7.5"});
|
||||||
this.fbxVersion.Location = new System.Drawing.Point(77, 302);
|
this.fbxVersion.Location = new System.Drawing.Point(77, 284);
|
||||||
this.fbxVersion.Name = "fbxVersion";
|
this.fbxVersion.Name = "fbxVersion";
|
||||||
this.fbxVersion.Size = new System.Drawing.Size(47, 21);
|
this.fbxVersion.Size = new System.Drawing.Size(47, 20);
|
||||||
this.fbxVersion.TabIndex = 16;
|
this.fbxVersion.TabIndex = 16;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(6, 305);
|
this.label3.Location = new System.Drawing.Point(6, 287);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(62, 13);
|
this.label3.Size = new System.Drawing.Size(65, 12);
|
||||||
this.label3.TabIndex = 15;
|
this.label3.TabIndex = 15;
|
||||||
this.label3.Text = "FBXVersion";
|
this.label3.Text = "FBXVersion";
|
||||||
//
|
//
|
||||||
// boneSize
|
// boneSize
|
||||||
//
|
//
|
||||||
this.boneSize.Location = new System.Drawing.Point(65, 208);
|
this.boneSize.Location = new System.Drawing.Point(65, 197);
|
||||||
this.boneSize.Name = "boneSize";
|
this.boneSize.Name = "boneSize";
|
||||||
this.boneSize.Size = new System.Drawing.Size(46, 20);
|
this.boneSize.Size = new System.Drawing.Size(46, 21);
|
||||||
this.boneSize.TabIndex = 11;
|
this.boneSize.TabIndex = 11;
|
||||||
this.boneSize.Value = new decimal(new int[] {
|
this.boneSize.Value = new decimal(new int[] {
|
||||||
10,
|
10,
|
||||||
@ -385,9 +385,9 @@
|
|||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(6, 210);
|
this.label2.Location = new System.Drawing.Point(6, 199);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(52, 13);
|
this.label2.Size = new System.Drawing.Size(53, 12);
|
||||||
this.label2.TabIndex = 10;
|
this.label2.TabIndex = 10;
|
||||||
this.label2.Text = "BoneSize";
|
this.label2.Text = "BoneSize";
|
||||||
//
|
//
|
||||||
@ -396,9 +396,9 @@
|
|||||||
this.exportSkins.AutoSize = true;
|
this.exportSkins.AutoSize = true;
|
||||||
this.exportSkins.Checked = true;
|
this.exportSkins.Checked = true;
|
||||||
this.exportSkins.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.exportSkins.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.exportSkins.Location = new System.Drawing.Point(6, 90);
|
this.exportSkins.Location = new System.Drawing.Point(6, 83);
|
||||||
this.exportSkins.Name = "exportSkins";
|
this.exportSkins.Name = "exportSkins";
|
||||||
this.exportSkins.Size = new System.Drawing.Size(83, 17);
|
this.exportSkins.Size = new System.Drawing.Size(96, 16);
|
||||||
this.exportSkins.TabIndex = 8;
|
this.exportSkins.TabIndex = 8;
|
||||||
this.exportSkins.Text = "Export skins";
|
this.exportSkins.Text = "Export skins";
|
||||||
this.exportSkins.UseVisualStyleBackColor = true;
|
this.exportSkins.UseVisualStyleBackColor = true;
|
||||||
@ -406,9 +406,9 @@
|
|||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(26, 42);
|
this.label1.Location = new System.Drawing.Point(26, 39);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(72, 13);
|
this.label1.Size = new System.Drawing.Size(95, 12);
|
||||||
this.label1.TabIndex = 7;
|
this.label1.TabIndex = 7;
|
||||||
this.label1.Text = "FilterPrecision";
|
this.label1.Text = "FilterPrecision";
|
||||||
//
|
//
|
||||||
@ -420,9 +420,9 @@
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
131072});
|
131072});
|
||||||
this.filterPrecision.Location = new System.Drawing.Point(127, 40);
|
this.filterPrecision.Location = new System.Drawing.Point(127, 37);
|
||||||
this.filterPrecision.Name = "filterPrecision";
|
this.filterPrecision.Name = "filterPrecision";
|
||||||
this.filterPrecision.Size = new System.Drawing.Size(51, 20);
|
this.filterPrecision.Size = new System.Drawing.Size(51, 21);
|
||||||
this.filterPrecision.TabIndex = 6;
|
this.filterPrecision.TabIndex = 6;
|
||||||
this.filterPrecision.Value = new decimal(new int[] {
|
this.filterPrecision.Value = new decimal(new int[] {
|
||||||
25,
|
25,
|
||||||
@ -433,9 +433,9 @@
|
|||||||
// castToBone
|
// castToBone
|
||||||
//
|
//
|
||||||
this.castToBone.AutoSize = true;
|
this.castToBone.AutoSize = true;
|
||||||
this.castToBone.Location = new System.Drawing.Point(6, 161);
|
this.castToBone.Location = new System.Drawing.Point(6, 149);
|
||||||
this.castToBone.Name = "castToBone";
|
this.castToBone.Name = "castToBone";
|
||||||
this.castToBone.Size = new System.Drawing.Size(131, 17);
|
this.castToBone.Size = new System.Drawing.Size(156, 16);
|
||||||
this.castToBone.TabIndex = 5;
|
this.castToBone.TabIndex = 5;
|
||||||
this.castToBone.Text = "All nodes cast to bone";
|
this.castToBone.Text = "All nodes cast to bone";
|
||||||
this.castToBone.UseVisualStyleBackColor = true;
|
this.castToBone.UseVisualStyleBackColor = true;
|
||||||
@ -445,9 +445,9 @@
|
|||||||
this.exportAllNodes.AutoSize = true;
|
this.exportAllNodes.AutoSize = true;
|
||||||
this.exportAllNodes.Checked = true;
|
this.exportAllNodes.Checked = true;
|
||||||
this.exportAllNodes.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.exportAllNodes.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.exportAllNodes.Location = new System.Drawing.Point(6, 66);
|
this.exportAllNodes.Location = new System.Drawing.Point(6, 61);
|
||||||
this.exportAllNodes.Name = "exportAllNodes";
|
this.exportAllNodes.Name = "exportAllNodes";
|
||||||
this.exportAllNodes.Size = new System.Drawing.Size(101, 17);
|
this.exportAllNodes.Size = new System.Drawing.Size(120, 16);
|
||||||
this.exportAllNodes.TabIndex = 4;
|
this.exportAllNodes.TabIndex = 4;
|
||||||
this.exportAllNodes.Text = "Export all nodes";
|
this.exportAllNodes.Text = "Export all nodes";
|
||||||
this.exportAllNodes.UseVisualStyleBackColor = true;
|
this.exportAllNodes.UseVisualStyleBackColor = true;
|
||||||
@ -457,9 +457,9 @@
|
|||||||
this.eulerFilter.AutoSize = true;
|
this.eulerFilter.AutoSize = true;
|
||||||
this.eulerFilter.Checked = true;
|
this.eulerFilter.Checked = true;
|
||||||
this.eulerFilter.CheckState = System.Windows.Forms.CheckState.Checked;
|
this.eulerFilter.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.eulerFilter.Location = new System.Drawing.Point(6, 22);
|
this.eulerFilter.Location = new System.Drawing.Point(6, 20);
|
||||||
this.eulerFilter.Name = "eulerFilter";
|
this.eulerFilter.Name = "eulerFilter";
|
||||||
this.eulerFilter.Size = new System.Drawing.Size(72, 17);
|
this.eulerFilter.Size = new System.Drawing.Size(90, 16);
|
||||||
this.eulerFilter.TabIndex = 3;
|
this.eulerFilter.TabIndex = 3;
|
||||||
this.eulerFilter.Text = "EulerFilter";
|
this.eulerFilter.Text = "EulerFilter";
|
||||||
this.eulerFilter.UseVisualStyleBackColor = true;
|
this.eulerFilter.UseVisualStyleBackColor = true;
|
||||||
@ -467,10 +467,10 @@
|
|||||||
// ExportOptions
|
// ExportOptions
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.OKbutton;
|
this.AcceptButton = this.OKbutton;
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.CancelButton = this.Cancel;
|
this.CancelButton = this.Cancel;
|
||||||
this.ClientSize = new System.Drawing.Size(477, 416);
|
this.ClientSize = new System.Drawing.Size(486, 384);
|
||||||
this.Controls.Add(this.groupBox2);
|
this.Controls.Add(this.groupBox2);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Controls.Add(this.Cancel);
|
this.Controls.Add(this.Cancel);
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
using System;
|
using AssetStudio;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AssetStudioGUI
|
namespace AssetStudioGUI
|
||||||
@ -19,7 +13,7 @@ namespace AssetStudioGUI
|
|||||||
restoreExtensionName.Checked = Properties.Settings.Default.restoreExtensionName;
|
restoreExtensionName.Checked = Properties.Settings.Default.restoreExtensionName;
|
||||||
converttexture.Checked = Properties.Settings.Default.convertTexture;
|
converttexture.Checked = Properties.Settings.Default.convertTexture;
|
||||||
convertAudio.Checked = Properties.Settings.Default.convertAudio;
|
convertAudio.Checked = Properties.Settings.Default.convertAudio;
|
||||||
var str = Properties.Settings.Default.convertType;
|
var str = Properties.Settings.Default.convertType.ToString();
|
||||||
foreach (Control c in panel1.Controls)
|
foreach (Control c in panel1.Controls)
|
||||||
{
|
{
|
||||||
if (c.Text == str)
|
if (c.Text == str)
|
||||||
@ -54,7 +48,7 @@ namespace AssetStudioGUI
|
|||||||
{
|
{
|
||||||
if (((RadioButton)c).Checked)
|
if (((RadioButton)c).Checked)
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.convertType = c.Text;
|
Properties.Settings.Default.convertType = (ImageFormat)Enum.Parse(typeof(ImageFormat), c.Text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using AssetStudio;
|
||||||
using System.Drawing.Imaging;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using AssetStudio;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using TGASharpLib;
|
|
||||||
|
|
||||||
namespace AssetStudioGUI
|
namespace AssetStudioGUI
|
||||||
{
|
{
|
||||||
@ -16,40 +14,17 @@ namespace AssetStudioGUI
|
|||||||
var m_Texture2D = (Texture2D)item.Asset;
|
var m_Texture2D = (Texture2D)item.Asset;
|
||||||
if (Properties.Settings.Default.convertTexture)
|
if (Properties.Settings.Default.convertTexture)
|
||||||
{
|
{
|
||||||
var bitmap = m_Texture2D.ConvertToBitmap(true);
|
var type = Properties.Settings.Default.convertType;
|
||||||
if (bitmap == null)
|
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
|
||||||
return false;
|
return false;
|
||||||
ImageFormat format = null;
|
var stream = m_Texture2D.ConvertToStream(type, true);
|
||||||
var ext = Properties.Settings.Default.convertType;
|
if (stream == null)
|
||||||
bool tga = false;
|
|
||||||
switch (ext)
|
|
||||||
{
|
|
||||||
case "BMP":
|
|
||||||
format = ImageFormat.Bmp;
|
|
||||||
break;
|
|
||||||
case "PNG":
|
|
||||||
format = ImageFormat.Png;
|
|
||||||
break;
|
|
||||||
case "JPEG":
|
|
||||||
format = ImageFormat.Jpeg;
|
|
||||||
break;
|
|
||||||
case "TGA":
|
|
||||||
tga = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!TryExportFile(exportPath, item, "." + ext.ToLower(), out var exportFullPath))
|
|
||||||
return false;
|
return false;
|
||||||
if (tga)
|
using (stream)
|
||||||
{
|
{
|
||||||
var file = new TGA(bitmap);
|
File.WriteAllBytes(exportFullPath, stream.ToArray());
|
||||||
file.Save(exportFullPath);
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
bitmap.Save(exportFullPath, format);
|
|
||||||
}
|
|
||||||
bitmap.Dispose();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -252,40 +227,17 @@ namespace AssetStudioGUI
|
|||||||
|
|
||||||
public static bool ExportSprite(AssetItem item, string exportPath)
|
public static bool ExportSprite(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
ImageFormat format = null;
|
|
||||||
var type = Properties.Settings.Default.convertType;
|
var type = Properties.Settings.Default.convertType;
|
||||||
bool tga = false;
|
if (!TryExportFile(exportPath, item, "." + type.ToString().ToLower(), out var exportFullPath))
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case "BMP":
|
|
||||||
format = ImageFormat.Bmp;
|
|
||||||
break;
|
|
||||||
case "PNG":
|
|
||||||
format = ImageFormat.Png;
|
|
||||||
break;
|
|
||||||
case "JPEG":
|
|
||||||
format = ImageFormat.Jpeg;
|
|
||||||
break;
|
|
||||||
case "TGA":
|
|
||||||
tga = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!TryExportFile(exportPath, item, "." + type.ToLower(), out var exportFullPath))
|
|
||||||
return false;
|
return false;
|
||||||
var bitmap = ((Sprite)item.Asset).GetImage();
|
var stream = ((Sprite)item.Asset).GetImage(type);
|
||||||
if (bitmap != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
if (tga)
|
using (stream)
|
||||||
{
|
{
|
||||||
var file = new TGA(bitmap);
|
File.WriteAllBytes(exportFullPath, stream.ToArray());
|
||||||
file.Save(exportFullPath);
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
bitmap.Save(exportFullPath, format);
|
|
||||||
}
|
|
||||||
bitmap.Dispose();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
14
AssetStudioGUI/Properties/Settings.Designer.cs
generated
14
AssetStudioGUI/Properties/Settings.Designer.cs
generated
@ -1,10 +1,10 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// 此代码由工具生成。
|
||||||
// Runtime Version:4.0.30319.42000
|
// 运行时版本:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||||
// the code is regenerated.
|
// 重新生成代码,这些更改将会丢失。
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -109,10 +109,10 @@ namespace AssetStudioGUI.Properties {
|
|||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("PNG")]
|
[global::System.Configuration.DefaultSettingValueAttribute("Png")]
|
||||||
public string convertType {
|
public global::AssetStudio.ImageFormat convertType {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["convertType"]));
|
return ((global::AssetStudio.ImageFormat)(this["convertType"]));
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this["convertType"] = value;
|
this["convertType"] = value;
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
<Setting Name="convertAudio" Type="System.Boolean" Scope="User">
|
<Setting Name="convertAudio" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="convertType" Type="System.String" Scope="User">
|
<Setting Name="convertType" Type="AssetStudio.ImageFormat" Scope="User">
|
||||||
<Value Profile="(Default)">PNG</Value>
|
<Value Profile="(Default)">Png</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="eulerFilter" Type="System.Boolean" Scope="User">
|
<Setting Name="eulerFilter" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<section name="AssetStudioGUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="AssetStudioGUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<value>True</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="convertType" serializeAs="String">
|
<setting name="convertType" serializeAs="String">
|
||||||
<value>PNG</value>
|
<value>Png</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="eulerFilter" serializeAs="String">
|
<setting name="eulerFilter" serializeAs="String">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
@ -75,4 +75,16 @@
|
|||||||
</setting>
|
</setting>
|
||||||
</AssetStudioGUI.Properties.Settings>
|
</AssetStudioGUI.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
@ -37,9 +37,48 @@
|
|||||||
<Reference Include="Mono.Cecil, Version=0.11.3.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
|
<Reference Include="Mono.Cecil, Version=0.11.3.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Mono.Cecil.0.11.3\lib\net40\Mono.Cecil.dll</HintPath>
|
<HintPath>..\packages\Mono.Cecil.0.11.3\lib\net40\Mono.Cecil.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SixLabors.Fonts.1.0.0-beta15\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SixLabors.ImageSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SixLabors.ImageSharp.1.0.3\lib\net472\SixLabors.ImageSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SixLabors.ImageSharp.Drawing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SixLabors.ImageSharp.Drawing.1.0.0-beta13\lib\net472\SixLabors.ImageSharp.Drawing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.UnmanagedMemoryStream, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.UnmanagedMemoryStream.4.3.0\lib\net46\System.IO.UnmanagedMemoryStream.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<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" />
|
||||||
@ -63,11 +102,12 @@
|
|||||||
<Compile Include="FMOD Studio API\fmod.cs" />
|
<Compile Include="FMOD Studio API\fmod.cs" />
|
||||||
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
<Compile Include="FMOD Studio API\fmod_dsp.cs" />
|
||||||
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
<Compile Include="FMOD Studio API\fmod_errors.cs" />
|
||||||
|
<Compile Include="ImageExtensions.cs" />
|
||||||
|
<Compile Include="ImageFormat.cs" />
|
||||||
<Compile Include="ModelConverter.cs" />
|
<Compile Include="ModelConverter.cs" />
|
||||||
<Compile Include="ModelExporter.cs" />
|
<Compile Include="ModelExporter.cs" />
|
||||||
<Compile Include="MonoBehaviourConverter.cs" />
|
<Compile Include="MonoBehaviourConverter.cs" />
|
||||||
<Compile Include="SerializedTypeHelper.cs" />
|
<Compile Include="SerializedTypeHelper.cs" />
|
||||||
<Compile Include="TGASharpLib.cs" />
|
|
||||||
<Compile Include="TypeDefinitionConverter.cs" />
|
<Compile Include="TypeDefinitionConverter.cs" />
|
||||||
<Compile Include="MyAssemblyResolver.cs" />
|
<Compile Include="MyAssemblyResolver.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@ -107,6 +147,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
39
AssetStudioUtility/ImageExtensions.cs
Normal file
39
AssetStudioUtility/ImageExtensions.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.Formats.Bmp;
|
||||||
|
using SixLabors.ImageSharp.Formats.Tga;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public static class ImageExtensions
|
||||||
|
{
|
||||||
|
public static MemoryStream ConvertToStream(this Image image, ImageFormat imageFormat)
|
||||||
|
{
|
||||||
|
var outputStream = new MemoryStream();
|
||||||
|
switch (imageFormat)
|
||||||
|
{
|
||||||
|
case ImageFormat.Jpeg:
|
||||||
|
image.SaveAsJpeg(outputStream);
|
||||||
|
break;
|
||||||
|
case ImageFormat.Png:
|
||||||
|
image.SaveAsPng(outputStream);
|
||||||
|
break;
|
||||||
|
case ImageFormat.Bmp:
|
||||||
|
image.Save(outputStream, new BmpEncoder
|
||||||
|
{
|
||||||
|
BitsPerPixel = BmpBitsPerPixel.Pixel32,
|
||||||
|
SupportTransparency = true
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case ImageFormat.Tga:
|
||||||
|
image.Save(outputStream, new TgaEncoder
|
||||||
|
{
|
||||||
|
BitsPerPixel = TgaBitsPerPixel.Pixel32,
|
||||||
|
Compression = TgaCompression.None
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return outputStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
AssetStudioUtility/ImageFormat.cs
Normal file
10
AssetStudioUtility/ImageFormat.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace AssetStudio
|
||||||
|
{
|
||||||
|
public enum ImageFormat
|
||||||
|
{
|
||||||
|
Jpeg,
|
||||||
|
Png,
|
||||||
|
Bmp,
|
||||||
|
Tga
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TGASharpLib;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@ -17,7 +14,7 @@ namespace AssetStudio
|
|||||||
public List<ImportedKeyframedAnimation> AnimationList { get; protected set; } = new List<ImportedKeyframedAnimation>();
|
public List<ImportedKeyframedAnimation> AnimationList { get; protected set; } = new List<ImportedKeyframedAnimation>();
|
||||||
public List<ImportedMorph> MorphList { get; protected set; } = new List<ImportedMorph>();
|
public List<ImportedMorph> MorphList { get; protected set; } = new List<ImportedMorph>();
|
||||||
|
|
||||||
private string imageFormat;
|
private ImageFormat imageFormat;
|
||||||
private Avatar avatar;
|
private Avatar avatar;
|
||||||
private HashSet<AnimationClip> animationClipHashSet = new HashSet<AnimationClip>();
|
private HashSet<AnimationClip> animationClipHashSet = new HashSet<AnimationClip>();
|
||||||
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
||||||
@ -25,7 +22,7 @@ namespace AssetStudio
|
|||||||
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
||||||
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
||||||
|
|
||||||
public ModelConverter(GameObject m_GameObject, string imageFormat, AnimationClip[] animationList = null)
|
public ModelConverter(GameObject m_GameObject, ImageFormat imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
this.imageFormat = imageFormat;
|
this.imageFormat = imageFormat;
|
||||||
if (m_GameObject.m_Animator != null)
|
if (m_GameObject.m_Animator != null)
|
||||||
@ -50,7 +47,7 @@ namespace AssetStudio
|
|||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelConverter(string rootName, List<GameObject> m_GameObjects, string imageFormat, AnimationClip[] animationList = null)
|
public ModelConverter(string rootName, List<GameObject> m_GameObjects, ImageFormat imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
this.imageFormat = imageFormat;
|
this.imageFormat = imageFormat;
|
||||||
RootFrame = CreateFrame(rootName, Vector3.Zero, new Quaternion(0, 0, 0, 0), Vector3.One);
|
RootFrame = CreateFrame(rootName, Vector3.Zero, new Quaternion(0, 0, 0, 0), Vector3.One);
|
||||||
@ -80,7 +77,7 @@ namespace AssetStudio
|
|||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelConverter(Animator m_Animator, string imageFormat, AnimationClip[] animationList = null)
|
public ModelConverter(Animator m_Animator, ImageFormat imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
this.imageFormat = imageFormat;
|
this.imageFormat = imageFormat;
|
||||||
InitWithAnimator(m_Animator);
|
InitWithAnimator(m_Animator);
|
||||||
@ -319,7 +316,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
ImportedMaterial iMat = ConvertMaterial(mat);
|
ImportedMaterial iMat = ConvertMaterial(mat);
|
||||||
iSubmesh.Material = iMat.Name;
|
iSubmesh.Material = iMat.Name;
|
||||||
iSubmesh.BaseVertex = (int) mesh.m_SubMeshes[i].firstVertex;
|
iSubmesh.BaseVertex = (int)mesh.m_SubMeshes[i].firstVertex;
|
||||||
|
|
||||||
//Face
|
//Face
|
||||||
iSubmesh.FaceList = new List<ImportedFace>(numFaces);
|
iSubmesh.FaceList = new List<ImportedFace>(numFaces);
|
||||||
@ -699,7 +696,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
texture.Dest = dest;
|
texture.Dest = dest;
|
||||||
|
|
||||||
var ext = $".{imageFormat.ToLower()}";
|
var ext = $".{imageFormat.ToString().ToLower()}";
|
||||||
if (textureNameDictionary.TryGetValue(m_Texture2D, out var textureName))
|
if (textureNameDictionary.TryGetValue(m_Texture2D, out var textureName))
|
||||||
{
|
{
|
||||||
texture.Name = textureName;
|
texture.Name = textureName;
|
||||||
@ -745,30 +742,13 @@ namespace AssetStudio
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bitmap = m_Texture2D.ConvertToBitmap(true);
|
var stream = m_Texture2D.ConvertToStream(imageFormat, true);
|
||||||
if (bitmap != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
using (var stream = new MemoryStream())
|
using (stream)
|
||||||
{
|
{
|
||||||
switch (imageFormat)
|
|
||||||
{
|
|
||||||
case "BMP":
|
|
||||||
bitmap.Save(stream, ImageFormat.Bmp);
|
|
||||||
break;
|
|
||||||
case "PNG":
|
|
||||||
bitmap.Save(stream, ImageFormat.Png);
|
|
||||||
break;
|
|
||||||
case "JPEG":
|
|
||||||
bitmap.Save(stream, ImageFormat.Jpeg);
|
|
||||||
break;
|
|
||||||
case "TGA":
|
|
||||||
var tga = new TGA(bitmap);
|
|
||||||
tga.Save(stream);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
iTex = new ImportedTexture(stream, name);
|
iTex = new ImportedTexture(stream, name);
|
||||||
TextureList.Add(iTex);
|
TextureList.Add(iTex);
|
||||||
bitmap.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
using System.Collections.Generic;
|
using SixLabors.ImageSharp;
|
||||||
using System.Drawing;
|
using SixLabors.ImageSharp.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using SixLabors.ImageSharp.Drawing.Processing;
|
||||||
using System.Drawing.Imaging;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public static class SpriteHelper
|
public static class SpriteHelper
|
||||||
{
|
{
|
||||||
public static Bitmap GetImage(this Sprite m_Sprite)
|
public static MemoryStream GetImage(this Sprite m_Sprite, ImageFormat imageFormat)
|
||||||
|
{
|
||||||
|
var image = GetImage(m_Sprite);
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
using (image)
|
||||||
|
{
|
||||||
|
return image.ConvertToStream(imageFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image GetImage(this Sprite m_Sprite)
|
||||||
{
|
{
|
||||||
if (m_Sprite.m_SpriteAtlas != null && m_Sprite.m_SpriteAtlas.TryGet(out var m_SpriteAtlas))
|
if (m_Sprite.m_SpriteAtlas != null && m_Sprite.m_SpriteAtlas.TryGet(out var m_SpriteAtlas))
|
||||||
{
|
{
|
||||||
@ -28,46 +44,32 @@ namespace AssetStudio
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Bitmap CutImage(Texture2D m_Texture2D, Sprite m_Sprite, Rectf textureRect, Vector2 textureRectOffset, SpriteSettings settingsRaw)
|
private static Image CutImage(Texture2D m_Texture2D, Sprite m_Sprite, Rectf textureRect, Vector2 textureRectOffset, SpriteSettings settingsRaw)
|
||||||
{
|
{
|
||||||
var originalImage = m_Texture2D.ConvertToBitmap(false);
|
var originalImage = m_Texture2D.ConvertToImage(false);
|
||||||
if (originalImage != null)
|
if (originalImage != null)
|
||||||
{
|
{
|
||||||
using (originalImage)
|
using (originalImage)
|
||||||
{
|
{
|
||||||
//var spriteImage = originalImage.Clone(textureRect, PixelFormat.Format32bppArgb);
|
|
||||||
var rectf = new RectangleF(textureRect.x, textureRect.y, textureRect.width, textureRect.height);
|
var rectf = new RectangleF(textureRect.x, textureRect.y, textureRect.width, textureRect.height);
|
||||||
var rect = Rectangle.Round(rectf);
|
var rect = Rectangle.Ceiling(rectf);
|
||||||
if (rect.Width == 0)
|
var spriteImage = originalImage.Clone(x => x.Crop(rect));
|
||||||
{
|
|
||||||
rect.Width = 1;
|
|
||||||
}
|
|
||||||
if (rect.Height == 0)
|
|
||||||
{
|
|
||||||
rect.Height = 1;
|
|
||||||
}
|
|
||||||
var spriteImage = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
|
|
||||||
var destRect = new Rectangle(0, 0, rect.Width, rect.Height);
|
|
||||||
using (var graphic = Graphics.FromImage(spriteImage))
|
|
||||||
{
|
|
||||||
graphic.DrawImage(originalImage, destRect, rect, GraphicsUnit.Pixel);
|
|
||||||
}
|
|
||||||
if (settingsRaw.packed == 1)
|
if (settingsRaw.packed == 1)
|
||||||
{
|
{
|
||||||
//RotateAndFlip
|
//RotateAndFlip
|
||||||
switch (settingsRaw.packingRotation)
|
switch (settingsRaw.packingRotation)
|
||||||
{
|
{
|
||||||
case SpritePackingRotation.kSPRFlipHorizontal:
|
case SpritePackingRotation.kSPRFlipHorizontal:
|
||||||
spriteImage.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
spriteImage.Mutate(x => x.Flip(FlipMode.Horizontal));
|
||||||
break;
|
break;
|
||||||
case SpritePackingRotation.kSPRFlipVertical:
|
case SpritePackingRotation.kSPRFlipVertical:
|
||||||
spriteImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
spriteImage.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||||
break;
|
break;
|
||||||
case SpritePackingRotation.kSPRRotate180:
|
case SpritePackingRotation.kSPRRotate180:
|
||||||
spriteImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
spriteImage.Mutate(x => x.Rotate(180));
|
||||||
break;
|
break;
|
||||||
case SpritePackingRotation.kSPRRotate90:
|
case SpritePackingRotation.kSPRRotate90:
|
||||||
spriteImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
|
spriteImage.Mutate(x => x.Rotate(270));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,41 +80,32 @@ namespace AssetStudio
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var triangles = GetTriangles(m_Sprite.m_RD);
|
var triangles = GetTriangles(m_Sprite.m_RD);
|
||||||
var points = triangles.Select(x => x.Select(y => new PointF(y.X, y.Y)).ToArray());
|
var polygons = triangles.Select(x => new Polygon(new LinearLineSegment(x.Select(y => new PointF(y.X, y.Y)).ToArray()))).ToArray();
|
||||||
using (var path = new GraphicsPath())
|
IPathCollection path = new PathCollection(polygons);
|
||||||
|
var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits);
|
||||||
|
var version = m_Sprite.version;
|
||||||
|
if (version[0] < 5
|
||||||
|
|| (version[0] == 5 && version[1] < 4)
|
||||||
|
|| (version[0] == 5 && version[1] == 4 && version[2] <= 1)) //5.4.1p3 down
|
||||||
{
|
{
|
||||||
foreach (var p in points)
|
matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * 0.5f - textureRectOffset.X, m_Sprite.m_Rect.height * 0.5f - textureRectOffset.Y);
|
||||||
{
|
|
||||||
path.AddPolygon(p);
|
|
||||||
}
|
|
||||||
using (var matr = new Matrix())
|
|
||||||
{
|
|
||||||
var version = m_Sprite.version;
|
|
||||||
if (version[0] < 5
|
|
||||||
|| (version[0] == 5 && version[1] < 4)
|
|
||||||
|| (version[0] == 5 && version[1] == 4 && version[2] <= 1)) //5.4.1p3 down
|
|
||||||
{
|
|
||||||
matr.Translate(m_Sprite.m_Rect.width * 0.5f - textureRectOffset.X, m_Sprite.m_Rect.height * 0.5f - textureRectOffset.Y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
matr.Translate(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
|
|
||||||
}
|
|
||||||
matr.Scale(m_Sprite.m_PixelsToUnits, m_Sprite.m_PixelsToUnits);
|
|
||||||
path.Transform(matr);
|
|
||||||
var bitmap = new Bitmap(rect.Width, rect.Height);
|
|
||||||
using (var graphic = Graphics.FromImage(bitmap))
|
|
||||||
{
|
|
||||||
using (var brush = new TextureBrush(spriteImage))
|
|
||||||
{
|
|
||||||
graphic.FillPath(brush, path);
|
|
||||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
|
||||||
spriteImage.Dispose();
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
|
||||||
|
}
|
||||||
|
path = path.Transform(matrix);
|
||||||
|
var options = new DrawingOptions
|
||||||
|
{
|
||||||
|
GraphicsOptions = new GraphicsOptions()
|
||||||
|
{
|
||||||
|
AlphaCompositionMode = PixelAlphaCompositionMode.DestOut
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rectP = new RectangularPolygon(0, 0, rect.Width, rect.Height);
|
||||||
|
spriteImage.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, rectP.Clip(path)));
|
||||||
|
spriteImage.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||||
|
return spriteImage;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -121,7 +114,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Rectangle
|
//Rectangle
|
||||||
spriteImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
spriteImage.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||||
return spriteImage;
|
return spriteImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Texture2DDecoder;
|
using Texture2DDecoder;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
@ -28,26 +25,6 @@ namespace AssetStudio
|
|||||||
platform = m_Texture2D.platform;
|
platform = m_Texture2D.platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap ConvertToBitmap(bool flip)
|
|
||||||
{
|
|
||||||
if (image_data == null || image_data.Length == 0)
|
|
||||||
return null;
|
|
||||||
var buff = DecodeTexture2D();
|
|
||||||
if (buff == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var bitmap = new Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb);
|
|
||||||
var bmpData = bitmap.LockBits(new Rectangle(0, 0, m_Width, m_Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
|
||||||
Marshal.Copy(buff, 0, bmpData.Scan0, buff.Length);
|
|
||||||
bitmap.UnlockBits(bmpData);
|
|
||||||
if (flip)
|
|
||||||
{
|
|
||||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
|
||||||
}
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] DecodeTexture2D()
|
public byte[] DecodeTexture2D()
|
||||||
{
|
{
|
||||||
byte[] bytes = null;
|
byte[] bytes = null;
|
||||||
|
@ -1,13 +1,39 @@
|
|||||||
using System.Drawing;
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
public static class Texture2DExtensions
|
public static class Texture2DExtensions
|
||||||
{
|
{
|
||||||
public static Bitmap ConvertToBitmap(this Texture2D m_Texture2D, bool flip)
|
public static Image ConvertToImage(this Texture2D m_Texture2D, bool flip)
|
||||||
{
|
{
|
||||||
var converter = new Texture2DConverter(m_Texture2D);
|
var converter = new Texture2DConverter(m_Texture2D);
|
||||||
return converter.ConvertToBitmap(flip);
|
var bytes = converter.DecodeTexture2D();
|
||||||
|
if (bytes != null && bytes.Length > 0)
|
||||||
|
{
|
||||||
|
var image = Image.LoadPixelData<Bgra32>(bytes, m_Texture2D.m_Width, m_Texture2D.m_Height);
|
||||||
|
if (flip)
|
||||||
|
{
|
||||||
|
image.Mutate(x => x.Flip(FlipMode.Vertical));
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MemoryStream ConvertToStream(this Texture2D m_Texture2D, ImageFormat imageFormat, bool flip)
|
||||||
|
{
|
||||||
|
var image = ConvertToImage(m_Texture2D, flip);
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
using (image)
|
||||||
|
{
|
||||||
|
return image.ConvertToStream(imageFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
AssetStudioUtility/app.config
Normal file
15
AssetStudioUtility/app.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
@ -1,4 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Mono.Cecil" version="0.11.3" targetFramework="net472" />
|
<package id="Mono.Cecil" version="0.11.3" targetFramework="net472" />
|
||||||
|
<package id="SixLabors.Fonts" version="1.0.0-beta15" targetFramework="net472" />
|
||||||
|
<package id="SixLabors.ImageSharp" version="1.0.3" targetFramework="net472" />
|
||||||
|
<package id="SixLabors.ImageSharp.Drawing" version="1.0.0-beta13" targetFramework="net472" />
|
||||||
|
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||||
|
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
|
||||||
|
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
|
||||||
|
<package id="System.IO.UnmanagedMemoryStream" version="4.3.0" targetFramework="net472" />
|
||||||
|
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net472" />
|
||||||
|
<package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net472" />
|
||||||
|
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user