예제 #1
0
        public static Boolean upload(Bitmap bmp)
        {
            try
            {
                var data = new NameValueCollection();

                var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
                data.Add("image", image);

                web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
                web_client.UploadValuesAsync(
                    new Uri("https://api.imgur.com/3/image/"),
                    "POST",
                    data
                    );

                web_client.Headers.Remove("Authorization");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        void save_screenshot(Bitmap bmp, String name = null)
        {
            if (!Settings.save_screenshots)
            {
                return;
            }

            if (name == null)
            {
                name = DateTime.Now.ToString("yyyy-MM-dd_HHmmss");
            }

            try
            {
                bmp.Save(
                    String.Format("{0}/{1}.{2}", Settings.save_folder, name, Settings.save_format),
                    Global_Func.ext_to_imageformat(Settings.save_format)
                    );
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot save image.");
                Console.WriteLine(ex.Message);
            }
        }
예제 #3
0
        void SaveAsToolStripMenuItemClick(object sender, System.EventArgs e)
        {
            var dialog = new SaveFileDialog();

            dialog.FileName = DateTime.Now.ToString("yyyy-MM-dd_HHmmss");
            dialog.Filter   = "PNG|*.png|JPG|*.jpg|BMP|*.bmp|All Files (*.*)|*.*";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                picture_box.Image.Save(
                    dialog.FileName,
                    Global_Func.ext_to_imageformat(Path.GetExtension(dialog.FileName).Substring(1))
                    );
            }
        }