summaryrefslogtreecommitdiffstats
path: root/pics/ksvgtopng.cpp
blob: 27f2545da6d071de288fa182347bff8c5c999c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <qimage.h>
#include <qstring.h>

#include <kimageeffect.h>

#include <ksvgiconengine.h>
#include <ksvgiconpainter.h>

#include <iostream>

using std::cout;
using std::endl;

int main(int argc, char **argv)
{
	if(argc < 5)
	{
		cout << "Usage : ksvgtopng width height svgfilename outputfilename" << endl;
		cout << "Please use full path name for svgfilename" << endl;
		return -1;
	}

	int width = atoi(argv[1]);
	int height = atoi(argv[2]);

	QImage *img = 0;

	KSVGIconEngine *svgEngine = new KSVGIconEngine();

	if(svgEngine->load(width, height, argv[3]))
	{
		img = svgEngine->painter()->image();
/*		
		// Apply icon sharpening
		double factor = 0;

		if(width == 16)
			factor = 30;
		else if(width == 32)
			factor = 20;
		else if(width == 48)
			factor = 10;
		else if(width == 64)
			factor = 5;

		*img = KImageEffect::sharpen(*img, factor);		
*/
	}
	else
		img = new QImage();

	delete svgEngine;

	img->save(argv[4], "PNG");

	delete img;

	return 0;
}