Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a831456242 | ||
|
|
88d78e5166 | ||
|
|
f7948e58b4 | ||
|
|
aeccee3fbc | ||
|
|
f8476e4f4e | ||
|
|
ff23e633ee |
21
License.md
Normal file
21
License.md
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Radu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -122,5 +122,23 @@ namespace SevenZip.Compression.LZMA
|
||||
return newOutStream;
|
||||
}
|
||||
|
||||
public static MemoryStream StreamDecompress(MemoryStream newInStream, long outSize)
|
||||
{
|
||||
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
|
||||
|
||||
newInStream.Seek(0, 0);
|
||||
MemoryStream newOutStream = new MemoryStream();
|
||||
|
||||
byte[] properties2 = new byte[5];
|
||||
if (newInStream.Read(properties2, 0, 5) != 5)
|
||||
throw (new Exception("input .lzma is too short"));
|
||||
decoder.SetDecoderProperties(properties2);
|
||||
|
||||
long compressedSize = newInStream.Length - newInStream.Position;
|
||||
decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
|
||||
|
||||
newOutStream.Position = 0;
|
||||
return newOutStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace Unity_Studio
|
||||
var uncompressedBytes = new byte[uncompressedSize];
|
||||
using (var mstream = new MemoryStream(compressedBytes))
|
||||
{
|
||||
var decoder = SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(mstream);
|
||||
var decoder = SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(mstream, uncompressedSize);
|
||||
decoder.Read(uncompressedBytes, 0, uncompressedSize);
|
||||
decoder.Dispose();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Unity_Studio
|
||||
if (sourceFile.version[0] == 5 && (sourceFile.version[1] > 2 || (sourceFile.version[1] == 2 && sourceFile.version[2] >= 1)))
|
||||
{ bool useOnDemandResources = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] < 3)
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 3))
|
||||
{ int targetResolution = a_Stream.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 1) { bool OverrideIPodMusic = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -24,6 +25,10 @@ namespace Unity_Studio
|
||||
public int m_WrapMode;
|
||||
public int m_LightmapFormat;
|
||||
public int m_ColorSpace;
|
||||
//m_StreamData
|
||||
public uint offset;
|
||||
public uint size;
|
||||
public string path;
|
||||
public byte[] image_data;
|
||||
|
||||
//DDS Start
|
||||
@@ -139,10 +144,43 @@ namespace Unity_Studio
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
if (image_data_size == 0 && ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) || sourceFile.version[0] > 5))//5.3.0 and up
|
||||
{
|
||||
offset = a_Stream.ReadUInt32();
|
||||
size = a_Stream.ReadUInt32();
|
||||
image_data_size = (int)size;
|
||||
path = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
image_data = new byte[image_data_size];
|
||||
a_Stream.Read(image_data, 0, image_data_size);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), path.Replace("archive:/", ""));
|
||||
if (File.Exists(path) ||
|
||||
File.Exists(path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(path))))
|
||||
{
|
||||
image_data = new byte[image_data_size];
|
||||
BinaryReader reader = new BinaryReader(File.OpenRead(path));
|
||||
reader.BaseStream.Position = offset;
|
||||
reader.Read(image_data, 0, image_data_size);
|
||||
reader.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
EndianStream estream = null;
|
||||
if (UnityStudioForm.assetsfileandstream.TryGetValue(Path.GetFileName(path), out estream))
|
||||
{
|
||||
estream.Position = offset;
|
||||
image_data = estream.ReadBytes(image_data_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image_data = new byte[image_data_size];
|
||||
a_Stream.Read(image_data, 0, image_data_size);
|
||||
}
|
||||
|
||||
switch ((TextureFormat)m_TextureFormat)
|
||||
{
|
||||
|
||||
@@ -2528,8 +2528,8 @@ namespace Unity_Studio
|
||||
//TODO check texture type and set path accordingly; eg. CubeMap, Texture3D
|
||||
string texFilename = Path.GetDirectoryName(FBXfile) + "\\Texture2D\\" + TexturePD.Text;
|
||||
StatusStripUpdate("Exporting Texture2D: " + Path.GetFileName(texFilename));
|
||||
ExportTexture(TexturePD, texFilename, TexturePD.extension);
|
||||
|
||||
ExportTexture(TexturePD, texFilename, TexturePD.extension, false);
|
||||
texFilename += ".png";//必须是png文件
|
||||
ob.AppendFormat("\n\tTexture: 7{0}, \"Texture::{1}\", \"\" {{", TexturePD.uniqueID, TexturePD.Text);
|
||||
ob.Append("\n\t\tType: \"TextureVideoClip\"");
|
||||
ob.Append("\n\t\tVersion: 202");
|
||||
@@ -3048,7 +3048,7 @@ namespace Unity_Studio
|
||||
switch (asset.Type2)
|
||||
{
|
||||
case 28:
|
||||
if (ExportTexture(asset, exportpath + asset.Text, asset.extension))
|
||||
if (ExportTexture(asset, exportpath + asset.Text, asset.extension, true))
|
||||
{
|
||||
exportedCount++;
|
||||
}
|
||||
@@ -3124,7 +3124,7 @@ namespace Unity_Studio
|
||||
File.WriteAllBytes(exportFilepath, bytes);
|
||||
}
|
||||
|
||||
private bool ExportTexture(AssetPreloadData asset, string exportFilename, string exportFileextension)
|
||||
private bool ExportTexture(AssetPreloadData asset, string exportFilename, string exportFileextension, bool flip)
|
||||
{
|
||||
ImageFormat format = null;
|
||||
var oldextension = exportFileextension;
|
||||
@@ -3154,7 +3154,8 @@ namespace Unity_Studio
|
||||
if ((bool)Properties.Settings.Default["convertTexture"])
|
||||
{
|
||||
var bitmap = DDSToBMP(imageBuffer);
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
if (flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
bitmap.Save(exportFullname, format);
|
||||
}
|
||||
else
|
||||
@@ -3173,7 +3174,8 @@ namespace Unity_Studio
|
||||
int len = Math.Abs(bmd.Stride) * bmd.Height;
|
||||
DecompressPVR(pvrdata, bmd.Scan0, len);
|
||||
bitmap.UnlockBits(bmd);
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
if (flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
bitmap.Save(exportFullname, format);
|
||||
}
|
||||
else
|
||||
@@ -3196,7 +3198,8 @@ namespace Unity_Studio
|
||||
File.Delete(tempastcfilepath);
|
||||
File.Delete(temptgafilepath);
|
||||
var bitmap = TGAToBMP(tempddsfile);
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
if (flip)
|
||||
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
bitmap.Save(exportFullname, format);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user