예제 #1
0
        void OnSaveDialogFormClosed(object sender, FormClosedEventArgs e)
        {
            RoiTool roiPlugin = this.Window.GetTool("Region") as RoiTool;

            this.Window.TileView.AllowMouseWheelZoom = true;
            roiPlugin.DisableUserInteraction         = false;
            this.Window.EnableNonPluginToolStrip     = true;
        }
예제 #2
0
        public SaveDialog(MosaicInfo mosaicInfo, RoiTool tool)
        {
            InitializeComponent();

            this.tool = tool;

            this.imageRegion = Rectangle.Empty;

            if (tool.Active == true)
            {
                this.imageRegion = tool.TransformedRegionOfInterest;
            }

            tool.RoiToolDrawnHandler       += new RoiToolHandler <RoiTool, RoiToolEventArgs>(OnRoiToolDrawnHandler);
            tool.PluginActiveStatusChanged +=
                new MosaicPluginEventHandler <MosaicPlugin, EventArgs>(OnRoiPluginActiveStatusChanged);

            this.widthNumeric.Minimum  = 100;
            this.widthNumeric.Maximum  = 1000000;
            this.heightNumeric.Minimum = 100;
            this.heightNumeric.Maximum = 1000000;

            if (MosaicWindow.MosaicInfo.TotalWidth > SaveDialog.MaxPossibleWidth)
            {
                this.MaxWidth = MaxPossibleWidth;
            }
            else
            {
                this.MaxWidth = MosaicWindow.MosaicInfo.TotalWidth;
            }

            if (MosaicWindow.MosaicInfo.TotalHeight > SaveDialog.MaxPossibleWidth)
            {
                this.MaxHeight = MaxPossibleHeight;
            }
            else
            {
                this.MaxHeight = MosaicWindow.MosaicInfo.TotalHeight;
            }

            CalculateAspectRatio();

            this.filePathCombo.Items.Add(MosaicWindow.MosaicInfo.DirectoryPath);
            this.filePathCombo.Text = MosaicWindow.MosaicInfo.DirectoryPath;

            this.OnExportSizeNumericValidating(this.widthNumeric, new CancelEventArgs());

            this.widthNumeric.ValueChanged  += new EventHandler(this.OnNumericValueChanged);
            this.heightNumeric.ValueChanged += new EventHandler(this.OnNumericValueChanged);
        }
예제 #3
0
        // Save mosaic data.
        internal void Export()
        {
            if (MosaicWindow.MosaicInfo == null)
            {
                return;
            }

            RoiTool roiPlugin = this.Window.GetTool("Region") as RoiTool;

            this.saveDialog = new SaveDialog(MosaicWindow.MosaicInfo, roiPlugin);
            this.saveDialog.SaveButtonClicked += new EventHandler(this.OnSaveDialogSaveButtonClicked);
            this.saveDialog.FormClosed        += new FormClosedEventHandler(OnSaveDialogFormClosed);
            this.saveDialog.Show();

            this.Window.TileView.AllowMouseWheelZoom = false;
            roiPlugin.DisableUserInteraction         = true;
            this.Window.EnableNonPluginToolStrip     = false;
        }
예제 #4
0
        public SaveDialog(MosaicInfo mosaicInfo, RoiTool tool)
        {
            InitializeComponent();

            this.tool = tool;

            this.imageRegion = Rectangle.Empty;

            if (tool.Active == true)
                this.imageRegion = tool.TransformedRegionOfInterest;

            tool.RoiToolDrawnHandler += new RoiToolHandler<RoiTool, RoiToolEventArgs>(OnRoiToolDrawnHandler);
            tool.PluginActiveStatusChanged +=
                new MosaicPluginEventHandler<MosaicPlugin, EventArgs>(OnRoiPluginActiveStatusChanged);

            this.widthNumeric.Minimum = 100;
            this.widthNumeric.Maximum = 1000000;
            this.heightNumeric.Minimum = 100;
            this.heightNumeric.Maximum = 1000000;

            if (MosaicWindow.MosaicInfo.TotalWidth > SaveDialog.MaxPossibleWidth)
                this.MaxWidth = MaxPossibleWidth;
            else
                this.MaxWidth = MosaicWindow.MosaicInfo.TotalWidth;

            if (MosaicWindow.MosaicInfo.TotalHeight > SaveDialog.MaxPossibleWidth)
                this.MaxHeight = MaxPossibleHeight;
            else
                this.MaxHeight = MosaicWindow.MosaicInfo.TotalHeight;

            CalculateAspectRatio();

            this.filePathCombo.Items.Add(MosaicWindow.MosaicInfo.DirectoryPath);
            this.filePathCombo.Text = MosaicWindow.MosaicInfo.DirectoryPath;

            this.OnExportSizeNumericValidating(this.widthNumeric, new CancelEventArgs());

            this.widthNumeric.ValueChanged += new EventHandler(this.OnNumericValueChanged);
            this.heightNumeric.ValueChanged += new EventHandler(this.OnNumericValueChanged);
        }
