Ejemplo n.º 1
0
 private void _htmlScreenCapture_HtmlScreenCaptureAvailable(object sender, HtmlScreenCaptureAvailableEventArgsCore e)
 {
     if (HtmlScreenCaptureAvailable != null)
     {
         HtmlScreenCaptureAvailableEventArgs ea = new HtmlScreenCaptureAvailableEventArgs(e.Bitmap);
         HtmlScreenCaptureAvailable(this, ea);
         e.CaptureCompleted = ea.CaptureCompleted;
     }
 }
Ejemplo n.º 2
0
        void htmlScreenCapture_HtmlScreenCaptureAvailable_RectangleTest(object sender, HtmlScreenCaptureAvailableEventArgs e)
        {
            Bitmap bitmap = e.Bitmap ;
            int xRect =  (int)Math.Round(bitmap.Width * rectTest.X-(rectTest.Width / 2));
            int yRect =  (int)Math.Round(bitmap.Height * rectTest.Y - (rectTest.Height / 2));

            int nonMatchingPixelCount = 0;
            for (int x = xRect; x < xRect + rectTest.Width; x++)
            {
                for (int y = yRect; y < yRect + rectTest.Height; y++)
                {
                    Color color = bitmap.GetPixel(x, y);
                    if (color.A != rectTest.Color.A ||
                        color.R != rectTest.Color.R ||
                        color.G != rectTest.Color.G ||
                        color.B != rectTest.Color.B)
                        nonMatchingPixelCount++;
                }
            }
            e.CaptureCompleted = nonMatchingPixelCount == 0 || TimedOut;
        }
Ejemplo n.º 3
0
        private void htmlScreenCapture_HtmlScreenCaptureAvailable_ColorTest(object sender, HtmlScreenCaptureAvailableEventArgs e)
        {
            const int PLAYER_CONTROL_OFFSET = 30;
            // get the bitmap
            Bitmap bitmap = e.Bitmap ;

            int pixelCount = 0;
            for (int x=0; x<bitmap.Width; x++)
            {
                for ( int y=0; y<bitmap.Height - PLAYER_CONTROL_OFFSET; y++)
                {
                    if (bitmap.GetPixel(x, y) == testColor)
                        pixelCount++ ;
                }
            }

            int totalPixels = bitmap.Width*(bitmap.Height - PLAYER_CONTROL_OFFSET);

            double pctBackground = Convert.ToDouble(pixelCount)/Convert.ToDouble(totalPixels);
            //Trace.WriteLine("how much test Color: " + pctBackground.ToString());
            e.CaptureCompleted = pctBackground < testPct || TimedOut;
        }
Ejemplo n.º 4
0
        private void htmlScreenCapture_HtmlScreenCaptureAvailable_ChangeTest(object sender, HtmlScreenCaptureAvailableEventArgs e)
        {
            // get the bitmap
            Bitmap bitmap = e.Bitmap ;
            int totalPixels = 0;
            if (testBitmap == null)
                testBitmap = (Bitmap)e.Bitmap.Clone();

            int countPixels = 0 ;
            //only doing some pixels to speed this up!
            for (int x=0; x<bitmap.Width; x+=8)
            {
                for ( int y=0; y<bitmap.Height; y+=8)
                {
                    totalPixels++;
                    if (bitmap.GetPixel(x, y) == testBitmap.GetPixel(x, y))
                        countPixels++ ;
                }

            }

            // if more than 80% of all pixels the same as first look then
            // this is not a thumbnail
            double pctBackground = Convert.ToDouble(countPixels) / Convert.ToDouble(totalPixels) ;
            //Trace.WriteLine("difference in snapshots: " + pctBackground.ToString());
            e.CaptureCompleted = pctBackground < .80F || TimedOut;
        }
 private void _htmlScreenCapture_HtmlScreenCaptureAvailable(object sender, HtmlScreenCaptureAvailableEventArgsCore e)
 {
     if (HtmlScreenCaptureAvailable != null)
     {
         HtmlScreenCaptureAvailableEventArgs ea = new HtmlScreenCaptureAvailableEventArgs(e.Bitmap);
         HtmlScreenCaptureAvailable(this, ea);
         e.CaptureCompleted = ea.CaptureCompleted;
     }
 }