/* Allocate and initialize a NEW TREEFOLDER */ static LPTREEFOLDER NewFolder(const char *lpTitle, UINT nFolderId, int nParent, UINT nIconId, DWORD dwFlags) { LPTREEFOLDER lpFolder = (LPTREEFOLDER)malloc(sizeof(TREEFOLDER)); memset(lpFolder, '\0', sizeof (TREEFOLDER)); lpFolder->m_lpTitle = (LPSTR)malloc(strlen(lpTitle) + 1); strcpy((char *)lpFolder->m_lpTitle,lpTitle); lpFolder->m_lpGameBits = NewBits(GetNumGames()); lpFolder->m_nFolderId = nFolderId; lpFolder->m_nParent = nParent; lpFolder->m_nIconId = nIconId; lpFolder->m_dwFlags = dwFlags; return lpFolder; }
static void main1(int argc, const char** argv) { print_g = true; // want to be able to see lprintfs if (argc != 2) Err("Usage: shapetostasm31 file.shape"); ShapeFile sh; // contents of the shape file sh.Open_(argv[1]); if (sh.shapes_[0].rows == 77) lprintf("Converting 77 point to 76 point shapes\n"); char newpath[SLEN]; sprintf(newpath, "%s_stasm31.shape", Base(argv[1])); lprintf("Generating %s ", newpath); FILE* file = fopen(newpath, "wb"); if (!file) Err("Cannot open %s for writing", newpath); Fprintf(file, "ss %s\n\n", newpath); Fprintf(file, "Directories %s\n\n", sh.dirs_); Pacifier pacifier(sh.nshapes_); for (int ishape = 0; ishape < sh.nshapes_; ishape++) { // we need the image width and height to convert the coords const char* imgpath = PathGivenDirs(sh.bases_[ishape], sh.dirs_, sh.shapepath_); cv::Mat_<unsigned char> img(cv::imread(imgpath, CV_LOAD_IMAGE_GRAYSCALE)); if (!img.data) Err("Cannot load %s", imgpath); Shape shape; if (sh.shapes_[0].rows == 77) shape = (ConvertShape(sh.shapes_[ishape], 76)); // convert 76 point shape else shape = sh.shapes_[ishape].clone(); CV_Assert(shape.rows); Fprintf(file, "\"%4.4x %s\"\n", NewBits(sh.bits_[ishape]), sh.bases_[ishape].c_str()); Fprintf(file, "{ %d %d\n", shape.rows, shape.cols); const int cols2 = img.cols / 2; const int rows2 = img.rows / 2; for (int i = 0; i < shape.rows; i++) { if (!PointUsed(shape, i)) Fprintf(file, "0 0\n"); else { double oldx = shape(i, IX) - cols2; double oldy = rows2 - shape(i, IY) - 1; if (!PointUsed(oldx, oldy)) oldx = XJITTER; Print(file, oldx, " "); Print(file, oldy, "\n"); } } Fprintf(file, "}\n"); pacifier.Print_(ishape); } pacifier.End_(); fclose(file); lprintf("\n"); }