本文整理汇总了C++中Arguments::destination方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::destination方法的具体用法?C++ Arguments::destination怎么用?C++ Arguments::destination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arguments
的用法示例。
在下文中一共展示了Arguments::destination方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName("Vincent Tim");
QCoreApplication::setApplicationVersion("1.2");
#ifdef Q_OS_WIN
QTextCodec::setCodecForLocale(QTextCodec::codecForName("IBM 850"));
#endif
#ifdef TESTS_ENABLED
qDebug() << "Running tests...";
Collect c("tests/tim/files");
c.textureData("tim");
#endif
Arguments args;
if (args.help() || args.paths().isEmpty()) {
args.showHelp();
} else {
foreach (const QString &path, args.paths()) {
TextureFile *texture;
if (args.inputFormat(path) == args.outputFormat()) {
qWarning() << "Error: input and output formats are not different";
a.exit(1);
}
QFile f(path);
if (f.open(QIODevice::ReadOnly)) {
if (!args.analysis()) {
texture = TextureFile::factory(args.inputFormat(path));
if (texture->open(f.readAll())) {
if (TextureFile::supportedTextureFormats().contains(args.outputFormat(), Qt::CaseInsensitive)) {
if (!toTexture(texture, path, args)) {
break;
}
} else if (TextureFile::supportedTextureFormats().contains(args.inputFormat(path), Qt::CaseInsensitive)) {
fromTexture(texture, path, args);
} else {
qWarning() << "Error: input format or output format must be a supported texture format" << TextureFile::supportedTextureFormats();
a.exit(1);
}
} else {
qWarning() << "Error: Cannot open Texture file";
a.exit(1);
}
f.close();
delete texture;
} else { // Search tim files
QList<PosSize> positions = TimFile::findTims(&f);
int num = 0;
foreach (const PosSize &pos, positions) {
texture = new TimFile();
f.seek(pos.first);
if (texture->open(f.read(pos.second))) {
if (args.outputFormat().compare("tim", Qt::CaseInsensitive) == 0) {
if (!texture->saveToFile(args.destination(path, num))) {
qWarning() << "Error: Cannot save Texture file from" << QDir::toNativeSeparators(path) << "to" << args.destination(path, num);
continue;
} else {
printf("%s\n", qPrintable(QDir::toNativeSeparators(args.destination(path, num))));
}
} else {
fromTexture(texture, path, args, num);
}
num++;
} else {
qWarning() << "Error: Cannot open Texture file from" << QDir::toNativeSeparators(path);
a.exit(1);
}
delete texture;
}
}
} else {
qWarning() << "Error: cannot open file" << QDir::toNativeSeparators(path) << f.errorString();
a.exit(1);
}
}
示例2: fromTexture
void fromTexture(TextureFile *texture, const QString &path, const Arguments &args, int num = -1)
{
QString destPathTexture;
bool error = false;
if (args.palette() < 0 || args.palette() >= texture->colorTableCount()) {
if (texture->colorTableCount() <= 0) {
destPathTexture = args.destination(path, num);
if (!saveTextureTo(texture, destPathTexture)) {
error = true;
}
}
for (int paletteID=0; paletteID<texture->colorTableCount(); ++paletteID) {
texture->setCurrentColorTable(paletteID);
destPathTexture = args.destination(path, num, paletteID);
if (!saveTextureTo(texture, destPathTexture)) {
error = true;
}
}
} else {
destPathTexture = args.destination(path, num);
if (!saveTextureTo(texture, destPathTexture)) {
error = true;
}
}
if (!error) {
if (args.exportMeta()) {
ExtraData meta = texture->extraData();
if (!meta.fields().isEmpty()) {
QString destPathMeta = args.destinationMeta(path, num);
if (!meta.save(destPathMeta)) {
qWarning() << "Error: Cannot save extra data";
return;
} else {
printf("%s\n", qPrintable(QDir::toNativeSeparators(destPathMeta)));
}
}
}
if (args.exportPalettes() && texture->depth() < 16) { // Do not use isPaletted for that!
QImage palette = texture->palette();
if (!palette.isNull()) {
QString destPathPalette = args.destinationPalette(path, num);
if (!palette.save(destPathPalette)) {
qWarning() << "Error: Cannot save palette";
return;
}
printf("%s\n", qPrintable(QDir::toNativeSeparators(destPathPalette)));
} else {
qWarning() << "Warning: No palette to export";
return;
}
}
}
if (error) {
qWarning() << "Error: Cannot save image";
}
}
示例3: toTexture
bool toTexture(TextureFile *texture, const QString &path, const Arguments &args, int num = -1)
{
QString pathMeta = args.inputPathMeta(path),
pathPalette = args.inputPathPalette(path);
if (pathMeta.isEmpty()) {
qWarning() << "Error: Please set the input path meta";
return false;
}
TextureFile *tex;
QString destPath;
if (args.outputFormat().compare("tex", Qt::CaseInsensitive) == 0) {
tex = new TexFile(*texture);
} else if (args.outputFormat().compare("tim", Qt::CaseInsensitive) == 0) {
tex = new TimFile(*texture);
} else {
qWarning() << "toTexture: output format not supported";
return false;
}
ExtraData meta;
if (!meta.open(pathMeta)) {
qWarning() << "Meta data not found!" << QDir::toNativeSeparators(pathMeta);
goto toTextureError;
}
tex->setExtraData(meta);
// Not texture to texture
if (args.outputFormat().compare(args.inputFormat(path), Qt::CaseInsensitive) != 0
&& tex->depth() < 16) { // Do not use isPaletted for that!
if (pathPalette.isEmpty()) {
qWarning() << "Error: Please set the input path palette";
goto toTextureError;
}
QImage paletteImage;
if (paletteImage.load(pathPalette)) {
if (!tex->setPalette(paletteImage)) {
qWarning() << "Error: Please set the depth in the meta file";
goto toTextureError;
}
if (args.palette() < 0 || args.palette() >= tex->colorTableCount()) {
qWarning() << "Error: Please set a valid number of palette";
goto toTextureError;
}
tex->convertToIndexedFormat(args.palette());
} else {
qWarning() << "Error: Cannot open the input palette";
goto toTextureError;
}
}
destPath = args.destination(path, num);
if (!tex->saveToFile(destPath)) {
goto toTextureError;
}
printf("%s\n", qPrintable(QDir::toNativeSeparators(destPath)));
delete tex;
return true;
toTextureError:
delete tex;
return false;
}