TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ksvgtopng.cpp 977B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <tqimage.h>
  2. #include <tqstring.h>
  3. #include <kimageeffect.h>
  4. #include <ksvgiconengine.h>
  5. #include <ksvgiconpainter.h>
  6. #include <iostream>
  7. using std::cout;
  8. using std::endl;
  9. int main(int argc, char **argv)
  10. {
  11. if(argc < 5)
  12. {
  13. cout << "Usage : ksvgtopng width height svgfilename outputfilename" << endl;
  14. cout << "Please use full path name for svgfilename" << endl;
  15. return -1;
  16. }
  17. int width = atoi(argv[1]);
  18. int height = atoi(argv[2]);
  19. TQImage *img = 0;
  20. KSVGIconEngine *svgEngine = new KSVGIconEngine();
  21. if(svgEngine->load(width, height, argv[3]))
  22. {
  23. img = svgEngine->painter()->image();
  24. /*
  25. // Apply icon sharpening
  26. double factor = 0;
  27. if(width == 16)
  28. factor = 30;
  29. else if(width == 32)
  30. factor = 20;
  31. else if(width == 48)
  32. factor = 10;
  33. else if(width == 64)
  34. factor = 5;
  35. *img = KImageEffect::sharpen(*img, factor);
  36. */
  37. }
  38. else
  39. img = new TQImage();
  40. delete svgEngine;
  41. img->save(argv[4], "PNG");
  42. delete img;
  43. return 0;
  44. }