Exemplo n.º 1
0
        private void Initfile(string filePath)
        {
            textBox1.Text = filePath;

            if (tiler != null)
            {
                tiler.SendFeedback -= new EventHandler <SendFeedbackEventArgs>(tiler_SendFeedback);
                tiler.Completed    -= new EventHandler <CompletedEventArgs>(tiler_Completed);
                tiler.Dispose();
                tiler = null;
            }

            tiler = new Tiler(textBox1.Text);
            tiler.SendFeedback += new EventHandler <SendFeedbackEventArgs>(tiler_SendFeedback);
            tiler.Completed    += new EventHandler <CompletedEventArgs>(tiler_Completed);

            label5.Text = string.Format("{0}x{1}", tiler.SourceImage.Width, tiler.SourceImage.Height);

            var tileImg = new Bitmap(256, 256);

            using (var graphcis = Graphics.FromImage(tileImg))
            {
                int width, height;
                if (tiler.SourceImage.Width > tiler.SourceImage.Height)
                {
                    width  = 256;
                    height = 256 * tiler.SourceImage.Height / tiler.SourceImage.Width;
                }
                else
                {
                    height = 256;
                    width  = 256 * tiler.SourceImage.Width / tiler.SourceImage.Height;
                }

                graphcis.FillRectangle(new SolidBrush(colorPanel.BackColor), 0, 0, 256, 256);
                graphcis.DrawImage(tiler.SourceImage, new Rectangle(0, 0, width, height),
                                   new Rectangle(0, 0, tiler.SourceImage.Width, tiler.SourceImage.Height),
                                   GraphicsUnit.Pixel);
            }

            pictureBox2.Image = tileImg;

            numericUpDown1.Value = tiler.OrgLevel;
            numericUpDown2.Value = tiler.MinLevel;
            numericUpDown3.Value = tiler.MaxLevel;
        }
Exemplo n.º 2
0
        private void Initfile(string filePath)
        {
            textBox1.Text = filePath;

            if (tiler != null)
            {
                tiler.SendFeedback -= new EventHandler<SendFeedbackEventArgs>(tiler_SendFeedback);
                tiler.Completed -= new EventHandler<CompletedEventArgs>(tiler_Completed);
                tiler.Dispose();
                tiler = null;
            }

            tiler = new Tiler(textBox1.Text);
            tiler.SendFeedback += new EventHandler<SendFeedbackEventArgs>(tiler_SendFeedback);
            tiler.Completed += new EventHandler<CompletedEventArgs>(tiler_Completed);

            label5.Text = string.Format("{0}x{1}", tiler.SourceImage.Width, tiler.SourceImage.Height);

            var tileImg = new Bitmap(256, 256);
            using (var graphcis = Graphics.FromImage(tileImg))
            {
                int width, height;
                if (tiler.SourceImage.Width > tiler.SourceImage.Height)
                {
                    width = 256;
                    height = 256 * tiler.SourceImage.Height / tiler.SourceImage.Width;
                }
                else
                {
                    height = 256;
                    width = 256 * tiler.SourceImage.Width / tiler.SourceImage.Height;
                }

                graphcis.FillRectangle(new SolidBrush(colorPanel.BackColor), 0, 0, 256, 256);
                graphcis.DrawImage(tiler.SourceImage, new Rectangle(0, 0, width, height),
                    new Rectangle(0, 0, tiler.SourceImage.Width, tiler.SourceImage.Height),
                    GraphicsUnit.Pixel);

            }

            pictureBox2.Image = tileImg;

            numericUpDown1.Value = tiler.OrgLevel;
            numericUpDown2.Value = tiler.MinLevel;
            numericUpDown3.Value = tiler.MaxLevel;
        }