mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
(Unity.Texture2D): added ARGB4444 textures.
This commit is contained in:
parent
a90d3ee9b0
commit
878415e71e
@ -44,6 +44,8 @@ namespace GameRes.Formats.Unity
|
||||
DXT5 = 12,
|
||||
RGBA4444 = 13,
|
||||
BGRA32 = 14,
|
||||
DXT1Crunched = 28,
|
||||
DXT5Crunched = 29,
|
||||
}
|
||||
|
||||
internal class Texture2D
|
||||
@ -205,6 +207,10 @@ namespace GameRes.Formats.Unity
|
||||
pixels = ConvertRgba (m_texture.m_Data);
|
||||
break;
|
||||
|
||||
case TextureFormat.ARGB4444:
|
||||
pixels = ConvertArgb16 (m_texture.m_Data);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException (string.Format ("Not supported Unity Texture2D format '{0}'.", m_texture.m_TextureFormat));
|
||||
}
|
||||
@ -222,6 +228,21 @@ namespace GameRes.Formats.Unity
|
||||
return data;
|
||||
}
|
||||
|
||||
byte[] ConvertArgb16 (byte[] data)
|
||||
{
|
||||
var output = new byte[data.Length * 2];
|
||||
int dst = 0;
|
||||
for (int i = 0; i < data.Length; i += 2)
|
||||
{
|
||||
ushort p = LittleEndian.ToUInt16 (data, i);
|
||||
output[dst++] = (byte)( (p & 0xF) * 0x11);
|
||||
output[dst++] = (byte)(((p >> 4) & 0xF) * 0x11);
|
||||
output[dst++] = (byte)(((p >> 8) & 0xF) * 0x11);
|
||||
output[dst++] = (byte)(((p >> 12) & 0xF) * 0x11);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
byte[] ConvertRgba (byte[] data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i += 4)
|
||||
|
Loading…
x
Reference in New Issue
Block a user