mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34: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.Text;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using GameRes.Strings;
|
||||||
using GameRes.Utility;
|
using GameRes.Utility;
|
||||||
|
|
||||||
namespace GameRes
|
namespace GameRes
|
||||||
@ -40,13 +41,18 @@ namespace GameRes
|
|||||||
public override uint Signature { get { return 0; } }
|
public override uint Signature { get { return 0; } }
|
||||||
public override bool CanWrite { get { return true; } }
|
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 ()
|
public JpegFormat ()
|
||||||
{
|
{
|
||||||
Extensions = new string[] { "jpg", "jpeg" };
|
Extensions = new string[] { "jpg", "jpeg" };
|
||||||
Signatures = new uint[] { 0xe0ffd8ffu, 0 };
|
Signatures = new uint[] { 0xe0ffd8ffu, 0 };
|
||||||
Quality = 100;
|
Settings = new[] { Quality };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
||||||
@ -61,7 +67,7 @@ namespace GameRes
|
|||||||
public override void Write (Stream file, ImageData image)
|
public override void Write (Stream file, ImageData image)
|
||||||
{
|
{
|
||||||
var encoder = new JpegBitmapEncoder();
|
var encoder = new JpegBitmapEncoder();
|
||||||
encoder.QualityLevel = Quality;
|
encoder.QualityLevel = Quality.Get<int>();
|
||||||
encoder.Frames.Add (BitmapFrame.Create (image.Bitmap, null, null, null));
|
encoder.Frames.Add (BitmapFrame.Create (image.Bitmap, null, null, null));
|
||||||
encoder.Save (file);
|
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;
|
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">
|
<Setting Name="UpgradeRequired" Type="System.Boolean" Scope="User">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="JPEGQuality" Type="System.Int32" Scope="User">
|
||||||
|
<Value Profile="(Default)">100</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
@ -23,6 +23,9 @@
|
|||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
namespace GameRes
|
namespace GameRes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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 {
|
public override object Value {
|
||||||
get { return GameRes.Properties.Settings.Default[Name]; }
|
get { return Settings[Name]; }
|
||||||
set { GameRes.Properties.Settings.Default[Name] = value; }
|
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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to File is empty.
|
/// Looks up a localized string similar to File is empty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -125,6 +125,9 @@
|
|||||||
<value>BMP形式の拡張機能を有効にします。</value>
|
<value>BMP形式の拡張機能を有効にします。</value>
|
||||||
<comment>Enable BMP format extensions</comment>
|
<comment>Enable BMP format extensions</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JPEGQualityText" xml:space="preserve">
|
||||||
|
<value>JPEG compression quality</value>
|
||||||
|
</data>
|
||||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||||
<value>ファイルが空です。</value>
|
<value>ファイルが空です。</value>
|
||||||
<comment>File is empty</comment>
|
<comment>File is empty</comment>
|
||||||
|
@ -125,6 +125,10 @@
|
|||||||
<value>Enable BMP format extensions</value>
|
<value>Enable BMP format extensions</value>
|
||||||
<comment>translation pending</comment>
|
<comment>translation pending</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JPEGQualityText" xml:space="preserve">
|
||||||
|
<value>JPEG compression quality</value>
|
||||||
|
<comment>translation pending</comment>
|
||||||
|
</data>
|
||||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||||
<value>파일이 비어있습니다</value>
|
<value>파일이 비어있습니다</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
<data name="BMPExtensionsText" xml:space="preserve">
|
<data name="BMPExtensionsText" xml:space="preserve">
|
||||||
<value>Enable BMP format extensions</value>
|
<value>Enable BMP format extensions</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JPEGQualityText" xml:space="preserve">
|
||||||
|
<value>JPEG compression quality</value>
|
||||||
|
</data>
|
||||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||||
<value>File is empty</value>
|
<value>File is empty</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
<data name="BMPExtensionsText" xml:space="preserve">
|
<data name="BMPExtensionsText" xml:space="preserve">
|
||||||
<value>Включить расширения формата BMP</value>
|
<value>Включить расширения формата BMP</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JPEGQualityText" xml:space="preserve">
|
||||||
|
<value>Качество JPEG-компрессии</value>
|
||||||
|
</data>
|
||||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||||
<value>Файл пуст</value>
|
<value>Файл пуст</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -123,6 +123,10 @@
|
|||||||
<data name="BMPExtensionsText" xml:space="preserve">
|
<data name="BMPExtensionsText" xml:space="preserve">
|
||||||
<value>启用 BMP 格式扩展</value>
|
<value>启用 BMP 格式扩展</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JPEGQualityText" xml:space="preserve">
|
||||||
|
<value>JPEG compression quality</value>
|
||||||
|
<comment>translation pending</comment>
|
||||||
|
</data>
|
||||||
<data name="MsgFileIsEmpty" xml:space="preserve">
|
<data name="MsgFileIsEmpty" xml:space="preserve">
|
||||||
<value>文件为空。</value>
|
<value>文件为空。</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<setting name="UpgradeRequired" serializeAs="String">
|
<setting name="UpgradeRequired" serializeAs="String">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="JPEGQuality" serializeAs="String">
|
||||||
|
<value>100</value>
|
||||||
|
</setting>
|
||||||
</GameRes.Properties.Settings>
|
</GameRes.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
Loading…
Reference in New Issue
Block a user