Skip to content

Commit 07bd15c

Browse files
committed
tga出力時にRLE圧縮を使うか設定できるようにした
1 parent 9070c8d commit 07bd15c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ cuDNN
107107

108108
###「出力画質設定」
109109
変換後の画像の画質を指定します。
110+
設定できる値は整数です。
110111
指定できる値の範囲と意味は「出力拡張子」で設定した形式により異なります。
111112

112113
* .jpg : 値の範囲(0~100) 数字が高いほど高画質
113114
* .webp : 値の範囲(1~100) 数字が高いほど高画質 100だと可逆圧縮
115+
* .tga : 値の範囲(0~1) 0なら圧縮なし、1ならRLE圧縮
114116

115117
###「出力深度ビット数」
116118
変換後の画像の1チャンネルあたりのビット数を指定します
@@ -342,3 +344,4 @@ ex.
342344
オリジナルの[waifu2x](https://github.com/nagadomi/waifu2x)、及びモデルの制作を行い、MITライセンスの下で公開して下さった [ultraist](https://twitter.com/ultraistter)さん、
343345
オリジナルのwaifu2xを元に[waifu2x-converter](https://github.com/WL-Amigo/waifu2x-converter-cpp)を作成して下さった [アミーゴ](https://twitter.com/WL_Amigo)さん(READMEやLICENSE.txtの書き方、OpenCVの使い方等かなり参考にさせていただきました)
344346
に、感謝します。
347+
また、メッセージを英訳してくださった @paul70078 さん、メッセージを中国語(簡体字)に翻訳してくださった @yoonhakcher さん、中国語(簡体字)訳のプルリクエストを下さった @mzhboy さんに感謝します。

common/waifu2x.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const std::vector<Waifu2x::stOutputExtentionElement> Waifu2x::OutputExtentionLis
137137
{ L".exr", { 8, 16, 32 }, boost::optional<int>(), boost::optional<int>(), boost::optional<int>(), boost::optional<int>() },
138138
{ L".ppm", { 8, 16 }, boost::optional<int>(), boost::optional<int>(), boost::optional<int>(), boost::optional<int>() },
139139
{ L".webp", { 8 }, 1, 100, 100, cv::IMWRITE_WEBP_QUALITY },
140-
{ L".tga", { 8 }, boost::optional<int>(), boost::optional<int>(), boost::optional<int>(), boost::optional<int>() },
140+
{ L".tga", { 8 }, 0, 1, 0, 0 },
141141
};
142142

143143
#ifndef CUDA_CHECK_WAIFU2X
@@ -1357,6 +1357,27 @@ Waifu2x::eWaifu2xError Waifu2x::WriteMat(const cv::Mat &im, const boost::filesys
13571357
if(!os)
13581358
return eWaifu2xError_FailedOpenOutputFile;
13591359

1360+
// RLE圧縮の設定
1361+
bool isSet = false;
1362+
const auto &OutputExtentionList = Waifu2x::OutputExtentionList;
1363+
for (const auto &elm : OutputExtentionList)
1364+
{
1365+
if (elm.ext == L".tga")
1366+
{
1367+
if (elm.imageQualitySettingVolume && output_quality)
1368+
{
1369+
stbi_write_tga_with_rle = *output_quality;
1370+
isSet = true;
1371+
}
1372+
1373+
break;
1374+
}
1375+
}
1376+
1377+
// 設定されなかったのでデフォルトにする
1378+
if (!isSet)
1379+
stbi_write_tga_with_rle = 1;
1380+
13601381
if (!stbi_write_tga_to_func(Waifu2x_stbi_write_func, &os, im.size().width, im.size().height, im.channels(), data))
13611382
return eWaifu2xError_FailedOpenOutputFile;
13621383

0 commit comments

Comments
 (0)