예제 #1
0
	void msgpack_pack(Packer& _Pk) const {
		_Pk.pack_array(4);
		_Pk.pack(key);
		_Pk.pack(ovalue);
		_Pk.pack(nvalue);
		_Pk.pack(xt);
	}
 void msgpack_pack(Packer& pk) const
 {
   if (is_double)
     pk.pack(msgpack::type::tuple<bool, double>(true, value.f));
   else
     pk.pack(msgpack::type::tuple<bool, int>(false, value.i));
 }
예제 #3
0
int main(int argc, char *argv[])
{
    parseCmdLine(argc, argv);
    setWriteEnabled(!dry_run);

    if(silent)
        setPrintMode(SILENT);
    else if(verbose)
        setPrintMode(VERBOSE);
    else
        setPrintMode(INFO);


    out_dir          = fs::path(cmd_output).parent_path();
    out_file_prepend = fs::path(cmd_output).filename().string();

    if(out_file_prepend == "." && boost::ends_with(fs::path(cmd_output).string(), "/"))
        out_file_prepend = "";

    if(read_stdin)
    {
        std::string line;
        while(!std::getline(std::cin, line).eof())
            input_paths.push_back(line);
    }

    std::vector<fs::path> files;
    findFiles(files);

    print(format("%d files found\n") % files.size());

    if(files.empty())
        return EXIT_SUCCESS;

    packer.setSheetSize(cmd_sheet_width, cmd_sheet_height);
    packer.setTexCoordOrigin(tex_coord_origin);
    packer.setPowerOfTwo(power_of_two);
    packer.setCompact(compact);
    packer.setExtrude(extrude);
    packer.setCaching(!no_cache);

    for(size_t i = 0; i < files.size(); i++)
        packer.addImage(files[i].string());

    if(packer.numImages() == 0)
        return EXIT_SUCCESS;

    packer.pack();
    writeData();

    return EXIT_SUCCESS;
}
예제 #4
0
 static void pack(Packer& pk, Tuple const& t) {
     define_map_imp<Tuple, N-1>::pack(pk, t);
     pk.pack(std::get<N-1>(t));
 }
예제 #5
0
 static void pack(Packer& pk, Tuple const& t) {
     pk.pack(std::get<0>(t));
 }
예제 #6
0
/**
 * エントリ
 */
