favorite立绘合成工具
-
测试解包软件为:garbro 其他软件可能会出现兼容问题
fav-bs.7z
源代码:#include<bits/stdc++.h> #include <io.h> #include <windows.h> #include <direct.h> #include <opencv2/opencv.hpp> #define image1 img1 #define image2 img2 #define mmax 100000 using namespace cv; using namespace std; void getFileNames(string path, vector<string>& files); void imgset(string path1, string path2); void overlayImages(const cv::Mat& background, const cv::Mat& foreground, cv::Mat& output, int x, int y) { output = background.clone(); cv::Rect roi(x, y, foreground.cols, foreground.rows); roi &= cv::Rect(0, 0, background.cols, background.rows); cv::Mat roi_output = output(roi); cv::Mat roi_foreground = foreground(cv::Rect(0, 0, roi.width, roi.height)); for (int i = 0; i < roi.height; ++i) { for (int j = 0; j < roi.width; ++j) { cv::Vec4b pixel_foreground = roi_foreground.at<cv::Vec4b>(i, j); cv::Vec4b& pixel_output = roi_output.at<cv::Vec4b>(i, j); double alpha = pixel_foreground[3] / 255.0; double beta = 1.0 - alpha; for (int k = 0; k < 3; ++k) { pixel_output[k] = static_cast<uchar>(alpha * pixel_foreground[k] + beta * pixel_output[k]); } } } } int main(){ system("md output"); system("md input"); system("cls"); printf("1.将立绘底部扔在程序目录下重命名为base.png\n2.将立绘面部扔在程序下input文件夹\n3.然后立绘将生成在output文件夹\n注意事项:请确保文件夹下没有其他类型的文件,并且所有文件为png文件\n"); system("pause"); system("cls"); char cwd[256]; _getcwd(cwd, 256); //cout << cwd << endl; string pp = cwd, pp1[mmax],pp2=pp+"\\base.png"; int pn = 0; vector<string> fileNames; string path(pp+"\\input"); getFileNames(path, fileNames); for (const auto &ph : fileNames) { pp1[pn] = ph; pn++; } for (int i = 0; i < pn; i++) imgset(pp1[i], pp2); system("cls"); printf("完成!\n"); system("pause"); return 0; } void getFileNames(string path, vector<string>& files){ intptr_t hFile = 0; struct _finddata_t fileinfo; string p; if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1){ do{ if ((fileinfo.attrib & _A_SUBDIR)){ if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) getFileNames(p.assign(path).append("\\").append(fileinfo.name), files); } else{ files.push_back(p.assign(path).append("\\").append(fileinfo.name)); } } while (_findnext(hFile, &fileinfo) == 0); _findclose(hFile); } } void imgset(string path1, string path2){ ifstream pic; pic.open(path1,ios::binary); for(int i=0;i<43;i++) pic.get(); int x=pic.get()*16*16+pic.get(); for(int i=0;i<2;i++) pic.get(); int y=pic.get()*16*16+pic.get(); Mat img1 = cv::imread(path2, cv::IMREAD_UNCHANGED); Mat img2 = cv::imread(path1, cv::IMREAD_UNCHANGED); Mat mergedImg; overlayImages(img1,img2,mergedImg,x,y); int plen1 = path1.size(), plen2 = path2.size(), p1=0, p2=0; for (; path1[plen1 - p1] != '\\'; p1++); for (; path2[plen2 - p2] != '\\'; p2++); //cout << p1 << ' ' << p2 << endl; string sp1="", sp2=""; for (int i = 1; i < p1 - 4; i++) sp1 += path1[plen1 - p1 + i]; for (int i = 1; i < p2 - 4; i++) sp2 += path2[plen2 - p2 + i]; //cout << sp1 << ' ' << sp2; imwrite(sp1 + '_' + sp2 + ".png", mergedImg); string temp = "move " + sp1 + '_' + sp2 + ".png" + " output"; system(temp.c_str()); }
-
要不。。。合并一下主题?