Esempio n. 1
0
 private static int detectRight(WriteableBitmap bmp)
 {
     for (int c = (bmp.PixelWidth - 1); c > 0; c--)
     {
         int count = 0;
         for (int r = (bmp.PixelHeight - 1); r > 0; r--)
         {
             Color color = bmp.GetPixel(c, r);
             if (color == Colors.White)
             {
                 count++;
             }
         }
         if (count > thCountY(bmp.PixelHeight) / 8)
         {
             return c;
         }
     }
     return 0;
 }
Esempio n. 2
0
        private void TimerOnTick(object sender, EventArgs eventArgs)
        {
            lastCount = count;
            count = 0;
            int[] pixelData = new int[(int)(camera.PreviewResolution.Width * camera.PreviewResolution.Height)];  //640x480

            camera.GetPreviewBufferArgb32(pixelData);

            WriteableBitmap freezeWriteableBitmap = new WriteableBitmap((int)camera.PreviewResolution.Width, (int)camera.PreviewResolution.Height);

            pixelData.CopyTo(freezeWriteableBitmap.Pixels, 0);

            freezeWriteableBitmap.Invalidate();
             //   timer.Stop();
            int[] buffer1 = buffer;

            try
            {
                camera.GetPreviewBufferArgb32(buffer);
               // camera.GetPreviewBufferY(bufferr);
            }
            catch (Exception e)
            {

            }
            //int t = 128;
               freezeWriteableBitmap = freezeWriteableBitmap.Resize(t, t,
                                                                 WriteableBitmapExtensions.Interpolation.Bilinear);
            /*
            for (int i = 0; i < bufferr.Length; i++)
            {
                if (bufferLast[i] != bufferr[i])
                {
                    count++;
                }
            }*/
            /*
              for (int i = 0; i < t; i++)
               {
               for (int j = 0; j < t; j++)
               {
                   var a = freezeWriteableBitmap.GetPixel(i, j);
                  byte d = (byte)((a.R + a.G + a.B)/3);

                    freezeWriteableBitmap.SetPixel(i,j, d,d,d);
               }
               }*/
            int srednia = 0;
            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j <t; j++)
                {
                    var d = freezeWriteableBitmap.GetPixel(i, j);

                    srednia += (d.R + d.G + d.B)/ 3;
                }
            }
            srednia = srednia/(128*128);
            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j <t; j++)
                {
                    var a = freezeWriteableBitmap.GetPixel(i, j);
                    if ((a.R + a.G + a.B)/3 <srednia)
                    {
                        freezeWriteableBitmap.SetPixel(i,j,0,0,0);
                    }
                    else
                    {
                        freezeWriteableBitmap.SetPixel(i,j,255,255,255);
                    }
                }
            }

               /*          int ApetureMin = -(10 / 2);
               int ApetureMax = (2 / 2);
            for (int x = 0; x < t; ++x)
            {
                for (int y = 0; y < t; ++y)
                {
                    int RValue = 0;
                    int GValue = 0;
                    int BValue = 0;
                    for (int x2 = ApetureMin; x2 < ApetureMax; ++x2)
                    {
                        int TempX = x + x2;
                        if (TempX >= 0 && TempX < t)
                        {
                            for (int y2 = ApetureMin; y2 < ApetureMax; ++y2)
                            {
                                int TempY = y + y2;
                                if (TempY >= 0 && TempY < t)
                                {
                                    Color TempColor = freezeWriteableBitmap.GetPixel(TempX, TempY);
                                    if (TempColor.R > RValue)
                                        RValue = TempColor.R;
                                    if (TempColor.G > GValue)
                                        GValue = TempColor.G;
                                    if (TempColor.B > BValue)
                                        BValue = TempColor.B;
                                }
                            }
                        }
                    }
                    //Color TempPixel = Color.FromArgb(0, (byte) RValue, (byte) GValue, (byte) BValue);
                    freezeWriteableBitmap.SetPixel(x, y, (byte)RValue, (byte)GValue, (byte)BValue);
                }
            }*/

            kopia.Source = freezeWriteableBitmap;

            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j < t; j++)
                {

                    if (zapisany.GetPixel(i, j) != freezeWriteableBitmap.GetPixel(i, j))
                    {
                        count++;

                    }
                }
            }
            if ((count - lastCount) > 100)
            {
                startButton.Content = "Ruch";
            }
            else
            {
                startButton.Content = "Brak ruchu";
            }

            if (count < 200)
            {
                setFrame();
            }
        }
 /**
  * Creates new frame image from current data (and previous
  * frames as specified by their disposition codes).
  */
 int[] GetPixels(WriteableBitmap bitmap)
 {
     int[] pixels = new int[3 * image.PixelWidth * image.PixelHeight];
     int count = 0;
     for (int th = 0; th < image.PixelHeight; th++)
     {
         for (int tw = 0; tw < image.PixelWidth; tw++)
         {
             Color color = bitmap.GetPixel(tw, th);
             pixels[count] = color.R;
             count++;
             pixels[count] = color.G;
             count++;
             pixels[count] = color.B;
             count++;
         }
     }
     return pixels;
 }