예제 #5
0
 void OnRoiToolDrawnHandler(RoiTool sender, RoiToolEventArgs args)
 {
     CalculateAspectRatio();
 }
예제 #6
0
        private FreeImageAlgorithmsBitmap Stitch(int stitchWidth, int stitchHeight)
        {
            float zoom   = 1.0f;
            Point origin = new Point(0, 0);

            List <Tile> tiles = null;

            RoiTool roiPlugin = this.Window.GetTool("Region") as RoiTool;

            Rectangle roi = Rectangle.Empty;

            if (roiPlugin.Active == true)
            {
                roi = roiPlugin.TransformedRegionOfInterest;
            }

            if (roi != null && roi != Rectangle.Empty)
            {
                tiles = new List <Tile>();

                foreach (Tile tile in MosaicWindow.MosaicInfo.Items)
                {
                    if (roi.IntersectsWith(tile.Bounds))
                    {
                        tiles.Add(tile);
                    }
                }

                zoom   = (float)stitchWidth / (float)(roi.Width);
                origin = roi.Location;
            }
            else
            {
                tiles = new List <Tile>(MosaicWindow.MosaicInfo.Items);
                zoom  = (float)stitchWidth / (float)(MosaicWindow.MosaicInfo.TotalWidth);
            }

            // origin = Tile.GetOriginOfTiles(tiles);

            //int width = Tile.GetHorizontalRangeOfTiles(tiles);
            //int height = Tile.GetVerticalRangeOfTiles(tiles);

            int width, height;

            if (roi == Rectangle.Empty)
            {
                // Whole mosaic Width / Height
                width  = MosaicWindow.MosaicInfo.TotalWidth;
                height = MosaicWindow.MosaicInfo.TotalHeight;
            }
            else
            {
                width  = roi.Width;
                height = roi.Height;
            }

            FreeImageAlgorithmsBitmap section = null;

            try
            {
                section = new FreeImageAlgorithmsBitmap((int)(width * zoom), (int)(height * zoom),
                                                        MosaicWindow.MosaicInfo.FreeImageType, MosaicWindow.MosaicInfo.ColorDepth);
            }
            catch (FreeImageException)
            {
                return(null);
            }

            FreeImageAlgorithmsBitmap tmpBitmap = null;

            int count = 1;

            foreach (Tile tile in tiles)
            {
                Point position = tile.GetTilePositionRelativeToPoint(origin);

                position.X = (int)(position.X * zoom);
                position.Y = (int)(position.Y * zoom);

                try
                {
                    tmpBitmap = tile.LoadFreeImageBitmap((int)(tile.Width * zoom), (int)(tile.Height * zoom));
                }
                catch (FreeImageException e)
                {
                    MessageBox.Show(e.Message);
                }

                section.PasteFromTopLeft(tmpBitmap, position, this.Window.BlendingEnabled);

                tmpBitmap.Dispose();

                this.threadController.ReportThreadPercentage(this, "Saving Tiles",
                                                             count, tiles.Count);

                count++;
            }

            return(section);
        }
예제 #7
0
 void OnRoiToolDrawnHandler(RoiTool sender, RoiToolEventArgs args)
 {
     CalculateAspectRatio();
 }