Beispiel #1
0
        private void CheckWidthHeight(List <string> lstFiles, ImageSizeFilter minimax)
        {
            //Filter the image width /ehgiht
            List <string> filtered2 = new List <string>();

            if (minimax != null)
            {
                int iFiltered = 0;
                foreach (string strPath in lstFiles)
                {
                    iFiltered++;
                    _objRifleManager.ShowStatus("Filtering W/H..." + iFiltered + "/" + lstFiles.Count);
                    try {
                        using (FileStream stream = new FileStream(strPath, FileMode.Open, FileAccess.Read))
                        {
                            //False 2nd 3rd parameter to avoid loading file into memer\
                            //http://stackoverflow.com/questions/552467/how-do-i-reliably-get-an-image-dimensions-in-net-without-loading-the-image
                            Image img = Image.FromStream(stream, false, false);
                            if (img.Width > minimax.MinWidth && img.Width < minimax.MaxWidth &&
                                img.Height > minimax.MinHeight && img.Height < minimax.MaxHeight)
                            {
                                filtered2.Add(strPath);
                            }
                        }
                    }
                    catch (Exception ex) {
                        //Swallow
                        int n;
                        n = 0;
                    }
                }
            }
            lstFiles.Clear();
            lstFiles.AddRange(filtered2);
        }
Beispiel #2
0
        public ImageSizeFilter GetMinMaxSize()
        {
            if (_chkFilterWidthHeight.Checked == false)
            {
                return(null);
            }

            ImageSizeFilter filt = new ImageSizeFilter();

            filt.MinWidth  = (int)_nudMinWidth.Value;
            filt.MaxWidth  = (int)_nudMaxWidth.Value;
            filt.MinHeight = (int)_nudMinHeight.Value;
            filt.MaxHeight = (int)_nudMaxHeight.Value;
            return(filt);
        }
Beispiel #3
0
 public FileCache(RifleManager objManager,
                  string strSearchPath,
                  int intMaxFiles,
                  int intTimeout,
                  bool blnRecursiveSearch,
                  ImageSizeFilter minimax = null
                  )
 {
     _intMaxFiles      = intMaxFiles;
     _strSearchPath    = strSearchPath;
     _objRifleManager  = objManager;
     _intGatherTimeout = intTimeout;
     Minimax           = minimax;
     RecursiveSearch   = blnRecursiveSearch;
 }