Esempio n. 4
0
        /**
         * Extracts image pixels into byte array "pixels"
         */
        protected void GetImagePixels()
        {
            int w = image.PixelWidth;
            int h = image.PixelHeight;
            //		int type = image.GetType().;
            if ((w != width)
                || (h != height)
                )
            {
                // create new image with right size/format
                WriteableBitmap temp =
                    new WriteableBitmap(width, height);
                temp.Blit(new Rect(0.0, 0.0, width, height), image, new Rect(0.0, 0.0, image.PixelWidth, image.PixelHeight));
                image = temp;
            }
            /*
                ToDo:
                improve performance: use unsafe code
            */
            pixels = new Byte[3 * image.PixelWidth * image.PixelHeight];
            int count = 0;
            WriteableBitmap tempBitmap = new WriteableBitmap(image);
            for (int th = 0; th < image.PixelHeight; th++)
            {
                for (int tw = 0; tw < image.PixelWidth; tw++)
                {
                    Color color = tempBitmap.GetPixel(tw, th);
                    pixels[count] = color.R;
                    count++;
                    pixels[count] = color.G;
                    count++;
                    pixels[count] = color.B;
                    count++;
                }
            }

            //		pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
        }
Esempio n. 5
0
    public RGBLuminanceSource(WriteableBitmap d, int W, int H)
#endif
        : base(W, H)
    {
        int width = __width = W;
        int height = __height = H;
        // In order to measure pure decoding speed, we convert the entire image to a greyscale array
        // up front, which is the same as the Y channel of the YUVLuminanceSource in the real app.
        luminances = new byte[width * height];
        //if (format == PixelFormat.Format8bppIndexed)
        {
            Color c;
            for (int y = 0; y < height; y++)
            {
                int offset = y * width;
                for (int x = 0; x < width; x++)
                {
                    c = d.GetPixel(x, y);
                    luminances[offset + x] = (byte)(((int)c.R) << 16 | ((int)c.G) << 8 | ((int)c.B));
                }
            }
        }
    }
        public void CalculateStarSize(WriteableBitmap bitmap)
        {
            int Max = 0;
            int Min = 800;
            int Count = 0;
            for (int i = 0; i < StarWindowSize-1; i++)
            {

                for (int j = 0; j < StarWindowSize-1; j++)
                {
                    var c = bitmap.GetPixel(i, j);
                    var greyVal = c.R + c.G + c.B;
                    if (greyVal > Threshold)
                        Count = Count + 1;
                    if (greyVal > Max)
                        Max = greyVal;

                    if (greyVal < Min)
                        Min = greyVal;
                }
            }
            MaximumValue = Max;
            MinimumValue = Min;
            Threshold = (Max + Min)/2;
            StarSize = ((double) Count + K*StarSizeOld)/(K + 1);
            StarSizeOld = StarSize;

        }
