private void CreateBindings()
        {
            ImageGrid.SetBinding(ToolTipProperty, new Binding("ItemTooltip")
            {
                Source = _model,
                Mode   = BindingMode.OneWay
            });

            Label.SetBinding(ContentProperty, new Binding("TransformationLabel")
            {
                Source = _model,
                Mode   = BindingMode.OneWay
            });

            RootGrid.SetBinding(VisibilityProperty, new Binding("Visibility")
            {
                Source = _model,
                Mode   = BindingMode.OneWay
            });

            Ring.SetBinding(VisibilityProperty, new Binding("RingVisibility")
            {
                Source = _model,
                Mode   = BindingMode.OneWay
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the threshold is to be set, or re-set
        /// takes the current range of changes and calculates threshold
        /// based on these ranges, and the specified sensitivity
        /// sets the gridImages object as each grid has its own threshold
        /// </summary>
        private void SetThreshold()
        {
            //set the threshold image
            ThresholdImage = new ImageGrid(gridImages[0].Columns[0].grids.Count, gridImages[0].Columns.Count);

            //do the calculation grid by grid
            for (int i = 0; i < gridImages[0].Columns.Count; i++)
            {
                ThresholdImage.Columns.Add(new GridColumn());

                for (int n = 0; n < gridImages[0].Columns[i].grids.Count; n++)
                {
                    List <double> gridTotals = new List <double>();
                    for (int k = 0; k < gridImages.Count; k++)
                    {
                        gridTotals.Add(gridImages[k].Columns[i].grids[n].positiveChange);
                    }

                    double buffer = ReturnBuffer(ReturnMax(gridTotals));
                    ThresholdImage.Columns[i].grids.Add(new Grid());
                    ThresholdImage.Columns[i].grids[n].threshold = Math.Round(buffer, 0);
                }
            }//each grid column

            ThresholdSet = true;
        }
Ejemplo n.º 3
0
        internal static void TileImages()
        {
            List <HoneycombDef> images = HoneycombPaper.GetImageSet().ToList();

            string[] inputImages = images.Select(i => i.FormatFilename()).ToArray();
            inputImages = new string[]
            {
                "46.png",
                "4_10.png",
                "4_20.png",
                "4i.png",
                "64.png",
                "10_4.png",
                "20_4.png",
                "i4.png",
            };

            ImageGrid imageGrid = new ImageGrid();

            imageGrid.Generate(new ImageGrid.Settings()
            {
                //Directory = @"C:\Users\hrn\Documents\roice\2D Tilings\2D Tilings 9-7-15\2D Tilings\bin\Release",
                Directory = @"C:\Users\hrn\Documents\roice\G4G\Figures",
                //Directory = @"./",
                InputImages = inputImages
            });
        }
Ejemplo n.º 4
0
        private void RunVideo(int Number)
        {
            switch (PlayStatus)
            {
            case MediaStatus.Play:
                return;

            case MediaStatus.Pause:
                if (WarningGrid.Opacity > 0)
                {
                    WarningGrid.BeginAnimation(OpacityProperty, OpacityAnimation(WarningGrid.Opacity, 0, 10));
                }
                else
                {
                    WarningGrid.BeginAnimation(OpacityProperty, OpacityAnimation(WarningGrid.Opacity, 1, 10));
                    WarningMessage();
                    return;
                }
                break;

            case MediaStatus.Stop:
                ImageGrid.BeginAnimation(OpacityProperty, OpacityAnimation(ImageGrid.Opacity, 0, 500));
                break;
            }

            mediaElement.Source = null;
            mediaElement.Source = new Uri(Path.GetFullPath(Config.GetConfigValue("video_" + Number.ToString())));

            StopList = Config.GetStringList("video_" + Number.ToString() + "_stop");

            mediaElement.Play();
            PlayStatus = MediaStatus.Play;
        }
Ejemplo n.º 5
0
        public string GetRowAndColumn(int v1X, int v1Y, int v2X, int v2Y, int v3X, int v3Y)
        {
            string rowAndColumn = string.Empty;

            try
            {
                var v1 = new Vertex()
                {
                    X = v1X, Y = v1Y
                };
                var v2 = new Vertex()
                {
                    X = v2X, Y = v2Y
                };
                var v3 = new Vertex()
                {
                    X = v3X, Y = v3Y
                };

                var vertices = new List <Vertex>(3)
                {
                    v1, v2, v3
                };
                var imageGrid = new ImageGrid();
                rowAndColumn = imageGrid.GetRowAndColumn(vertices);
            }
            catch (ArgumentException argEx) //also covers ArgumentOutOfRangeException as descendant
            {
                HandleArgumentErrors("vertices", argEx);
            }

            return(rowAndColumn);
        }
Ejemplo n.º 6
0
        private void Grid_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MouseIsDown = false;
            ImageGrid.ReleaseMouseCapture();

            ChangeSelectionRectangle(MouseDownPosition, e.GetPosition(ImageGrid));
        }
Ejemplo n.º 7
0
        public void Load(Song song, bool update = false)
        {
            if (song == null)
            {
                throw new ArgumentNullException("song");
            }

            this.song = song;

            base.Load(false, true);

            DoubleAnimation ani = new DoubleAnimation {
                From = 0.0, To = 1.0
            };

            storyboard = new Storyboard();
            storyboard.Children.Add(ani);
            Storyboard.SetTarget(ani, Control.ForegroundGrid);
            Storyboard.SetTargetProperty(ani, new PropertyPath(Image.OpacityProperty));

            if (song.VideoBackground == null)
            {
                frontImage = new ImageGrid {
                    Background = Brushes.Black, Stretch = Stretch.UniformToFill
                };
                backImage = new ImageGrid {
                    Background = Brushes.Black, Stretch = Stretch.UniformToFill
                };

                this.Control.BackgroundGrid.Children.Add(backImage);
                this.Control.ForegroundGrid.Children.Add(frontImage);
            }
            else
            {
                videoBackground = new AudioVideo.VlcWrapper();                 // TODO: use configurable wrapper (does WPF work?)

                videoBackground.Autoplay = true;
                videoBackground.Loop     = true;
                try
                {
                    videoBackground.Load(DataManager.Backgrounds.GetFile(song.VideoBackground).Uri);
                }
                catch (FileNotFoundException)
                {
                    throw new NotImplementedException("Video background file not found: Doesn't know what to do.");
                }

                var brush = new System.Windows.Media.VisualBrush(videoBackground);
                videoBackgroundClone      = new System.Windows.Shapes.Rectangle();
                videoBackgroundClone.Fill = brush;

                this.Control.ForegroundGrid.Children.Add(videoBackground);
                this.Control.BackgroundGrid.Children.Add(videoBackgroundClone);
            }

            this.Control.Web.IsTransparent   = true;
            this.Control.Web.ProcessCreated += Web_ProcessCreated;
            currentSlideIndex = -1;
        }
 private void SB_Completed(object sender, object e)
 {
     ImageGrid.ClearImageFiles();
     foreach (var item in RandomResult)
     {
         ImageGrid.ShowImageFile(item);
     }
 }
    public MainWindow()
    {
        InitializeComponent();
        ImageGrid ig = new ImageGrid();

        Grid.Children.Add(ig);
        ig.Loaded += ImageGrid_Loaded;
    }
Ejemplo n.º 10
0
        /// <summary>
        /// Processes the input equirectangular image.
        /// </summary>
        /// <param name="inputImage">
        /// Input image path.
        /// </param>
        /// <param name="outputDir">
        /// Output directory where pyramid is generated.
        /// </param>
        /// <param name="projection">
        /// Projection type.
        /// </param>
        private static void ProcessEquirectangularImage(string inputImage, string outputDir, ProjectionTypes projection)
        {
            Trace.TraceInformation("{0}: Reading image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageFormat imageFormat = ImageFormat.Png;

            // Set the grid boundaries
            var imageBoundary = new Boundary(-180, -90, 180, 90);

            // Build an image grid using the input image
            var imageGrid = new ImageGrid(inputImage, true);

            // Build the grid map for equirectangular projection using the image grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(imageGrid, imageBoundary);

            // Build the color map using equirectangular projection grid map
            var imageColorMap = new ImageColorMap(equirectangularGridMap);

            var maximumLevelsOfDetail = TileHelper.CalculateMaximumLevel(imageGrid.Height, imageGrid.Width, imageBoundary);

            // Define ITileCreator instance for creating image tiles.
            ITileCreator tileCreator = TileCreatorFactory.CreateImageTileCreator(imageColorMap, projection, outputDir);

            // Define plumbing for looping through all the tiles to be created for base image and pyramid.
            var tileGenerator = new TileGenerator(tileCreator);

            // Start building base image and the pyramid.
            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            tileGenerator.Generate(maximumLevelsOfDetail);

            string fileName = Path.GetFileNameWithoutExtension(inputImage);

            // Generate Plate file.
            Trace.TraceInformation("{0}: Building Plate file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer pyramid        = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            PlateFileGenerator  plateGenerator = new PlateFileGenerator(
                Path.Combine(outputDir, fileName + ".plate"),
                maximumLevelsOfDetail,
                ImageFormat.Png);

            plateGenerator.CreateFromImageTile(pyramid);

            // Generate Thumbnail Images.
            Trace.TraceInformation("{0}: Building Thumbnail image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");

            TileHelper.GenerateThumbnail(inputImage, 96, 45, thumbnailFile, ImageFormat.Jpeg);

            // Get the path of image tiles created and save it in WTML file.
            Trace.TraceInformation("{0}: Building WTML file..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string pyramidPath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());

            // Create and save WTML collection file.
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, pyramidPath, maximumLevelsOfDetail, projection);
            string         path           = Path.Combine(outputDir, fileName + ".wtml");

            wtmlCollection.Save(path);
            Trace.TraceInformation("{0}: Collection successfully generated.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
        }
Ejemplo n.º 11
0
        private void Grid_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MouseIsDown                   = true;
            MouseDownPosition             = e.GetPosition(ImageGrid);
            SelectionRectangle.Visibility = Visibility.Visible;
            ChangeSelectionRectangle(MouseDownPosition, MouseDownPosition);

            ImageGrid.CaptureMouse();
        }
Ejemplo n.º 12
0
    private void Fill_List(int Rows)
    {
        string Imagespath = HttpContext.Current.Server.MapPath("~/Images/");
        string SitePath   = HttpContext.Current.Server.MapPath("~");
        var    Files      = (from file in Directory.GetFiles(Imagespath) select new { image = file.Replace(SitePath, "~") }).Take(Rows);

        ImageGrid.DataSource = Files.ToList();
        ImageGrid.DataBind();
    }
Ejemplo n.º 13
0
        public void Generate()
        {
            string mosaicDir = @"D:\GitHub\TilingBot\TilingBot\working\mosaic";

            string[] files = EnumFiles(new string[] { @"D:\GitHub\TilingBot\TilingBot\working\experiment graveyard\mosaic" });
            //GenImages( mosaicDir, files );
            //return;

            // Load image info.
            mosaicDir = @"D:\GitHub\TilingBot\TilingBot\working\mosaic";
            var images = LoadImages(mosaicDir);
            //return;

            string sourceImage = @"D:\GitHub\TilingBot\TilingBot\working\tet_50.png";
            Bitmap source      = new Bitmap(sourceImage);

            List <string> inputImages = new List <string>();

            for (int x = 0; x < source.Width; x++)
            {
                for (int y = 0; y < source.Height; y++)
                {
                    Color     c       = source.GetPixel(x, y);
                    ImageInfo closest = FindClosest(c, images.Values);
                    closest.Used = true;
                    string fn = Path.GetFileName(closest.Path);
                    inputImages.Add(fn);
                    System.Diagnostics.Trace.WriteLine(fn + "\t" + c.GetBrightness() + "\t" + closest.AvgBrightness + "\t" + c.GetSaturation() + "\t" + closest.AvgSat);
                }
            }

            // Create output image.
            int numTiles = source.Width;
            //numTiles = 10;
            int gridSpace = 30;
            int tileSize  = 300;
            int size      = numTiles * tileSize + (numTiles + 1) * gridSpace;

            ImageGrid.Settings settings = new ImageGrid.Settings()
            {
                Directory   = mosaicDir,
                Rows        = numTiles,
                Columns     = numTiles,
                Width       = size,
                Height      = size,
                hGap        = gridSpace,
                vGap        = gridSpace,
                InputImages = inputImages.ToArray(),
                FileName    = "mosaic.png"
            };

            ImageGrid grid = new ImageGrid();

            grid.Generate(settings);
        }
Ejemplo n.º 14
0
        public bool Analyze(ImageGrid grid, int frameDelay)
        {
            var tiles         = _motionDetector.DetectChanges(grid);
            var relativeDelay = frameDelay - _timeOffset;

            if (tiles.IsDefaultOrEmpty)
            {
                // more data is needed
                return(false);
            }

            _timeOffset = frameDelay;

            foreach (var sequence in tiles.GroupBy(CreateGroupKey).Where(x => x.Key is not null))
            {
                var point1 = new Point(int.MaxValue, int.MaxValue);
                var point2 = new Point(int.MinValue, int.MinValue);

                foreach (var tile in sequence)
                {
                    var bounds = tile.OriginalBounds;

                    if (bounds.Left < point1.X)
                    {
                        point1.X = bounds.Left;
                    }

                    if (bounds.Top < point1.Y)
                    {
                        point1.Y = bounds.Top;
                    }

                    if (bounds.Right > point2.X)
                    {
                        point2.X = bounds.Right;
                    }

                    if (bounds.Bottom > point2.Y)
                    {
                        point2.Y = bounds.Bottom;
                    }
                }

                var rectangle = new Rectangle(
                    x: point1.X,
                    y: point1.Y,
                    width: point2.X - point1.X,
                    height: point2.Y - point1.Y);

                AddCandidate(sequence.Key !, relativeDelay, rectangle);
            }

            return(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Tworzy tablice z wartosciami liczbowymi i umieszcza ja w odpowiedniej stronie kontrolki TabControl
        /// </summary>
        /// <param name="array">Dwuwymiarowa tablica wartości z jakiej ma zostać utworzona tablica w Formie</param>
        /// <param name="pageToAttachTo">Strona w jakiej ma zostać umieszczona tablica</param>
        public void CreateImageGridDec(int[,] array, TabPage pageToAttachTo)
        {
            ImageGrid grid = new ImageGrid();

            pageToAttachTo.Controls.Add(grid);
            grid.FixedColumns = 1;
            grid.FixedRows    = 1;
            grid.BorderStyle  = BorderStyle.Fixed3D;
            grid.Dock         = DockStyle.Fill;
            grid.DataSource   = array;
        }
Ejemplo n.º 16
0
 private void ImageGrid_MouseDown(object sender, MouseButtonEventArgs e)
 {
     _mouseDown         = true;
     _mouseDownPosition = e.GetPosition(ImageGrid);
     ImageGrid.CaptureMouse();
     Console.WriteLine($"MouseDown Position: {_mouseDownPosition}");
     Canvas.SetLeft(CriteriaSelectionBox, _mouseDownPosition.X);
     Canvas.SetTop(CriteriaSelectionBox, _mouseDownPosition.Y);
     CriteriaSelectionBox.Width      = 0;
     CriteriaSelectionBox.Height     = 0;
     CriteriaSelectionBox.Visibility = Visibility.Visible;
 }
Ejemplo n.º 17
0
        public void ImageGridConstructorTest()
        {
            string    path       = Path.Combine(TestDataPath, "BlueMarble.png");
            bool      isCircular = false;
            ImageGrid target     = new ImageGrid(path, isCircular);

            Assert.AreEqual(5400, target.Width);
            Assert.AreEqual(2700, target.Height);
            Assert.AreEqual(-16644328.0, target.GetValue(0.5, 0.5));
            Assert.AreEqual(-16180676.0, target.GetValueAt(2400, 2000));
            Assert.AreEqual(2591, target.GetXIndex(0.48));
            Assert.AreEqual(971, target.GetYIndex(0.36));
        }
Ejemplo n.º 18
0
        public void ImageGridConstructorTest()
        {
            string path = Path.Combine(TestDataPath, "BlueMarble.png");
            bool isCircular = false;
            ImageGrid target = new ImageGrid(path, isCircular);

            Assert.AreEqual(5400, target.Width);
            Assert.AreEqual(2700, target.Height);
            Assert.AreEqual(-16644328.0, target.GetValue(0.5, 0.5));
            Assert.AreEqual(-16180676.0, target.GetValueAt(2400, 2000));
            Assert.AreEqual(2591, target.GetXIndex(0.48));
            Assert.AreEqual(971, target.GetYIndex(0.36));
        }
Ejemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CloudStorageAccount sa     = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("SACS"));
            CloudBlobClient     client = sa.CreateCloudBlobClient();

            container = client.GetContainerReference("photobucket");
            container.CreateIfNotExists();
            container.SetPermissions(new BlobContainerPermissions {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });
            ImageGrid.DataSource = container.ListBlobs();
            ImageGrid.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CloudStorageAccount sa     = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue("mycon"));
            CloudBlobClient     client = sa.CreateCloudBlobClient();

            container = client.GetContainerReference("photobucket");
            container.CreateIfNotExists();
            container.SetPermissions(new BlobContainerPermissions {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });
            ImageGrid.DataSource = container.ListBlobs();
            ImageGrid.DataBind();
        }
Ejemplo n.º 21
0
        private static void CorrectFishEye(ImageGrid grid, float correctionRadius, RgbColor[] buffer)
        {
            // calculate the coordinates of the center of the image
            var centerX = grid.Width / 2;
            var centerY = grid.Height / 2;

            // iterate through all horizontal lines
            for (var y = 0; y < grid.Height; y++)
            {
                // calculate the y-coordinate currently processing and precompute the squared value
                // of the current center y-coordinate being processed
                var currentY        = y - centerY;
                var currentYSquared = MathF.Pow(currentY, 2);

                // iterate through all vertical lines in the current horizontal scan line
                for (var x = 0; x < grid.Width; x++)
                {
                    // calculate the x-coordinate currently processing and compute the squared value
                    // of the current center x-coordinate being processed
                    var currentX        = x - centerX;
                    var currentXSquared = MathF.Pow(currentX, 2);

                    // compute the distance between the original center and the current point
                    var distance = MathF.Sqrt(currentXSquared + currentYSquared);

                    // compute the current correction radius to perform correction with
                    var radius = distance / correctionRadius;

                    // the theta used as a factor to correct the fish-eye distortion, pre-initialize
                    // with 1F to avoid division through zero errors
                    var theta = 1F;

                    // check if the radius is not zero, to avoid division through zero errors
                    if (radius is not 0.0F)
                    {
                        // compute the theta
                        theta = MathF.Atan(radius) / radius;
                    }

                    // calculate the coordinates of the pixel to retrieve the value from
                    var sourceX = (int)MathF.Floor(centerX + (theta * currentX));
                    var sourceY = (int)MathF.Floor(centerY + (theta * currentY));

                    // retrieve the value of the source pixel
                    var value = grid.GetPixel(sourceX, sourceY);

                    // set the current target pixel to the corrected pixel
                    buffer[x + (y * grid.Width)] = value;
                }
            }
        }
Ejemplo n.º 22
0
        private void CreateBindings()
        {
            Image.SetBinding(Image.SourceProperty, new Binding("Image")
            {
                Source = (BaseModel)CenteredImageModel ?? Model,
                Mode   = BindingMode.OneWay
            });
            Image.SetBinding(MarginProperty, new Binding("FormattedMargin")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });

            ImageGrid.SetBinding(HeightProperty, new Binding("Height")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
            ImageGrid.SetBinding(WidthProperty, new Binding("Width")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
            ImageGrid.SetBinding(VisibilityProperty, new Binding("Visibility")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
            ImageGrid.SetBinding(RenderTransformProperty, new Binding("Translate")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
            ImageGrid.SetBinding(CursorProperty, new Binding("Cursor")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });

            TooltipControl.SetBinding(ContentProperty, new Binding("Tooltip")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
            TooltipControl.SetBinding(VisibilityProperty, new Binding("TooltipVisibility")
            {
                Source = Model,
                Mode   = BindingMode.OneWay
            });
        }
Ejemplo n.º 23
0
        public BenchmarkView()
        {
            InitializeComponent();

            Padding = new Padding(5);

            _imageGrid = new ImageGrid()
            {
                Dock = DockStyle.Fill, Padding = new Padding(20)
            };

            panelGridContainer.Controls.Add(_imageGrid);

            InitializeView();
        }
        private void ToggleDebug()
        {
            ViewDebug = !ViewDebug;
            if (ViewDebug)
            {
                DebugGrid.Visibility = Visibility.Visible;

                WatchoutDebug.Text = App.WatchoutIP + ":" + App.WatchoutPort + "\n";
            }
            else
            {
                DebugGrid.Visibility = Visibility.Collapsed;
            }
            ImageGrid.ShowFrames(ViewDebug);
        }
Ejemplo n.º 25
0
        public static void Output(BackgroundWorker sender, ImageGrid g, string id_, string path)
        {
            ImageTile it   = imageTiles[id_];
            DateTime  time = DateTime.Now;

            MainWindow.Log("Saving Image (" + it.worldX + " " + it.worldY + ")");

            time = DateTime.Now;

            {
                for (int i = 0; i < MainWindow.classesList.Count; i += 4)
                {
                    Classes c0 = MainWindow.classesList[i];
                    Classes c1 = i + 1 < MainWindow.classesList.Count ? MainWindow.classesList[i + 1] : null;
                    Classes c2 = i + 2 < MainWindow.classesList.Count ? MainWindow.classesList[i + 2] : null;
                    Classes c3 = i + 3 < MainWindow.classesList.Count ? MainWindow.classesList[i + 3] : null;

                    string classesNames = c0.className.Replace(' ', '_');
                    classesNames += c1 != null?c1.className.Replace(' ', '_') : "";

                    classesNames += c2 != null?c2.className.Replace(' ', '_') : "";

                    classesNames += c3 != null?c3.className.Replace(' ', '_') : "";

                    string filename = path + "\\" + (it.worldY) + "_" + (it.worldX) + "_" + classesNames + ".png";

                    MainWindow.dispatcher.Invoke(() =>
                    {
                        ImageHelper.ExportClassification(it.id, c0, c1, c2, c3, filename, ref Stitch, i / 4, ref StichLock);
                    });
                }
            }


            MainWindow.dispatcher.Invoke(() =>
                                         g.RemoveTile(it.tileX, it.tileY)
                                         );

            float t = (float)(DateTime.Now - time).TotalSeconds;

            averageOutputTime = (averageOutputTime * outputDone + t) / (outputDone + 1);
            outputDone++;
            ReportProgress(sender);

            MainWindow.Log("Image (" + it.worldX + " " + it.worldY + ") saved in " + t + "s. Done");

            GC.Collect();
        }
Ejemplo n.º 26
0
        }//Compare

        /// <summary>
        /// Creates a dummy threshold image, used for testing and benchmarking
        /// </summary>
        public void CreateDummyThreshold(int width, int height)
        {
            ThresholdImage = new ImageGrid(width, height);
            for (int i = 0; i < width; i++)
            {
                ThresholdImage.Columns.Add(new GridColumn());

                for (int n = 0; n < height; n++)
                {
                    Random random = new Random();
                    double buffer = ReturnBuffer(random.Next(25000000));
                    ThresholdImage.Columns[i].grids.Add(new Grid());
                    ThresholdImage.Columns[i].grids[n].threshold = Math.Round(buffer, 0);
                }
            }
        }
Ejemplo n.º 27
0
        public Triangle GetTriangle(string row, string col)
        {
            Triangle triangle = null;

            try
            {
                var imageGrid = new ImageGrid();
                triangle = imageGrid.GetTriangleByRowAndColumn(row, col);
            }
            catch (ArgumentException argEx) //also covers ArgumentOutOfRangeException as descendant
            {
                HandleArgumentErrors($"row {row}, col {col}", argEx);
            }

            return(triangle);
        }
Ejemplo n.º 28
0
        public void SetImage(ImageGrid grid)
        {
            var img = grid.GetSelectImage();

            if (img.Image != null)
            {
                selectedPicturePreviewBox.Image = grid.GetBitmapImage();
                CurrentImage      = grid.GetSelectImage();
                CurrentImageIndex = grid.SelectedIndex;
            }
            else
            {
                selectedPicturePreviewBox.Image = null;
                CurrentImage      = null;
                CurrentImageIndex = 0;
            }
        }
Ejemplo n.º 29
0
 private void ImageGrid_MouseUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         _mouseDown = false;
         ImageGrid.ReleaseMouseCapture();
         _mouseUpPosition = e.GetPosition(PreviewImage);
         ((CriteriaCreatorViewModel)DataContext).PreviewImageWidth  = PreviewImage.ActualWidth;
         ((CriteriaCreatorViewModel)DataContext).PreviewImageHeight = PreviewImage.ActualHeight;
         ((CriteriaCreatorViewModel)DataContext).InitialPosition    = _mouseDownPosition;
         ((CriteriaCreatorViewModel)DataContext).ReleasePosition    = _mouseUpPosition;
         ((CriteriaCreatorViewModel)DataContext).SelectionSize      = new System.Drawing.Size(Convert.ToInt32(CriteriaSelectionBox.Width), Convert.ToInt32(CriteriaSelectionBox.Height));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message.Trim());
     }
 }
Ejemplo n.º 30
0
        private static bool canOutput(ImageGrid g, ImageTile it)
        {
            if (!postProcessed[it.tileX, it.tileY])
            {
                return(false);
            }

            for (int x = Math.Max(0, it.tileX - 1); x <= Math.Min(g.width - 1, it.tileX + 1); x++)
            {
                for (int y = Math.Max(0, it.tileY - 1); y <= Math.Min(g.height - 1, it.tileY + 1); y++)
                {
                    if (!postProcessed[x, y])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 31
0
        public TerrainAssembler()
        {
            InitializeComponent();

            // Initialize the grid control
            imageGrid = new ImageGrid();
            mainSplitContainer.Panel1.Controls.Add(imageGrid);
            imageGrid.Name                 = "imageGrid";
            imageGrid.Location             = new System.Drawing.Point(0, 0);
            imageGrid.TabIndex             = 0;
            imageGrid.Dock                 = DockStyle.Fill;
            imageGrid.Enabled              = false;
            imageGrid.VisibleCellsChange  += new VisibleCellsChangeEvent(VisibleCellsChangeHandler);
            imageGrid.UserSelectionChange += new UserSelectionChangeEvent(UserSelectionChangeHandler);

            //imageGrid.WidthCells = 50;
            //imageGrid.HeightCells = 30;

            imageGrid.LabelCells           = showLabelsToolStripMenuItem.Checked;
            imageGrid.SelectionBorderColor = Color.Red;

            //for (int i = 0; i < 10; i++)
            //{
            //    ImageGridCell cell = imageGrid.CreateCell(i, 5);
            //    cell.Color = Color.Red;
            //    cell.Label = String.Format("color{0}", i);
            //}

            //for (int y = 0; y < 10; y++)
            //{
            //    for (int x = 0; x < 8; x++)
            //    {
            //        ImageGridCell cell = imageGrid.CreateCell(5 + x, 10 + y);
            //        Bitmap tmpBitmap = new Bitmap(String.Format("minimap\\minimap_x{0}y{1}.png", x, 9 - y));
            //        cell.Image = new Bitmap(tmpBitmap, new Size(64, 64));
            //        cell.Label = String.Format("map({0}, {1})", x, y);
            //        cell.ToolTipText = String.Format("Zone: Island\nGrid Coordinate: {0}, {1}", x, y);
            //    }
            //}
        }