GetBitmap() public method

public GetBitmap ( ) : Bitmap
return System.Drawing.Bitmap
Exemplo n.º 1
0
        private void ParseAllMaps(string folder)
        {
            DirectoryInfo info = new DirectoryInfo(folder);

            FileInfo[] blocks = info.GetFiles("*.shbd", SearchOption.AllDirectories);
            SetLabel("Done: 0/" + blocks.Length);
            busy = true;
            DateTime start = DateTime.Now;

            for (int i = 0; i < blocks.Length; i++)
            {
                try
                {
                    MapRender render = new MapRender(blocks[i].FullName);
                    Bitmap    lulz   = render.GetBitmap();
                    using (FileStream stream = File.Create(Path.GetFileNameWithoutExtension(blocks[i].FullName) + ".png"))
                    {
                        lulz.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("could not parse " + Path.GetFileNameWithoutExtension(blocks[i].FullName) + ": " + ex.Message);
                }
                SetLabel("Done: " + i + "/" + blocks.Length);
            }
            TimeSpan totaltime = DateTime.Now - start;

            SetLabel("Finished in " + Math.Round(totaltime.TotalSeconds, 1) + " seconds.");
            busy = false;
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (busy)
            {
                MessageBox.Show("Already converting, please wait.");
                return;
            }
            OpenFileDialog diag = new OpenFileDialog();

            diag.Filter = "SHBD File (*.shbd)|*.shbd";
            if (diag.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            MapRender render = new MapRender(diag.FileName);
            Bitmap    lulz   = render.GetBitmap();

            using (FileStream stream = File.Create(Path.GetFileNameWithoutExtension(diag.FileName) + ".png"))
            {
                lulz.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            }
            MessageBox.Show("Done!");
        }