[DEV] add tool to convert svg in bmp

This commit is contained in:
Edouard DUPIN 2015-12-30 21:15:06 +01:00
parent 197016453b
commit 59ad94637d
2 changed files with 79 additions and 0 deletions

34
lutin_esvg-convert.py Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/python
import lutin.module as module
import lutin.tools as tools
def get_type():
return "BINARY"
def get_sub_type():
return "TOOLS"
def get_desc():
return "eSVG converter in bitmap"
def get_licence():
return "APACHE-2"
def get_compagny_type():
return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
my_module.add_src_file([
'tools/converter.cpp'
])
my_module.add_module_depend(['esvg', 'test-debug'])
return my_module

45
tools/converter.cpp Normal file
View File

@ -0,0 +1,45 @@
/**
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <test-debug/debug.h>
#include <vector>
#include <etk/etk.h>
#include <esvg/esvg.h>
#undef __class__
#define __class__ "converter"
static void usage() {
TEST_PRINT(etk::getApplicationName() << " - help : ");
TEST_PRINT(" " << etk::getApplicationName() << " [options]");
TEST_PRINT(" --file=xxx convert file in the same file.bmp");
exit(-1);
}
int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
std::string inputFile;
for (int32_t iii=0; iii<_argc ; ++iii) {
std::string data = _argv[iii];
if (etk::start_with(data, "--file=") == true) {
inputFile = std::string(&data[7]);
TEST_PRINT("file='" << inputFile << "'");
} else if ( data == "-h"
|| data == "--help") {
usage();
}
}
if (inputFile == "") {
TEST_ERROR("Missing '--file' option");
usage();
}
esvg::Document doc;
doc.load(inputFile);
doc.generateAnImage(ivec2(512, 512), inputFile + ".bmp");
}