diff --git a/GameRes/ImageJPEG.cs b/GameRes/ImageJPEG.cs index 982318b9..3de37066 100644 --- a/GameRes/ImageJPEG.cs +++ b/GameRes/ImageJPEG.cs @@ -28,6 +28,7 @@ using System.IO; using System.Text; using System.ComponentModel.Composition; using System.Windows.Media.Imaging; +using GameRes.Strings; using GameRes.Utility; namespace GameRes @@ -40,13 +41,18 @@ namespace GameRes public override uint Signature { get { return 0; } } public override bool CanWrite { get { return true; } } - public int Quality { get; set; } + readonly FixedGaugeSetting Quality = new FixedGaugeSetting (Properties.Settings.Default) { + Name = "JPEGQuality", + Text = garStrings.JPEGQualityText, + Min = 1, Max = 100, + ValuesSet = new[] { 1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }, + }; public JpegFormat () { Extensions = new string[] { "jpg", "jpeg" }; Signatures = new uint[] { 0xe0ffd8ffu, 0 }; - Quality = 100; + Settings = new[] { Quality }; } public override ImageData Read (IBinaryStream file, ImageMetaData info) @@ -61,7 +67,7 @@ namespace GameRes public override void Write (Stream file, ImageData image) { var encoder = new JpegBitmapEncoder(); - encoder.QualityLevel = Quality; + encoder.QualityLevel = Quality.Get(); encoder.Frames.Add (BitmapFrame.Create (image.Bitmap, null, null, null)); encoder.Save (file); } diff --git a/GameRes/Properties/Settings.Designer.cs b/GameRes/Properties/Settings.Designer.cs index b147338a..2938355d 100644 --- a/GameRes/Properties/Settings.Designer.cs +++ b/GameRes/Properties/Settings.Designer.cs @@ -46,5 +46,17 @@ namespace GameRes.Properties { this["UpgradeRequired"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100")] + public int JPEGQuality { + get { + return ((int)(this["JPEGQuality"])); + } + set { + this["JPEGQuality"] = value; + } + } } } diff --git a/GameRes/Properties/Settings.settings b/GameRes/Properties/Settings.settings index 549aaf77..af77df6d 100644 --- a/GameRes/Properties/Settings.settings +++ b/GameRes/Properties/Settings.settings @@ -8,5 +8,8 @@ True + + 100 + \ No newline at end of file diff --git a/GameRes/ResourceSettings.cs b/GameRes/ResourceSettings.cs index cd021fa7..f34a7333 100644 --- a/GameRes/ResourceSettings.cs +++ b/GameRes/ResourceSettings.cs @@ -23,6 +23,9 @@ // IN THE SOFTWARE. // +using System.Collections.Generic; +using System.Configuration; + namespace GameRes { /// @@ -86,11 +89,34 @@ namespace GameRes } } - internal class LocalResourceSetting : ResourceSettingBase + public class ApplicationSetting : ResourceSettingBase { + public ApplicationSetting (ApplicationSettingsBase settings) + { + Settings = settings; + } + + public ApplicationSettingsBase Settings { get; set; } + public override object Value { - get { return GameRes.Properties.Settings.Default[Name]; } - set { GameRes.Properties.Settings.Default[Name] = value; } + get { return Settings[Name]; } + set { Settings[Name] = value; } + } + } + + internal class LocalResourceSetting : ApplicationSetting + { + public LocalResourceSetting () : base (GameRes.Properties.Settings.Default) { } + } + + public class FixedGaugeSetting : ApplicationSetting + { + public int Min { get; set; } + public int Max { get; set; } + public IEnumerable ValuesSet { get; set; } + + public FixedGaugeSetting (ApplicationSettingsBase settings) : base (settings) + { } } } diff --git a/GameRes/Strings/garStrings.Designer.cs b/GameRes/Strings/garStrings.Designer.cs index 5f0d1852..0872a82d 100644 --- a/GameRes/Strings/garStrings.Designer.cs +++ b/GameRes/Strings/garStrings.Designer.cs @@ -78,6 +78,15 @@ namespace GameRes.Strings { } } + /// + /// Looks up a localized string similar to JPEG compression quality. + /// + public static string JPEGQualityText { + get { + return ResourceManager.GetString("JPEGQualityText", resourceCulture); + } + } + /// /// Looks up a localized string similar to File is empty. /// diff --git a/GameRes/Strings/garStrings.ja-JP.resx b/GameRes/Strings/garStrings.ja-JP.resx index 67f0e5b6..26dc4dcb 100644 --- a/GameRes/Strings/garStrings.ja-JP.resx +++ b/GameRes/Strings/garStrings.ja-JP.resx @@ -125,6 +125,9 @@ BMP形式の拡張機能を有効にします。 Enable BMP format extensions + + JPEG compression quality + ファイルが空です。 File is empty diff --git a/GameRes/Strings/garStrings.ko-KR.resx b/GameRes/Strings/garStrings.ko-KR.resx index b7b8476d..3ef1ac07 100644 --- a/GameRes/Strings/garStrings.ko-KR.resx +++ b/GameRes/Strings/garStrings.ko-KR.resx @@ -125,6 +125,10 @@ Enable BMP format extensions translation pending + + JPEG compression quality + translation pending + 파일이 비어있습니다 diff --git a/GameRes/Strings/garStrings.resx b/GameRes/Strings/garStrings.resx index addbc85a..3488ee6f 100644 --- a/GameRes/Strings/garStrings.resx +++ b/GameRes/Strings/garStrings.resx @@ -123,6 +123,9 @@ Enable BMP format extensions + + JPEG compression quality + File is empty diff --git a/GameRes/Strings/garStrings.ru-RU.resx b/GameRes/Strings/garStrings.ru-RU.resx index 3755932c..e04bf775 100644 --- a/GameRes/Strings/garStrings.ru-RU.resx +++ b/GameRes/Strings/garStrings.ru-RU.resx @@ -123,6 +123,9 @@ Включить расширения формата BMP + + Качество JPEG-компрессии + Файл пуст diff --git a/GameRes/Strings/garStrings.zh-Hans.resx b/GameRes/Strings/garStrings.zh-Hans.resx index 7bd4d089..22a63493 100644 --- a/GameRes/Strings/garStrings.zh-Hans.resx +++ b/GameRes/Strings/garStrings.zh-Hans.resx @@ -123,6 +123,10 @@ 启用 BMP 格式扩展 + + JPEG compression quality + translation pending + 文件为空。 @@ -144,4 +148,4 @@ 无法作为压缩包打开文件。 - + \ No newline at end of file diff --git a/GameRes/app.config b/GameRes/app.config index e9cd7531..f88aed13 100644 --- a/GameRes/app.config +++ b/GameRes/app.config @@ -13,6 +13,9 @@ True + + 100 + \ No newline at end of file