Esempio n. 7
0
 public static Color getTargetColor(MouseButtonEventArgs e, InkPresenter inkCanvas, WriteableBitmap wb)
 {
     return wb.GetPixel((int)e.GetPosition(inkCanvas).X, (int)e.GetPosition(inkCanvas).Y);
 }
        private Color GetColorFromImage(MouseEventArgs e)
        {
            Color color = Color.FromArgb(0, 0, 0, 0);

            try
            {
                var mousePos = e.GetPosition(this.mapImage);
                int x = (int)mousePos.X;
                int y = (int)mousePos.Y;

                var bitmap = new WriteableBitmap(this.mapImage, null);
                color = bitmap.GetPixel(x, y);

                if (_debugModeOn)
                {
                    string strColorARGB = string.Join(", ", color.A.ToString(), color.R.ToString(), color.G.ToString(), color.B.ToString());
                    txtSelectedCountry.Text = string.Format("ARGB: {0}", strColorARGB);
                }
            }
            catch { }

            return color;
        }
        public AdvGamePage()
        {
            InitializeComponent();

            var fileStream1 = Application.GetResourceStream(new Uri("TestImages/TestingUpper.png", UriKind.Relative));
            var s1 = new BitmapImage();
            using (var stream = fileStream1.Stream)
            {
                s1.SetSource(stream);
            }

            var upper = new WriteableBitmap(s1);

            var fileStream2 = Application.GetResourceStream(new Uri("TestImages/TestingLower.png", UriKind.Relative));
            var s2 = new BitmapImage();
            using (var stream = fileStream2.Stream)
            {
                s2.SetSource(stream);
            }

            var lower = new WriteableBitmap(s2);

            var upperEx = upper.GetBitmapContext();
            var lowerEx = lower.GetBitmapContext();

            UpperImage.Source = upper;
            LowerImage.Source = lower;

            upper.ForEach((x, y, color) =>
                {
                    var lowerColor = lower.GetPixel(x, y);
                    return new Color
                        {
                            R = (byte) (color.R - lowerColor.R),
                            G = (byte) (color.G - lowerColor.G),
                            B = (byte) (color.B - lowerColor.B),
                            A = color.A
                        };
                });
            upper.Invalidate();

            var changesPixels = new List<Point>();

            upper.ForEach((x, y, color) =>
                {
                    if (upper.GetPixel(x, y).R != 0)
                    {
                        lower.FillEllipseCentered(x, y, 10, 10, Colors.Red);
                        changesPixels.Add(new Point(x, y));
                    }

                    return color;
                });
            lower.Invalidate();

            //var indicator = new bool[480, 320];
            var startingPoint = changesPixels[0];
            var newPointToBeInvestigate = new List<Point> { startingPoint };
            changesPixels.Remove(startingPoint);
            //indicator[(int)startingPoint.X, (int)startingPoint.Y] = true;

            System.Diagnostics.Debug.WriteLine(DateTime.Now);

            var i = 0;
            while (newPointToBeInvestigate.Count > 0 && i < newPointToBeInvestigate.Count)
            {
                var newPixels = changesPixels.Where(p => DistanceBetweenPoints(newPointToBeInvestigate[i], p)).ToList();

                foreach (var np in newPixels)
                {
                    changesPixels.Remove(np);
                    newPointToBeInvestigate.Add(np);
                }

                //foreach (var newP in newPixels.Where(newP => !indicator[(int)newP.X, (int)newP.Y]))
                //{
                //    indicator[(int)newP.X, (int)newP.Y] = true;
                //}

                i++;

            }
            System.Diagnostics.Debug.WriteLine(DateTime.Now);

            foreach (var changeP in newPointToBeInvestigate)
            {
                lower.SetPixel((int)changeP.X, (int)changeP.Y, Colors.Green);
            }

            lower.Invalidate();
        }
