Merge pull request #3099 from shun-iwasawa/g/fix_convert_to_tlv
Fix Convert to TLV
This commit is contained in:
commit
22d65307c5
2 changed files with 29 additions and 22 deletions
|
@ -256,6 +256,8 @@ void ConvertPopup::Converter::convertLevelWithConvert2Tlv(
|
|||
tlvConverter->abort();
|
||||
} else {
|
||||
int count = tlvConverter->getFramesToConvertCount();
|
||||
popup->m_progressDialog->setMinimum(0);
|
||||
popup->m_progressDialog->setMaximum(count);
|
||||
bool stop = false;
|
||||
for (int j = 0; j < count && !stop; j++) {
|
||||
if (!tlvConverter->convertNext(errorMessage)) {
|
||||
|
@ -263,6 +265,8 @@ void ConvertPopup::Converter::convertLevelWithConvert2Tlv(
|
|||
DVGui::warning(QString::fromStdString(errorMessage));
|
||||
}
|
||||
if (popup->m_progressDialog->wasCanceled()) stop = true;
|
||||
|
||||
popup->m_notifier->notifyFrameCompleted(j);
|
||||
}
|
||||
if (stop) tlvConverter->abort();
|
||||
|
||||
|
@ -661,9 +665,9 @@ QFrame *ConvertPopup::createTlvSettings() {
|
|||
bool ret = true;
|
||||
ret = ret && connect(m_antialias, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(onAntialiasSelected(int)));
|
||||
ret = ret && connect(m_palettePath, SIGNAL(pathChanged()), this,
|
||||
ret = ret && connect(m_palettePath, SIGNAL(pathChanged()), this,
|
||||
SLOT(onPalettePathChanged()));
|
||||
ret = ret && connect(m_dpiMode, SIGNAL(currentIndexChanged(int)), this,
|
||||
ret = ret && connect(m_dpiMode, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(onDpiModeSelected(int)));
|
||||
|
||||
assert(ret);
|
||||
|
@ -891,7 +895,7 @@ Convert2Tlv *ConvertPopup::makeTlvConverter(const TFilePath &sourceFilePath) {
|
|||
sourceFilePath.withParentDir(unpaintedFolder).withName(basename));
|
||||
}
|
||||
int from = -1, to = -1;
|
||||
if (m_srcFilePaths.size() > 1) {
|
||||
if (m_srcFilePaths.size() == 1) {
|
||||
from = m_fromFld->getValue();
|
||||
to = m_toFld->getValue();
|
||||
}
|
||||
|
@ -1109,10 +1113,10 @@ void ConvertPopup::getFrameRange(const TFilePath &sourceFilePath,
|
|||
TFrameId fid;
|
||||
bool ok;
|
||||
|
||||
fid = TFrameId(m_fromFld->text().toInt(&ok));
|
||||
fid = TFrameId(m_fromFld->text().toInt(&ok));
|
||||
if (ok && fid > from) from = tcrop(fid, firstFrame, lastFrame);
|
||||
|
||||
fid = TFrameId(m_toFld->text().toInt(&ok));
|
||||
fid = TFrameId(m_toFld->text().toInt(&ok));
|
||||
if (ok && fid < to) to = tcrop(fid, firstFrame, lastFrame);
|
||||
}
|
||||
}
|
||||
|
@ -1266,9 +1270,9 @@ void ConvertPopup::onOptionsClicked() {
|
|||
std::string ext = m_fileFormat->currentText().toStdString();
|
||||
TPropertyGroup *props = getFormatProperties(ext);
|
||||
|
||||
openFormatSettingsPopup(this, ext, props, m_srcFilePaths.size() == 1
|
||||
? m_srcFilePaths[0]
|
||||
: TFilePath());
|
||||
openFormatSettingsPopup(
|
||||
this, ext, props,
|
||||
m_srcFilePaths.size() == 1 ? m_srcFilePaths[0] : TFilePath());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -1297,9 +1301,8 @@ void ConvertPopup::onPalettePathChanged() {
|
|||
bool ConvertPopup::isSaveTlvBackupToNopaintActive() {
|
||||
return m_fileFormat->currentText() ==
|
||||
TlvExtension /*-- tlvが選択されている --*/
|
||||
&&
|
||||
m_tlvMode->currentText() ==
|
||||
TlvMode_Unpainted /*-- Unpainted Tlvが選択されている --*/
|
||||
&& m_tlvMode->currentText() ==
|
||||
TlvMode_Unpainted /*-- Unpainted Tlvが選択されている --*/
|
||||
&& m_saveBackupToNopaint->isChecked(); /*-- Save Backup to "nopaint"
|
||||
Folder オプションが有効 --*/
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ inline int distance(const TPixel &c1, const TPixel &c2) {
|
|||
|
||||
int findClosest(const std::map<TPixel, int> &colorMap, TPixel &curPixColor) {
|
||||
std::map<TPixel, int>::const_iterator it = colorMap.begin();
|
||||
int minDistance = 1000000000;
|
||||
int index = -1;
|
||||
int minDistance = 1000000000;
|
||||
int index = -1;
|
||||
for (; it != colorMap.end(); ++it) {
|
||||
int dist = distance(it->first, curPixColor);
|
||||
if (dist < minDistance) {
|
||||
|
@ -140,7 +140,7 @@ int getMaxMatte(const TRaster32P &r) {
|
|||
for (int i = 0; i < r->getLy(); i++) {
|
||||
TPixel32 *pix = r->pixels(i);
|
||||
for (int j = 0; j < r->getLx(); j++, pix++) {
|
||||
maxMatte = std::max(maxMatte, (int)pix->m);
|
||||
maxMatte = std::max(maxMatte, (int)pix->m);
|
||||
if (pix->m != 255) withMatte = true;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ int getFramesCount(const TLevelP &l, int from, int to) {
|
|||
while (it != l->end() && it->first.getNumber() <= to) it++, count++;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
// namespace
|
||||
|
||||
std::map<TPixel, int>::const_iterator Convert2Tlv::findNearestColor(
|
||||
|
@ -186,7 +186,7 @@ std::map<TPixel, int>::const_iterator Convert2Tlv::findNearestColor(
|
|||
// assert((int)colorMap.size()>toIndex);
|
||||
// assert((int)colorMap.size()>fromIndex);
|
||||
std::map<TPixel, int>::const_iterator ret = m_colorMap.end(),
|
||||
it = m_colorMap.begin();
|
||||
it = m_colorMap.begin();
|
||||
// std::advance(it, fromIndex);
|
||||
|
||||
int mindist = 1000;
|
||||
|
@ -337,7 +337,7 @@ void Convert2Tlv::buildInksForNAAImage(TRasterCM32P &rout,
|
|||
curColor = *pixin;
|
||||
if ((it = m_colorMap.find(curColor)) == m_colorMap.end()) {
|
||||
if (m_lastIndex < 4095) m_colorMap[curColor] = ++m_lastIndex;
|
||||
curIndex = m_lastIndex;
|
||||
curIndex = m_lastIndex;
|
||||
} else
|
||||
curIndex = it->second;
|
||||
}
|
||||
|
@ -510,6 +510,8 @@ void Convert2Tlv::buildToonzRaster(TRasterCM32P &rout, const TRasterP &rin1,
|
|||
int maxMatte = getMaxMatte((TRaster32P)rU);
|
||||
if (maxMatte == -1)
|
||||
buildInksFromGrayTones(r, rU);
|
||||
else if (maxMatte == 0) // empty frame doesn't need further computation
|
||||
return;
|
||||
else {
|
||||
if (maxMatte < 255) normalize(rU, maxMatte);
|
||||
buildInks(r, (TRaster32P)rU /*rP,*/);
|
||||
|
@ -538,7 +540,7 @@ void Convert2Tlv::buildToonzRaster(TRasterCM32P &rout, const TRasterP &rin1,
|
|||
|
||||
TPalette *Convert2Tlv::buildPalette() {
|
||||
std::map<TPixel, int>::const_iterator it = m_colorMap.begin();
|
||||
TPalette::Page *page = m_palette->getPage(0);
|
||||
TPalette::Page *page = m_palette->getPage(0);
|
||||
|
||||
QList<int> stylesToBeAddedToPage;
|
||||
|
||||
|
@ -709,7 +711,7 @@ bool Convert2Tlv::init(std::string &errorMessage) {
|
|||
m_colorMap.clear();
|
||||
|
||||
try {
|
||||
m_lr1 = TLevelReaderP(m_levelIn1);
|
||||
m_lr1 = TLevelReaderP(m_levelIn1);
|
||||
if (m_lr1) m_level1 = m_lr1->loadInfo();
|
||||
} catch (...) {
|
||||
errorMessage =
|
||||
|
@ -727,7 +729,7 @@ bool Convert2Tlv::init(std::string &errorMessage) {
|
|||
|
||||
if (m_levelIn2 != TFilePath()) {
|
||||
try {
|
||||
m_lr2 = TLevelReaderP(m_levelIn2);
|
||||
m_lr2 = TLevelReaderP(m_levelIn2);
|
||||
if (m_lr2) level2 = m_lr2->loadInfo();
|
||||
} catch (...) {
|
||||
errorMessage =
|
||||
|
@ -815,7 +817,7 @@ bool Convert2Tlv::init(std::string &errorMessage) {
|
|||
for (int i = 0; i < m_palette->getStyleCount(); i++)
|
||||
if (m_palette->getStylePage(i)) {
|
||||
m_colorMap[m_palette->getStyle(i)->getMainColor()] = i;
|
||||
if (i > m_lastIndex) m_lastIndex = i;
|
||||
if (i > m_lastIndex) m_lastIndex = i;
|
||||
}
|
||||
assert(m_colorMap.size() == m_palette->getStyleInPagesCount());
|
||||
}
|
||||
|
@ -898,7 +900,9 @@ bool Convert2Tlv::convertNext(std::string &errorMessage) {
|
|||
|
||||
TLevel::Iterator itaux = m_it;
|
||||
itaux++;
|
||||
if (itaux == m_level1->end()) // ultimo frame da scrivere.
|
||||
if (itaux == m_level1->end() ||
|
||||
(m_to != -1 &&
|
||||
itaux->first.getNumber() > m_to)) // ultimo frame da scrivere.
|
||||
timg->setPalette(buildPalette());
|
||||
|
||||
iw->save(timg);
|
||||
|
|
Loading…
Reference in a new issue