Example #1
0
 public bool SaveTIF(string fpOut, int convdpi)
 {
     if (fpPDF != null)
     {
         return(PDFUt.PDF2TIF(fpPDF, fpOut, convdpi, null, 1 + index));
     }
     else
     {
         return(Tiffcp.Run(fpOut, fpTIF + "," + index, false, false));
     }
 }
Example #2
0
        private void bwImport_DoWork(object sender, DoWorkEventArgs e)
        {
            bwImport.ReportProgress(0, "");
            while (true)
            {
                String fptry = null;
                lock (importFiles) {
                    if (importFiles.Count == 0)
                    {
                        break;
                    }
                    fptry = importFiles[0];
                    importFiles.RemoveAt(0);
                }

                String fpTIF = null;
                bool   isPDF = false;
                if (FIUt.IsPDF(fptry))
                {
                    fpTIF = tempFiles.NewFile(".tif");
                    bwImport.ReportProgress(0, "PDF 画像変換");
                    if (!PDFUt.PDF2TIF(fptry, fpTIF, null, sizeThumb.Width, null))
                    {
                        continue;
                    }
                    isPDF = true;
                }
                else
                {
                    fpTIF = fptry;
                }

                if (fpTIF != null)
                {
#if true
                    FIMULTIBITMAP      tif       = FreeImage.OpenMultiBitmapEx(fpTIF, true, false);
                    List <PicProvider> providers = new List <PicProvider>();
                    try {
                        int nPages = FreeImage.GetPageCount(tif);
                        for (int x = 0; x < nPages; x++)
                        {
                            FIBITMAP dib = FreeImage.LockPage(tif, x);
                            try {
                                FIBITMAP thumb = FreeImage.MakeThumbnail(dib, sizeThumb.Width, true);
                                try {
                                    bwImport.ReportProgress(0, String.Format("{0}/{1} from {2}", 1 + x, nPages, fptry));
                                    providers.Add(new PicProvider(FreeImage.GetBitmap(thumb), fpTIF, isPDF ? fptry : null, x, FreeImage.GetBPP(dib) == 1));
                                }
                                finally {
                                    FreeImage.UnloadEx(ref thumb);
                                }
                            }
                            finally {
                                FreeImage.UnlockPage(tif, dib, false);
                            }
                        }
                    }
                    finally {
                        FreeImage.CloseMultiBitmapEx(ref tif);
                    }

                    foreach (PicProvider pp in providers)
                    {
                        AddPage(pp);
                    }
#else
                    using (Bitmap pic = new Bitmap(fpTIF)) {
                        int nPages = pic.GetFrameCount(FrameDimension.Page);
                        for (int x = 0; x < nPages; x++)
                        {
                            pic.SelectActiveFrame(FrameDimension.Page, x);
                            AddPage(new PicProvider(ThumbUtil.Make(pic, sizeThumb), fpTIF, isPDF ? fptry : null, x, pic.PixelFormat == PixelFormat.Format1bppIndexed));
                        }
                    }
#endif
                }
            }
        }