diff --git a/ArcFormats/DigitalWorks/ImageTM2.cs b/ArcFormats/DigitalWorks/ImageTM2.cs index b7be2d45..25310143 100644 --- a/ArcFormats/DigitalWorks/ImageTM2.cs +++ b/ArcFormats/DigitalWorks/ImageTM2.cs @@ -23,6 +23,7 @@ // IN THE SOFTWARE. // +using GameRes.Formats.Strings; using System; using System.ComponentModel.Composition; using System.IO; @@ -36,7 +37,7 @@ namespace GameRes.Formats.DigitalWorks public int PaletteSize; public int HeaderSize; public int Colors; - public bool X_A = false; + public byte X_A; } [Export(typeof(ImageFormat))] @@ -49,8 +50,16 @@ namespace GameRes.Formats.DigitalWorks public Tim2Format () { Extensions = new string[] { "tm2", "ext" }; + Settings = new[] { AlphaFormat }; } + FixedSetSetting AlphaFormat = new FixedSetSetting(Properties.Settings.Default) + { + Name = "TIM2AlphaFormat", + Text = arcStrings.Tim2AlphaFormat, + ValuesSet = new[] { "No Alpha", "RGBX", "RGBA" }, + }; + public override ImageMetaData ReadMetaData (IBinaryStream file) { var header = file.ReadHeader (0x40); @@ -63,6 +72,14 @@ namespace GameRes.Formats.DigitalWorks case 5: bpp = 8; break; default: return null; } + byte alpha; + switch (AlphaFormat.Get()) + { + case "No Alpha": alpha = 0; break; + case "RGBX": alpha = 7; break; + case "RGBA": + default: alpha = 8; break; + } return new Tim2MetaData { Width = header.ToUInt16 (0x24), Height = header.ToUInt16 (0x26), @@ -70,7 +87,7 @@ namespace GameRes.Formats.DigitalWorks PaletteSize = header.ToInt32 (0x14), HeaderSize = header.ToUInt16 (0x1C), Colors = header.ToUInt16 (0x1E), - X_A = header.ToUInt16(0x30) == 0, // not so sure, there will be omissions + X_A = alpha, //header.ToUInt16(0x30) == 0?// not so sure, there will be omissions }; } @@ -117,7 +134,7 @@ namespace GameRes.Formats.DigitalWorks if (pixel_size <= 8 && m_info.Colors > 0) Palette = ReadPalette (m_info.Colors, m_info.X_A); - if (pixel_size == 3 || pixel_size == 4 && !m_info.X_A) + if (pixel_size == 3 || pixel_size == 4 && m_info.X_A == 8) { for (int i = 0; i < image_size; i += pixel_size) { @@ -126,7 +143,7 @@ namespace GameRes.Formats.DigitalWorks output[i+2] = r; } } - if (pixel_size == 4 && m_info.X_A) + if (pixel_size == 4 && m_info.X_A == 7) { for (int i = 0; i < image_size; i += 4) { @@ -139,12 +156,23 @@ namespace GameRes.Formats.DigitalWorks output[i + 3] = (byte)(output[i + 3] << 1); } } + if (pixel_size == 4 && m_info.X_A == 0) + { + for (int i = 0; i < image_size; i += 4) + { + byte r = output[i]; + output[i] = output[i + 2]; + output[i + 2] = r; + output[i + 3] = byte.MaxValue; + } + } return output; } - BitmapPalette ReadPalette (int color_num, bool X_A = false) + BitmapPalette ReadPalette (int color_num, byte X_A = 8) { - var source = ImageFormat.ReadColorMap (m_input.AsStream, color_num, X_A ? PaletteFormat.RgbX : PaletteFormat.RgbA); + var source = ImageFormat.ReadColorMap (m_input.AsStream, + color_num, X_A == 7 ? PaletteFormat.RgbX : X_A == 0 ? PaletteFormat.RgbX_Disposed : PaletteFormat.RgbA); var color_map = new Color[color_num]; int parts = color_num / 32; diff --git a/ArcFormats/DigitalWorks/ImageTM2arc.cs b/ArcFormats/DigitalWorks/ImageTM2arc.cs index 9b57c6a0..f7be9250 100644 --- a/ArcFormats/DigitalWorks/ImageTM2arc.cs +++ b/ArcFormats/DigitalWorks/ImageTM2arc.cs @@ -15,7 +15,9 @@ namespace GameRes.Formats.DigitalWorks public TM2ArkFormat() { Extensions = new string[] { "tm2" }; + Settings = null; } + public override ImageMetaData ReadMetaData(IBinaryStream stream) { stream.Position = 9; diff --git a/ArcFormats/MAGES/ArcARC20.cs b/ArcFormats/MAGES/ArcARC20.cs index a8c3f1cd..9c7a16c5 100644 --- a/ArcFormats/MAGES/ArcARC20.cs +++ b/ArcFormats/MAGES/ArcARC20.cs @@ -11,7 +11,7 @@ namespace GameRes.Formats.MAGES public override string Tag { get { return "ARC/Princess Soft ARC20"; } } public override string Description { get { return "Princess Soft PS2 resource archive"; } } public override uint Signature { get { return 0x20435241; } } // 'ARC\x20' - public override bool IsHierarchic { get { return false; } } + public override bool IsHierarchic { get { return true; } } public override bool CanWrite { get { return false; } } public override ArcFile TryOpen(ArcView file) diff --git a/ArcFormats/Properties/Settings.Designer.cs b/ArcFormats/Properties/Settings.Designer.cs index f22c61a8..4bad779b 100644 --- a/ArcFormats/Properties/Settings.Designer.cs +++ b/ArcFormats/Properties/Settings.Designer.cs @@ -837,5 +837,17 @@ namespace GameRes.Formats.Properties { this["NexasEncodingCP"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("RGBA")] + public string TIM2AlphaFormat { + get { + return ((string)(this["TIM2AlphaFormat"])); + } + set { + this["TIM2AlphaFormat"] = value; + } + } } } diff --git a/ArcFormats/Properties/Settings.settings b/ArcFormats/Properties/Settings.settings index a6aa5543..50457412 100644 --- a/ArcFormats/Properties/Settings.settings +++ b/ArcFormats/Properties/Settings.settings @@ -206,5 +206,8 @@ 932 + + RGBA + \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.Designer.cs b/ArcFormats/Strings/arcStrings.Designer.cs index c42b4340..accb3959 100644 --- a/ArcFormats/Strings/arcStrings.Designer.cs +++ b/ArcFormats/Strings/arcStrings.Designer.cs @@ -752,6 +752,16 @@ namespace GameRes.Formats.Strings { } } + /// + /// Looks up a localized string similar to Choose Tim2 image alpha format. + /// It can't be read correctly from the file. + /// + public static string Tim2AlphaFormat { + get { + return ResourceManager.GetString("Tim2AlphaFormat", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hex number. /// diff --git a/ArcFormats/Strings/arcStrings.ja-JP.resx b/ArcFormats/Strings/arcStrings.ja-JP.resx index 09cb1f5f..ea90ba37 100644 --- a/ArcFormats/Strings/arcStrings.ja-JP.resx +++ b/ArcFormats/Strings/arcStrings.ja-JP.resx @@ -501,4 +501,8 @@ Choose encryption scheme or enter a passphrase. Default audio sampling rate + + Tim2画像のAlpha形式を選択してください。 +ファイルから正しく読み取ることができません。 + \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.resx b/ArcFormats/Strings/arcStrings.resx index 435a145e..8543086c 100644 --- a/ArcFormats/Strings/arcStrings.resx +++ b/ArcFormats/Strings/arcStrings.resx @@ -401,4 +401,8 @@ Choose encryption scheme or enter a passphrase. Default audio sampling rate + + Choose Tim2 image alpha format. +It can't be read correctly from the file. + \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.zh-Hans.resx b/ArcFormats/Strings/arcStrings.zh-Hans.resx index 97a8a221..056eb3ec 100644 --- a/ArcFormats/Strings/arcStrings.zh-Hans.resx +++ b/ArcFormats/Strings/arcStrings.zh-Hans.resx @@ -399,4 +399,8 @@ 默认音频采样率 + + 选择Tim2图片透明度格式。 +这无法从文件中正确获取。 + \ No newline at end of file diff --git a/ArcFormats/app.config b/ArcFormats/app.config index eb7f9ea8..ef1cc161 100644 --- a/ArcFormats/app.config +++ b/ArcFormats/app.config @@ -208,6 +208,9 @@ 932 + + RGBA +