Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
        /// <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);
        }