Exemplo n.º 1
0
        private void btnGarbage2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_prevSketches.Count == 0)
                {
                    MessageBox.Show("Need stored images first", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                // Pick a random sketch
                var sketch = StaticRandom.NextItem(_prevSketches);

                Color[] colors        = sketch.BitmapColors.GetColors(0, 0, sketch.Bitmap.PixelWidth, sketch.Bitmap.PixelHeight);
                Color[] inverseColors = colors.
                                        Select(o =>
                {
                    bool isBlack = (o.A > 200 && Math1D.Avg(o.R, o.G, o.B) < 20);

                    // Invert the color
                    return(isBlack ? Colors.Transparent : Colors.Black);
                }).
                                        ToArray();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }