Esempio n. 1
0
int runCli(Arguments & args)
{
    QImage * image = new QImage(args.getSource());

    if (image->format() != QImage::Format_RGB32)
    {
        /* For working with image with QImage::bits()
         * and qRed(), qGreen() and qBlue() functions. */
        *image = image->convertToFormat(QImage::Format_RGB32);
    }

    if (image->isNull())
    {
        fatal(QObject::tr("Unable to load source image."));
    }

    processFilters(image, args.getFilters());

    bool ok = image->save(args.getDestination());

    if (!ok)
    {
        fatal(QObject::tr("Unable to save result image."));
    }

    return 0;
}
Esempio n. 2
0
int runGui(Arguments & args)
{
    if (! args.getFilters().isEmpty())
    {
        fatal(QObject::tr(
            "Point destination or remove filters arguments."));
    }

    MainWindow mainWindow(args.getSource());
    mainWindow.show();

    return qApp->exec();
}
Esempio n. 3
0
int main(int argc, char ** argv)
{
    QApplication app(argc, argv);

    Arguments args;
    try
    {
        args.parse(app.arguments());
    } catch(BadArgsException & e)
    {
        fatal(e.toString(), true);
    }

    if (args.hasHelpOption())
    {
        if (! args.getSource().isNull() ||
            ! args.getDestination().isNull() ||
            ! args.getFilters().isEmpty())
        {
            qDebug() << "Option --help pointed,"
                " all others are ignored.";
        }

        helpWrite();
        return 0;
    }

    if (! args.getSource().isNull() &&
        ! args.getDestination().isNull())
    {
        return runCli(args);
    }
    else 
    {
        return runGui(args);
    }
}