// 페이지수 다르게 SPLIT // 파라미터 : 원본 파일 비트맵 객체 public static bool SplitTif(string p_strPath, Bitmap p_srcFile, string p_strPages, string p_strOutFilePrefix, ref List <DbModule.SPLIT_FILE_INFO> p_lstOutFiles) { int from, to; char[] dash = new char[] { '-' }; DbModule.SPLIT_FILE_INFO splitFileInfo = new DbModule.SPLIT_FILE_INFO(); try { string[] pages = p_strPages.Split(new char[] { ',' }); // SPLIT 루프 for (int i = 0; i < pages.Length; ++i) { // SPLIT 파일 정보 SET splitFileInfo.Clear(); splitFileInfo.p_strPagesInOrg = pages[i]; splitFileInfo.p_strFile = string.Format("{0}_{1}.tif", p_strOutFilePrefix, i + 1); // SPLIT 파일 : from - to 얻기 string[] fromTo = pages[i].Split(dash); if (fromTo.Length == 1) { from = Convert.ToInt32(fromTo[0]); to = from;; } else if (fromTo.Length == 2) // 예1) "3-5", 예2) "7-" { from = Convert.ToInt32(fromTo[0]); if (fromTo[1].Length > 0) { to = Convert.ToInt32(fromTo[1]); // 예1) "3-5" } else { to = p_srcFile.GetFrameCount(FrameDimension.Page); // 예2) "7-". 끝페이지까지 } } else { AppLog.Write(LOG_LEVEL.ERR, string.Format("TIF파일 분리 시, 분리 페이지 정보가 잘 못 되었습니다.({0})", p_strPages)); return(false); } // SPLIT SplitTif(p_strPath, p_srcFile, from, to, ref splitFileInfo); // SPLIT 파일 정보 추가 p_lstOutFiles.Add(splitFileInfo); } } catch (Exception ex) { AppLog.ExceptionLog(ex, "TIF파일 분리 시, 예외가 발생하였습니다."); return(false); } return(true); }
private static bool SplitTif(string p_strPath, Bitmap p_srcFile, int p_nPageBegin, int p_nPageEnd, ref DbModule.SPLIT_FILE_INFO p_fileInfo) { Bitmap outFile = null; Bitmap outTempFile = null; Bitmap newFile; bool bFrameBuild; string strPathFile = p_strPath + "\\" + p_fileInfo.p_strFile; // TIF 페이지 추출 생성 bFrameBuild = false; for (int i = p_nPageBegin - 1; i <= p_nPageEnd - 1; ++i) { p_srcFile.SelectActiveFrame(FrameDimension.Page, i); // TIF 가로 픽셀이 1728이 아닌경우, Bitmap 재생성 newFile = null; if (p_srcFile.Width == 1728) { outTempFile = p_srcFile; } else { newFile = ReDrawToA4Size(p_srcFile); newFile = BitmapTo1Bpp(newFile); outTempFile = newFile; } if (!bFrameBuild) { bFrameBuild = true; outFile = outTempFile; outFile.Save(strPathFile, CODEC_TIF, EPS_Frame); } else { outFile.SaveAdd(outTempFile, EPS_FramePage); } if (newFile != null) { newFile.Dispose(); } } outFile.SaveAdd(EPS_Flush); // SPLIT 파일 정보 SET FileInfo info = new FileInfo(strPathFile); p_fileInfo.p_nPageCnt = p_nPageEnd - p_nPageBegin + 1; p_fileInfo.p_fileSize = info.Length; return(true); }