int main(int argc, char *argv[]){
#if	0	// for debug
	std::vector<std::string> output_array;

	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0163.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0164.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0165.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0166.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0167.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0168.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0169.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0170.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0172.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0173.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0174.jpg;");
	output_array.push_back("E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\miku.png;");

	char* _argv[] = {
		"",
		"-i=E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0163.jpg;E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\eyes0164.jpg;",
//		"-o=E:\\GitHubRepository\\2dpacker\\2dpacker\\image\\packed.png",
//		"-p=100",
		"-pad=0",
		"-aln=false",
		"-d=true"
	};

	std::string output("-i=");
	if(!output_array.empty()){
		std::vector<std::string>::iterator it = output_array.begin();
		for(; it != output_array.end(); it++){
			output.append(*it);
		}
		_argv[1] = const_cast<char*>(output.c_str());
	}

	argv = _argv;
	argc = sizeof(_argv) / sizeof(_argv[0]);
#endif
	// {:パーサ文字列の開始
	// }:パーサ文字列の終了
	// |:セパレータ
	// ショートネーム,フルネーム,デフォルト値,ヘルプ文
	const char* keys = {
		"{i|input     |      |input files}"
		"{o|output    |      |output file}"
		"{p|param     |-1    |output parameter}"
		"{pad|padding |0     |padding pixel}"
		"{aln|aligned |false |aligned power of two boundary}"
		"{d|display   |false |display images}"
	};

	cv::CommandLineParser parser(argc, argv, keys);
	if(argc == 1){
		parser.printParams();
		return EXIT_SUCCESS;
	}

	std::string param_i = parser.get<std::string>("i");
	const std::string param_o = parser.get<std::string>("o");
	int param_p = parser.get<int>("p");
	const unsigned int param_pad = parser.get<unsigned int>("pad");
	const bool param_aln = parser.get<bool>("aln");
	const bool param_d = parser.get<bool>("d");

	if(param_i.empty()){
		std::cout << "[error] empty input data." << std::endl;
		return EXIT_FAILURE;
	}
	else{
#if 0
		std::stringstream ss(param_i);
		std::string temp;
		while(ss >> temp){
			input_images.push_back(temp);
		}
#else
		std::string temp;
		while(param_i.find(";", 0) != std::string::npos){
			size_t pos = param_i.find(";", 0);
			temp = param_i.substr(0, pos);
			param_i.erase(0, pos + 1);
			input_images.push_back(temp);
		}
#endif
	}
	// 出力設定
	padding = param_pad;
	aligned = param_aln;
	output_path = param_o;
	if(!output_path.empty()){
		ofmt_type = getExtension(output_path);
		if(ofmt_type == OutputFormat_Unsupported){
			std::cerr << "[error] unsupported output format." << std::endl;
			return EXIT_FAILURE;
		}
		if(ofmt_type == OutputFormat_Jpg){
			params.push_back(CV_IMWRITE_JPEG_QUALITY);
			param_p = (param_p == -1)? 95 : param_p;	// 0-100(default=95)
			params.push_back(param_p);
		}
		else
		if(ofmt_type == OutputFormat_Png){
			params.push_back(CV_IMWRITE_PNG_COMPRESSION);
			param_p = (param_p == -1)? 3 : param_p;	// 0-9(default=3)
			params.push_back(param_p);
		}
//		else
//		if(output_type == Output_Pnm){
//			params.push_back(CV_IMWRITE_PXM_BINARY);
//			param_p = (param_p == -1)? 1 : param_p;	// 0:ascii 1:binary(default=1)
//			params.push_back(param_p);
//		}
		om_type = (param_d)? OutputMode_Both : OutputMode_WriteOnly;
	}
	else{
		ofmt_type = OutputFormat_Png;
		om_type = OutputMode_DisplayOnly;
	}

	// 準備を行う
	setup();

	// パッキング
	packer.setPadding(padding);
	packer.setAligned(aligned);
	if(!packer.pack(inputs)){
		std::cerr << "[error] failed to pack." << std::endl;
		return EXIT_FAILURE;
	}

	// 画像の合成
	combineImages();

	cv::waitKey(0);

	return EXIT_SUCCESS;
}
예제 #7
0
 void packBoolean(Packer& pk, int index) const {
   int b = lua_toboolean(L, index);
   pk.pack(b != 0);
 }
예제 #8
0
 void packNumber(Packer& pk, int index) const {
   double n = lua_tonumber(L, index);
   int64_t i = static_cast<int64_t>(n);
   if (i == n) pk.pack(i);
   else pk.pack(n);
 }
예제 #9
0
	void msgpack_pack(Packer& _Pk) const {
		_Pk.pack_array(2);
		_Pk.pack(login);
		_Pk.pack(passw);
	}
예제 #10
0
 void pack(Packer& packer) const {
   packer.pack(*this);
 }
예제 #11
0
void NetExplosion::write(Packer & packer) const
{
	packer.pack(pos.x);
	packer.pack(pos.y);
}
예제 #12
0
	void msgpack_pack(Packer& _Pk) const {
		_Pk.pack_array(2);
		_Pk.pack(regex);
		_Pk.pack(max);
	}
예제 #13
0
	void msgpack_pack(Packer& _Pk) const {
		_Pk.pack_array(2);
		_Pk.pack(prefix);
		_Pk.pack(max);
	}
예제 #14
0
	void msgpack_pack(Packer& _Pk) const {
		_Pk.pack_array(1);
		_Pk.pack(key);
	}
예제 #15
0
void NetGameDataTdm::write(Packer & packer) const
{
	packer.pack(scoreA);
	packer.pack(scoreB);
}