Ver Fonte

添加序号起始值

maoyehu há 2 anos atrás
pai
commit
dc117ecdfa

+ 2 - 2
MFCApplication1/CvxText.cpp

@@ -443,7 +443,7 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 	int colWidth = fontW / cols; // 单栏的宽度
 	fSize.width = 0; fSize.height = 0;
 	Json::Value root(Json::arrayValue);
-	RNG rng;
+	//RNG rng;
 	for (int col = 0; col < cols; col++)
 	{ // 逐栏画题
 		int colTopPos = topPos;
@@ -483,7 +483,7 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 			cv::Rect rcAns(colLeftPos + 30, colTopPos + fSize.height, colWidth - ttBoxWidth, 1);
 			
 			colTopPos = colTopPos + fSize.height * 3.5; //两行之间两倍的距离用于书写
-			lineGrayPix = rng.operator ()(220);
+			//lineGrayPix = rng.operator ()(220);
 			line(img, cv::Point(colLeftPos + 30, colTopPos), cv::Point(colLeftPos + colWidth - 1, colTopPos), Scalar(lineGrayPix, lineGrayPix, lineGrayPix), 1, 8, 0);
 			rcAns.height = colTopPos - rcAns.y + lineDis;
 

BIN
MFCApplication1/MFCApplication1.rc


+ 31 - 2
MFCApplication1/MFCApplication1Dlg.cpp

@@ -102,6 +102,18 @@ DWORD WINAPI ProcessThread(void *param)
 	std::vector<std::string> fourList;
 	AssignWordsFromTest(UnicodeToGB2312(pWnd->m_strTextPath), twoList, threeList, fourList);
 
+	HMODULE module = GetModuleHandle(0);
+	TCHAR pFileName[MAX_PATH + 2] = { 0 };
+	GetModuleFileName(module, pFileName, MAX_PATH);
+
+	CString csFullPath(pFileName);
+	int nPos = csFullPath.ReverseFind(_T('\\'));
+	CString strFileDir = csFullPath.Left(nPos);
+	CString strFilePath = strFileDir + L"\\config.ini";
+	WCHAR wgray[10];
+	GetPrivateProfileString(L"USER", L"GrayPix", L"100", wgray, 10, strFilePath);
+	int nLineGrayPix = _wtoi(wgray);
+	
 	auto CovertPdfFunc = [&](std::vector<std::string>&  vctFiles, int col, int& pageNum){
 		std::string strPage1;
 		for (size_t i = 0; i < vctFiles.size(); i += max_line * col)
@@ -111,7 +123,7 @@ DWORD WINAPI ProcessThread(void *param)
 			vecSmall.insert(vecSmall.begin(), vctFiles.begin() + i, vctFiles.begin() + last);
 
 			std::string strPagePath;
-			dataCollectionPaper(col, pageNum, 30, 100, false, vecSmall, pWnd->m_strPdfDir, strPagePath);
+			dataCollectionPaper(col, pageNum, 30, nLineGrayPix, false, vecSmall, pWnd->m_strPdfDir, strPagePath);
 			if (strPage1.length() == 0)
 			{
 				strPage1 = strPagePath;
@@ -143,7 +155,7 @@ DWORD WINAPI ProcessThread(void *param)
 	};
 	
 
-	int pageNum = 100;
+	int pageNum = _wtoi(pWnd->m_strPageNumber);
 	CovertPdfFunc(twoList, 2, pageNum);
 	CovertPdfFunc(threeList, 3, pageNum);
 	CovertPdfFunc(fourList, 4, pageNum);
@@ -421,6 +433,7 @@ void CMFCApplication1Dlg::OnBnClickedOk()
 {
 	((CEdit*)GetDlgItem(IDC_EDIT_TXT))->GetWindowText(m_strTextPath);
 	((CEdit*)GetDlgItem(IDC_EDIT_PDF))->GetWindowText(m_strPdfDir);
+	((CEdit*)GetDlgItem(IDC_EDIT_PAGE_NUMBER))->GetWindowText(m_strPageNumber);
 	
 	if (m_strTextPath.GetLength() == 0)
 	{
@@ -432,6 +445,22 @@ void CMFCApplication1Dlg::OnBnClickedOk()
 		AfxMessageBox(L"PDF文件夹未选择");
 		return;
 	}
+	m_strPageNumber.Trim();
+	if (m_strPageNumber.GetLength() == 0)
+	{
+		AfxMessageBox(L"启始页码未输入");
+		return;
+	}
+	if (m_strPageNumber.SpanIncluding(_T("0123456789")) != m_strPageNumber)
+	{
+		AfxMessageBox(L"启始页码不是数字");
+		return;
+	}
+	if (_wtoi(m_strPageNumber.GetBuffer()) > 20000)
+	{
+		AfxMessageBox(L"启始页码小于20000");
+		return;
+	}
 
 	GetDlgItem(IDOK)->EnableWindow(FALSE);
 	m_strMsg = "";

+ 1 - 0
MFCApplication1/MFCApplication1Dlg.h

@@ -51,6 +51,7 @@ public:
 	
 	CString m_strTextPath;
 	CString m_strPdfDir;
+	CString m_strPageNumber;
 
 	CString m_strModePath;
 	CString m_strImgPath;

+ 3 - 1
MFCApplication1/resource.h

@@ -22,6 +22,8 @@
 #define IDC_EDIT_SCANMSG                1013
 #define IDC_EDIT_CUTPATH2               1014
 #define IDC_EDIT_SCANPROCESS            1014
+#define IDC_EDIT_START_NUMBER           1015
+#define IDC_EDIT_PAGE_NUMBER            1015
 
 // Next default values for new objects
 // 
@@ -29,7 +31,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        130
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1011
+#define _APS_NEXT_CONTROL_VALUE         1016
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif