Commit 3382b0cb authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

new test program to load PGF data from image file and convert it to QImg using...

new test program to load PGF data from image file and convert it to QImg using PGFUtils::readPGFImageData()
CCBUGS: 273765
parent c9cb6ce2
......@@ -238,3 +238,6 @@ SET(pgfscaled_SRCS pgfscaled.cpp ${libpgf_SRCS} ${pgfutils_SRCS})
KDE4_ADD_EXECUTABLE(pgfscaled NOGUI ${pgfscaled_SRCS})
TARGET_LINK_LIBRARIES(pgfscaled ${OPENMP_LDFLAGS} ${KDE4_KIO_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
SET(loadpgfdata_SRCS loadpgfdata.cpp ${libpgf_SRCS} ${pgfutils_SRCS})
KDE4_ADD_EXECUTABLE(loadpgfdata NOGUI ${loadpgfdata_SRCS})
TARGET_LINK_LIBRARIES(loadpgfdata ${OPENMP_LDFLAGS} ${KDE4_KIO_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2009-02-04
* Description : a command line tool to load PGF data and convert to QImage
*
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Qt includes
#include <QFile>
#include <QIODevice>
#include <QImage>
// KDE includes
#include <kdebug.h>
// Local includes
#include "pgfutils.h"
using namespace Digikam;
int main(int argc, char** argv)
{
if (argc != 2)
{
kDebug() << "loadpgfdata - Load PGF data and save to PNG";
kDebug() << "Usage: <pgffile>";
return -1;
}
QImage img;
// Write PGF file.
QString fname(argv[1]);
QFile file(fname);
if ( !file.open(QIODevice::ReadOnly) )
{
kDebug() << "Cannot open PGF file to read...";
return -1;
}
QByteArray data(file.size(), '\x00');
QDataStream stream(&file);
stream.readRawData(data.data(), data.size());
// PGF => QImage conversion
if (!readPGFImageData(data, img))
{
kDebug() << "loadPGFScaled failed...";
return -1;
}
img.save(file.fileName() + QString("-converted.png"), "PNG");
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment