예제 #1
0
파일: ImageSearching.cs 프로젝트: Nucs/nlib
        /// <summary>
        ///     Finds a single subimage, null if not found.
        /// </summary>
        public static Rectangle?SingleSubimage(this ImageSource <DirectBitmap> source, DirectBitmap small, int toleranceprecentage, bool forceupdate = false, ImageSearchingOptions opts = null)
        {
            opts = opts ?? ImageSearchingOptions.SingleMultithreaded;
            opts.NumberOfResults     = 1;
            opts.AllowMultithreading = true;
            var ret = Subimages(source, small, toleranceprecentage, forceupdate, opts)?.SingleOrDefault();

            return(ret == Rectangle.Empty ? null : ret);
        }
예제 #2
0
파일: ScreenCapture.cs 프로젝트: Nucs/nlib
        /// <summary>
        /// Captures a screen shot of a specific window, and saves it to a file
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="filename"></param>
        /// <param name="format"></param>
        public static void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)
        {
            DirectBitmap img = CaptureWindow(handle);

            img.Save(filename, format);
        }
예제 #3
0
파일: ImageSearching.cs 프로젝트: Nucs/nlib
 public static List <Rectangle> Subimages(this ImageSource <DirectBitmap> source, DirectBitmap small, int toleranceprecentage, bool forceupdate = false, ImageSearchingOptions opts = null)
 {
     opts = opts ?? ImageSearchingOptions.Default;
     using (var big = forceupdate ? source.FetchFresh : source.Fetch)
         return(big.FindSubimages(small, toleranceprecentage, ImageSearchingOptions.SingleMultithreaded));
 }
예제 #4
0
파일: ScreenCapture.cs 프로젝트: Nucs/nlib
        /// <summary>
        /// Captures a screen shot of the entire desktop, and saves it to a file
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="format"></param>
        public static void CaptureScreenToFile(string filename, ImageFormat format)
        {
            DirectBitmap img = CaptureScreen();

            img.Save(filename, format);
        }