Esempio n. 10
0
        private static void redrawMovedImage(WriteableBitmap tempWb, Image img)
        {
            int w = MainPage.layerList[clickedLayer].wb.PixelWidth;
            int h = MainPage.layerList[clickedLayer].wb.PixelHeight;

            MainPage.layerList[clickedLayer].wb.Clear();
            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    if (tempWb.GetPixel(i, j) != Color.FromArgb(0, 0, 0, 0))
                    {
                        Color tempPixel = tempWb.GetPixel(i, j);

                        int setX = i + (int)img.Margin.Left;
                        int setY = j + (int)img.Margin.Top;
                        if (setX < w && setX >= 0 && setY < h && setY >= 0)
                        {
                            MainPage.layerList[clickedLayer].wb.SetPixel(setX, setY, tempPixel);
                        }

                    }
                }
            }
        }
        private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                int Height = (int)IconPreview.ActualHeight;
                int Width = (int)IconPreview.ActualWidth;

                RenderTargetBitmap bmp = new RenderTargetBitmap(Width, Height, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(this.IconPreview);

                var wb = new WriteableBitmap(bmp);
                var pos = e.GetPosition(sender as FrameworkElement);
                _iconsGenerator.Color = wb.GetPixel((int) pos.X, (int) pos.Y);

                ColorPicker1.SelectedColor = _iconsGenerator.Color;
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 12
0
        void setFrame()
        {
            camera.GetPreviewBufferYCbCr(bufferLast);
            int[] pixelData = new int[(int)(camera.PreviewResolution.Width * camera.PreviewResolution.Height)];  //640x480

            camera.GetPreviewBufferArgb32(pixelData);
            zapisany = new WriteableBitmap((int)camera.PreviewResolution.Width, (int)camera.PreviewResolution.Height);

            pixelData.CopyTo(zapisany.Pixels, 0);

            zapisany.Invalidate();

            zapisany = zapisany.Resize(t, t,
                                                                 WriteableBitmapExtensions.Interpolation.Bilinear);

            /*            int ApetureMin = -(2 / 2);
            int ApetureMax = (2 / 2);
            for (int x = 0; x < t; ++x)
            {
                for (int y = 0; y < t; ++y)
                {
                    int RValue = 0;
                    int GValue = 0;
                    int BValue = 0;
                    for (int x2 = ApetureMin; x2 < ApetureMax; ++x2)
                    {
                        int TempX = x + x2;
                        if (TempX >= 0 && TempX < t)
                        {
                            for (int y2 = ApetureMin; y2 < ApetureMax; ++y2)
                            {
                                int TempY = y + y2;
                                if (TempY >= 0 && TempY < t)
                                {
                                    Color TempColor = zapisany.GetPixel(TempX, TempY);
                                    if (TempColor.R > RValue)
                                        RValue = TempColor.R;
                                    if (TempColor.G > GValue)
                                        GValue = TempColor.G;
                                    if (TempColor.B > BValue)
                                        BValue = TempColor.B;
                                }
                            }
                        }
                    }
                    //Color TempPixel = Color.FromArgb(0, (byte) RValue, (byte) GValue, (byte) BValue);
                    zapisany.SetPixel(x, y, (byte)RValue, (byte)GValue, (byte)BValue);
                }
            }*/

            /*        for (int i = 0; i < 128; i++)
                    {
                        for (int j = 0; j < 128; j++)
                        {
                            var a = zapisany.GetPixel(i, j);
                            byte d = (byte)((a.R + a.G + a.B) / 3);

                           zapisany.SetPixel(i, j, d, d, d);
                        }
                    }*/
            /*            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j < t; j++)
                {
                    var a = zapisany.GetPixel(i, j);
                    byte d = (byte)((a.R + a.G + a.B) / 3);

                    zapisany.SetPixel(i, j, d, d, d);
                }
            }*/

            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j < t; j++)
                {
                    var a = zapisany.GetPixel(i, j);
                    if ((a.R + a.G + a.B) / 3 < 128)
                    {
                        zapisany.SetPixel(i, j, 0, 0, 0);
                    }
                    else
                    {
                        zapisany.SetPixel(i, j, 255, 255, 255);
                    }
                }
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Converts a WritableBitmap to grayscale image
 /// </summary>
 public static WriteableBitmap ToGrayScale(WriteableBitmap bmp)
 {
     for (int i = 0; i < bmp.PixelHeight; i++)
     {
         for (int j = 0; j < bmp.PixelWidth; j++)
         {
             byte grayScale = Convert.ToByte((bmp.GetPixel(j, i).R * 0.3) + (bmp.GetPixel(j, i).G * 0.59) + (bmp.GetPixel(j, i).B * 0.11));
             Color c = Color.FromArgb(255, grayScale, grayScale, grayScale);
             bmp.SetPixel(j, i, c);
         }
     }
     return bmp;
 }
Esempio n. 14
0
        public static void floodFill(Point pt, Color targetColor, Color replacementColor, WriteableBitmap compressedBitmap, WriteableBitmap outputBitmap)
        {
            Queue<Point> q = new Queue<Point>();

            maxLeft = compressedBitmap.PixelWidth;
            //System.Diagnostics.Debug.WriteLine(maxLeft);
            maxRight = 0;
            maxTop = compressedBitmap.PixelHeight;
            //System.Diagnostics.Debug.WriteLine("while filling" + maxTop);
            maxBottom = 0;

            if (!Common.ColorMatch(compressedBitmap.GetPixel((int)pt.X, (int)pt.Y), targetColor) || Common.ColorMatch(compressedBitmap.GetPixel((int)pt.X, (int)pt.Y), replacementColor))
            {
                return;
            }

            q.Enqueue(pt);

            while (q.Count > 0)
            {
                Point n = q.Dequeue();

                if (Common.ColorMatch(compressedBitmap.GetPixel((int)n.X, (int)n.Y), targetColor))
                {
                    Point west = n;
                    Point east = n;

                    while ((west.X >= 0) && (west.X < compressedBitmap.PixelWidth) && Common.ColorMatch(compressedBitmap.GetPixel((int)west.X, (int)west.Y), targetColor))
                    {
                        west.X--;
                    }
                    while ((east.X >= 0) && (east.X < compressedBitmap.PixelWidth) && Common.ColorMatch(compressedBitmap.GetPixel((int)east.X, (int)east.Y), targetColor))
                    {
                        east.X++;
                    }
                    west.X++;
                    east.X--;

                    if (west.X < maxLeft)
                    {
                        maxLeft = west.X;
                    }

                    if (east.X > maxRight)
                    {
                        maxRight = east.X;
                    }

                    for (int i = (int)west.X; i <= east.X; i++)
                    {
                        compressedBitmap.SetPixel(i, (int)west.Y, replacementColor);
                        outputBitmap.SetPixel(i, (int)west.Y, replacementColor);
                        if ((i >= 0) && (i < compressedBitmap.PixelWidth) && (west.Y + 1 >= 0 && west.Y + 1 < compressedBitmap.PixelHeight) && Common.ColorMatch(compressedBitmap.GetPixel(i, (int)west.Y + 1), targetColor))
                        {
                            if (west.Y + 1 > maxBottom)
                            {
                                maxBottom = west.Y + 1;
                            }

                            q.Enqueue(new Point(i, west.Y + 1));
                        }
                        if ((i >= 0) && (i < compressedBitmap.PixelWidth) && (west.Y - 1 >= 0 && west.Y - 1 < compressedBitmap.PixelHeight) && Common.ColorMatch(compressedBitmap.GetPixel(i, (int)west.Y - 1), targetColor))
                        {
                            if (west.Y - 1 < maxTop)
                            {
                                maxTop = west.Y - 1;
                            }

                            q.Enqueue(new Point(i, west.Y - 1));
                        }
                    }
                }
            }
        }
Esempio n. 15
-1
        private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (toolState == 0)
            {
                canvas1.CaptureMouse();
                if (!activelyDrawing && toolState == 0) //just started to draw, save state first (in order to undo)
                {
                    updateUndoList();
                    activelyDrawing = true;
                }

                cur_p.x = (short)e.GetPosition(canvas1).X;
                cur_p.y = (short)e.GetPosition(canvas1).Y;

                prev_p = cur_p;
            }
            else if (toolState == 2)
            {
                bm = new WriteableBitmap(canvas1, null);
                Globals.scb.Color = bm.GetPixel((int)e.GetPosition(canvas1).X, (int)e.GetPosition(canvas1).Y);
                border2.Background = Globals.scb;
                makeToast("Color Sampled", "");
                toolState++;
                fillClick(null, null); //to move to pencil mode
                //NavigationService.Navigate(new Uri("/ColorPicker.xaml", UriKind.Relative));
            }
        }
        public WriteableBitmap EdgeDetection(WriteableBitmap bmap, double bound)
        {
            int height = bmap.PixelHeight - 1;
            int width = bmap.PixelWidth - 1;
            Matrix thetaM = new Matrix(width, height);
            Matrix greyM = new Matrix(width + 1, height + 1);
            for (int i = 0; i < greyM.Width; i++)
                for (int j = 0; j < greyM.Height; j++)
                    greyM[i, j] = Greyscale(bmap.GetPixel(i, j).R, bmap.GetPixel(i, j).G, bmap.GetPixel(i, j).B);

            for (int i = 1; i < width; i++)
                for (int j = 1; j < height; j++)
                {
                    Vector lx = new Vector(3);
                    Vector ly = new Vector(3);
                    lx[0] = greyM[i - 1, j];
                    lx[1] = greyM[i, j];
                    lx[2] = greyM[i + 1, j];
                    ly[0] = greyM[i, j - 1];
                    ly[1] = greyM[i, j];
                    ly[2] = greyM[i, j + 1];
                    Vector slx = SobelX(lx);
                    Vector sly = SobelY(ly);
                    double gx = Math.Pow(slx * slx, 0.5);
                    double gy = Math.Pow(sly * sly, 0.5);
                    thetaM[i - 1, j - 1] = Math.Atan2(gy, gx);
                }
            WriteableBitmap plot = BitmapFactory.New(width, height);
            for (int i = 0; i < width; i++)
                for (int j = 0; j < height; j++)
                {
                    if (thetaM[i, j] > bound)
                        plot.SetPixel(i, j, Colors.White);
                    else
                        plot.SetPixel(i, j, Colors.Black);
                }
            return plot;
        }
