Browse Source

imageconverter: restore the --converter raw option.

Broken with 5a8d31bf68. Tests. Did I
mention I need tests for this?
pull/578/head
Vladimír Vondruš 4 years ago
parent
commit
66d29d1b53
  1. 24
      src/Magnum/Trade/imageconverter.cpp

24
src/Magnum/Trade/imageconverter.cpp

@ -965,9 +965,10 @@ no -C / --converter is specified, AnyImageConverter is used.)")
(outputDimensions == 2 && outputImages2D.front().isCompressed()) || (outputDimensions == 2 && outputImages2D.front().isCompressed()) ||
(outputDimensions == 3 && outputImages3D.front().isCompressed()); (outputDimensions == 3 && outputImages3D.front().isCompressed());
/* Load converter plugin */ /* Load converter plugin if a raw conversion is not requested */
Containers::Pointer<Trade::AbstractImageConverter> converter = converterManager.loadAndInstantiate(converterName); Containers::Pointer<Trade::AbstractImageConverter> converter;
if(!converter) { if(converterName != "raw"_s) {
if(!(converter = converterManager.loadAndInstantiate(converterName))) {
Debug{} << "Available converter plugins:" << ", "_s.join(converterManager.aliasList()); Debug{} << "Available converter plugins:" << ", "_s.join(converterManager.aliasList());
return 2; return 2;
} }
@ -976,21 +977,24 @@ no -C / --converter is specified, AnyImageConverter is used.)")
if(args.isSet("verbose")) converter->addFlags(Trade::ImageConverterFlag::Verbose); if(args.isSet("verbose")) converter->addFlags(Trade::ImageConverterFlag::Verbose);
if(i < args.arrayValueCount("converter-options")) if(i < args.arrayValueCount("converter-options"))
Implementation::setOptions(*converter, "AnyImageConverter", args.arrayValue("converter-options", i)); Implementation::setOptions(*converter, "AnyImageConverter", args.arrayValue("converter-options", i));
}
/* This is the last --converter (or the implicit AnyImageConverter at /* This is the last --converter (a raw output, a file-capable converter
the end), output to a file and exit the loop */ or the implicit AnyImageConverter at the end), output to a file and
if(i + 1 >= converterCount && (converter->features() & ( exit the loop */
if(i + 1 >= converterCount && (converterName == "raw"_s || (converter->features() & (
Trade::ImageConverterFeature::Convert1DToFile| Trade::ImageConverterFeature::Convert1DToFile|
Trade::ImageConverterFeature::Convert2DToFile| Trade::ImageConverterFeature::Convert2DToFile|
Trade::ImageConverterFeature::Convert3DToFile| Trade::ImageConverterFeature::Convert3DToFile|
Trade::ImageConverterFeature::ConvertCompressed1DToFile| Trade::ImageConverterFeature::ConvertCompressed1DToFile|
Trade::ImageConverterFeature::ConvertCompressed2DToFile| Trade::ImageConverterFeature::ConvertCompressed2DToFile|
Trade::ImageConverterFeature::ConvertCompressed3DToFile))) Trade::ImageConverterFeature::ConvertCompressed3DToFile))))
{ {
/* Decide what converter feature we should look for for given /* Decide what converter feature we should look for for given
dimension count. This has to be redone each iteration, as a dimension count. This has to be redone each iteration, as a
converted could have converted an uncompressed image to a converted could have converted an uncompressed image to a
compressed one and vice versa. */ compressed one and vice versa. */
if(converterName != "raw"_s) {
Trade::ImageConverterFeatures expectedFeatures; Trade::ImageConverterFeatures expectedFeatures;
if(outputDimensions == 1) { if(outputDimensions == 1) {
expectedFeatures = outputIsCompressed ? expectedFeatures = outputIsCompressed ?
@ -1019,6 +1023,7 @@ no -C / --converter is specified, AnyImageConverter is used.)")
err << outputDimensions << Debug::nospace << "D image to file conversion, only" << converter->features(); err << outputDimensions << Debug::nospace << "D image to file conversion, only" << converter->features();
return 6; return 6;
} }
}
if(args.isSet("verbose")) { if(args.isSet("verbose")) {
Debug d; Debug d;
@ -1103,6 +1108,11 @@ no -C / --converter is specified, AnyImageConverter is used.)")
/* This is not the last converter, expect that it's capable of /* This is not the last converter, expect that it's capable of
image-to-image conversion */ image-to-image conversion */
} else { } else {
if(converterName == "raw"_s) {
Error{} << "Only the very last --converter can be raw";
return 1;
}
CORRADE_INTERNAL_ASSERT(i < converterCount); CORRADE_INTERNAL_ASSERT(i < converterCount);
if(converterCount > 1 && args.isSet("verbose")) if(converterCount > 1 && args.isSet("verbose"))
Debug{} << "Processing (" << Debug::nospace << (i+1) << Debug::nospace << "/" << Debug::nospace << converterCount << Debug::nospace << ") with" << converterName << Debug::nospace << "..."; Debug{} << "Processing (" << Debug::nospace << (i+1) << Debug::nospace << "/" << Debug::nospace << converterCount << Debug::nospace << ") with" << converterName << Debug::nospace << "...";

Loading…
Cancel
Save