argdox for stdockConvert; locale detection
[xcurtheme.git] / tests / xcur_unpack / main.cpp
blob2175da888d8db3ddce61551377fe80a630e14c3d
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
3 * This program is free software. It comes without any warranty, to
4 * the extent permitted by applicable law. You can redistribute it
5 * and/or modify it under the terms of the Do What The Fuck You Want
6 * To Public License, Version 2, as published by Sam Hocevar. See
7 * http://sam.zoy.org/wtfpl/COPYING for more details.
8 */
9 #include <QDebug>
10 //#include <QtCore>
12 #include "main.h"
14 #include <QApplication>
15 #include <QStringList>
16 #include <QTextCodec>
17 #include <QTextStream>
19 #include <QDir>
22 #include "xcrimg.h"
23 #include "xcrxcur.h"
26 ///////////////////////////////////////////////////////////////////////////////
27 int main (int argc, char *argv[]) {
28 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("koi8-r"));
29 QTextCodec::setCodecForLocale(QTextCodec::codecForName("koi8-r"));
31 QApplication app(argc, argv);
33 QStringList args(QCoreApplication::arguments());
34 if (args.size() < 2) {
35 fprintf(stderr, "usage: %s infile [outdir]\n", argv[0]);
36 return 1;
39 XCursorImages *il = new XCursorImagesXCur(args.at(1));
40 qDebug() << il->count() << "cursors found";
42 QString dirS(".");
43 if (args.size() > 2) dirS = args.at(2);
44 if (!dirS.isEmpty() && !dirS.endsWith('/')) dirS += '/';
46 QDir d;
47 d.mkdir(dirS);
49 // dump images
51 for (int f = 0; f < il->count(); ++f) {
52 const XCursorImage *img = il->at(f);
53 qDebug() << img->name();
54 img->image().save(dirS+img->name()+".png");
56 // now dump the script
58 QFile fl(dirS+il->name()+".xcg");
59 if (fl.open(QIODevice::WriteOnly)) {
60 QTextStream stream;
61 stream.setDevice(&fl);
62 stream.setCodec("UTF-8");
63 stream << "; nothing xhot yhot pic delay\n";
64 for (int f = 0; f < il->count(); ++f) {
65 const XCursorImage *img = il->at(f);
66 stream << "1 " << img->xhot() << " " << img->yhot() << " "+img->name()+".png" << " " << img->delay() << "\n";
68 fl.close();
70 //1 1 1 center_ptr_0.png 50
73 delete il;
75 return 0;