mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-26 23:24:00 +08:00
(GameRes): added JPEG compression quality setting.
This commit is contained in:
parent
3bea44ff30
commit
12bff91ba2
@ -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<int>();
|
||||
encoder.Frames.Add (BitmapFrame.Create (image.Bitmap, null, null, null));
|
||||
encoder.Save (file);
|
||||
}
|
||||
|
12
GameRes/Properties/Settings.Designer.cs
generated
12
GameRes/Properties/Settings.Designer.cs
generated
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,8 @@
|
||||
<Setting Name="UpgradeRequired" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="JPEGQuality" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">100</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -23,6 +23,9 @@
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
|
||||
namespace GameRes
|
||||
{
|
||||
/// <summary>
|
||||
@ -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<int> ValuesSet { get; set; }
|
||||
|
||||
public FixedGaugeSetting (ApplicationSettingsBase settings) : base (settings)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
GameRes/Strings/garStrings.Designer.cs
generated
9
GameRes/Strings/garStrings.Designer.cs
generated
@ -78,6 +78,15 @@ namespace GameRes.Strings {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to JPEG compression quality.
|
||||
/// </summary>
|
||||
public static string JPEGQualityText {
|
||||
get {
|
||||
return ResourceManager.GetString("JPEGQualityText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File is empty.
|
||||
/// </summary>
|
||||
|
@ -125,6 +125,9 @@
|
||||
<value>BMP形式の拡張機能を有効にします。</value>
|
||||
<comment>Enable BMP format extensions</comment>
|
||||
</data>
|
||||
<data name="JPEGQualityText" xml:space="preserve">
|
||||
<value>JPEG compression quality</value>
|
||||
</data>
|
||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||
<value>ファイルが空です。</value>
|
||||
<comment>File is empty</comment>
|
||||
|
@ -125,6 +125,10 @@
|
||||
<value>Enable BMP format extensions</value>
|
||||
<comment>translation pending</comment>
|
||||
</data>
|
||||
<data name="JPEGQualityText" xml:space="preserve">
|
||||
<value>JPEG compression quality</value>
|
||||
<comment>translation pending</comment>
|
||||
</data>
|
||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||
<value>파일이 비어있습니다</value>
|
||||
</data>
|
||||
|
@ -123,6 +123,9 @@
|
||||
<data name="BMPExtensionsText" xml:space="preserve">
|
||||
<value>Enable BMP format extensions</value>
|
||||
</data>
|
||||
<data name="JPEGQualityText" xml:space="preserve">
|
||||
<value>JPEG compression quality</value>
|
||||
</data>
|
||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||
<value>File is empty</value>
|
||||
</data>
|
||||
|
@ -123,6 +123,9 @@
|
||||
<data name="BMPExtensionsText" xml:space="preserve">
|
||||
<value>Включить расширения формата BMP</value>
|
||||
</data>
|
||||
<data name="JPEGQualityText" xml:space="preserve">
|
||||
<value>Качество JPEG-компрессии</value>
|
||||
</data>
|
||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||
<value>Файл пуст</value>
|
||||
</data>
|
||||
|
@ -123,6 +123,10 @@
|
||||
<data name="BMPExtensionsText" xml:space="preserve">
|
||||
<value>启用 BMP 格式扩展</value>
|
||||
</data>
|
||||
<data name="JPEGQualityText" xml:space="preserve">
|
||||
<value>JPEG compression quality</value>
|
||||
<comment>translation pending</comment>
|
||||
</data>
|
||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||
<value>文件为空。</value>
|
||||
</data>
|
||||
@ -144,4 +148,4 @@
|
||||
<data name="MsgUnknownFormat" xml:space="preserve">
|
||||
<value>无法作为压缩包打开文件。</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
@ -13,6 +13,9 @@
|
||||
<setting name="UpgradeRequired" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="JPEGQuality" serializeAs="String">
|
||||
<value>100</value>
|
||||
</setting>
|
||||
</GameRes.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user