Esempio n. 17
-1
        public GameViewModel(WriteableBitmap img)
        {
            // Invert width and height cause of bmp?
            GridViewModel = new GridViewModel(img.PixelHeight, img.PixelWidth);

            // Get every pixel
            for (int x = 0; x < img.PixelWidth; x++)
            {
                for (int y = 0; y < img.PixelHeight; y++)
                {
                    Color color = img.GetPixel(x, y);

                    float r, g, b, a;

                    if (color.A < 20)
                    {
                        a = 1;
                        r = 1;
                        g = 1;
                        b = 1;
                    }
                    else
                    {
                        a = 1;
                        r = color.R / 255f;
                        g = color.G / 255f;
                        b = color.B / 255f;
                    }

                    // invert x and y
                    GridViewModel.SetPixelData(y, x, new Data.CellColor()
                    {
                        A = a,
                        R = r,
                        G = g,
                        B = b,
                    });
                }
            }

            GridViewModel.SetupGrid();
            GridViewModel.UpdateView(null);
        }
Esempio n. 18
-1
        public MainViewModel()
        {
            SizeX = 768;
            SizeY = 512;
            SpotSizeX = 200;
            SpotSizeY = 233;

            SpotColors = new List<Color>
            {
                Color.FromArgb(150, 164, 232, 0),
                Color.FromArgb(150, 255, 185, 17),
                Color.FromArgb(150, 0, 149, 59),
                Color.FromArgb(150, 222, 184, 99),
                Color.FromArgb(150, 234, 0, 53),
            };

            var colors = new List<Color>
            {
                Colors.Red,
                Colors.Blue,
                Colors.Green
            };
            Overlay = new WriteableBitmap(SizeX, SizeY, 96, 96, PixelFormats.Pbgra32, new BitmapPalette(colors));
            Overlay.Clear(Colors.Black);

            PixSpots = new List<Blot>();
            Pixs = new List<byte[,]>();

            var spots =
                Directory.GetFiles(Directory.GetCurrentDirectory() + @"\img\").Where(p => p.Contains(".png")).ToArray();
            foreach (var spot in spots)
            {
                Pixs.Add(new byte[SpotSizeX, SpotSizeY]);
                var img = new WriteableBitmap(new BitmapImage(new Uri(spot)));
                for (var i = 0; i < img.PixelWidth; i++)
                    for (var j = 0; j < img.PixelHeight; j++)
                        if (img.GetPixel(i, j).A > 0)
                            Pixs[Pixs.Count - 1][i, j] = 1;
            }
        }
Esempio n. 19
-1
 private static int detectTop(WriteableBitmap bmp)
 {
     for (int r = 0; r < bmp.PixelHeight - 1; r++)
     {
         int count = 0;
         for (int c = 0; c < bmp.PixelWidth - 1; c++)
         {
             Color color = bmp.GetPixel(c, r);
             if (color == Colors.White)
             {
                 count++;
             }
         }
         if (count > thCountX(bmp.PixelWidth))
         {
             return r;
         }
     }
     return 0;
 }