private void Window_Loaded(object sender, RoutedEventArgs e) { DpiScale = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.M11; labelHeader.Visibility = Visibility.Visible; borderCapture.Visibility = Visibility.Visible; this.Width = SystemParameters.VirtualScreenWidth; this.Height = SystemParameters.VirtualScreenHeight; this.Left = SystemParameters.VirtualScreenLeft; this.Top = SystemParameters.VirtualScreenTop; if (captureMode == Models.CaptureMode.PNG) { using (var ms = new MemoryStream()) { BackgroundImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png); var bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = ms; bi.CacheOption = BitmapCacheOption.OnLoad; bi.EndInit(); bi.Freeze(); gridMain.Background = new ImageBrush(bi); } } FrameWindowUnderCursor(); this.Activate(); }
private void 保存toolStripMenuItem_Click(object sender, EventArgs e) { var saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "jpg图片(*.jpg)|*.jpg|png图片(*.png)|*.jpg|bmp图片(*.bmp)|*.bmp"; saveFileDialog.AddExtension = false; saveFileDialog.FileName = string.Concat("tianruo_", DateTime.Now.Year.ToString(), "-", DateTime.Now.Month.ToString(), "-", DateTime.Now.Day.ToString(), "-", DateTime.Now.Ticks.ToString()); saveFileDialog.Title = "保存图片"; saveFileDialog.FilterIndex = 1; saveFileDialog.RestoreDirectory = true; var flag = saveFileDialog.ShowDialog() == DialogResult.OK; if (flag) { var extension = Path.GetExtension(saveFileDialog.FileName); var flag2 = extension.Equals(".jpg"); if (flag2) { BackgroundImage.Save(saveFileDialog.FileName, ImageFormat.Jpeg); } var flag3 = extension.Equals(".png"); if (flag3) { BackgroundImage.Save(saveFileDialog.FileName, ImageFormat.Png); } var flag4 = extension.Equals(".bmp"); if (flag4) { BackgroundImage.Save(saveFileDialog.FileName, ImageFormat.Bmp); } } }
private void button1_Click(object sender, EventArgs e) { //Dialog kutusu gösterilir ve nereye kayıt edileceğini sorar. saveFileDialog2.ShowDialog(); BackgroundImage.Save(saveFileDialog2.FileName + ".png", ImageFormat.Jpeg); MessageBox.Show("Ekran görüntüsü başarı ile kayıt edildi.\nResim yolu:\n" + saveFileDialog2.FileName + ".png", "Başarı ile Kayıt Edildi!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void MainForm_Load(object sender, EventArgs e) { BackgroundImage = DecalGenerator.Create(10); // Save this wherever you want! // Use it to create more decals! BackgroundImage.Save("Decal_Number10.png"); }
private void MainForm_Load(object sender, EventArgs e) { using (var generator = new Generator()) { BackgroundImage = generator.GenerateRuneCircle(); } BackgroundImage.Save(@"C:\Temp\Ring.png"); }
private Image CopyBackgroundImage() { using (var ms = new MemoryStream()) { BackgroundImage.Save(ms, BackgroundImage.RawFormat); var data = ms.ToArray(); return(ImageUtil.FromByteArray(data)); } }
private void tsmI_Save_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog { Filter = "JPEG (*.jpg,*.jpeg) | *.jpg;*.jpeg", //设置文件类型 FileName = Guid.NewGuid().ToString(), //设置默认文件名 AddExtension = true //设置自动在文件名中添加扩展名 }; if (sfd.ShowDialog() == DialogResult.OK) { BackgroundImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); MessageBox.Show("保存成功"); } }
private void SavesTo(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = ".PNG"; sfd.ShowDialog(); String URL = sfd.FileName; if (URL == "") { return; } BackgroundImage.Save(URL); if (MessageBox.Show("保存成功 是否打开文件夹?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(ih.GetFullName(URL)); } }
private void buttonSave_Click(object sender, EventArgs e) { if (BackgroundImage == null) { MessageBox.Show("Image not generated.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = "Bitmap Format|*.bmp"; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); if (dialog.ShowDialog() == DialogResult.OK) { BackgroundImage.Save(dialog.FileName); } } }
private void saveButton_Click(object sender, EventArgs e) { using (var sfd = new SaveFileDialog { Filter = "JPG File (*.jpg)|*.jpg", DefaultExt = "jpg" }) { if (sfd.ShowDialog() == DialogResult.OK) { try { BackgroundImage.Save(sfd.FileName, ImageFormat.Jpeg); } catch (Exception ex) { MessageService.ShowWarning(ex); } } } }
public void GetBackground() { System.Drawing.Bitmap flag = new System.Drawing.Bitmap(this.Width, this.Height); //string start = DateTime.Now.ToString(); for (int x = 1; x < flag.Width; ++x) { for (int y = 1; y < flag.Height; ++y) { //this.FindForm().PointToClient Point p = this.Parent.PointToScreen(this.Location); Color c = GetPixelColor(x + p.X, y + p.Y); flag.SetPixel(x, y, c); } } BackgroundImage = flag; // MessageBox.Show(start + " - " +DateTime.Now.ToString()); if (bCreateAndSave) { BackgroundImage.Save("C://" + this.Name + ".bmp"); } }
public void SavePicture() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Fichiers image (*.png)|*.png|Tous les fichiers (*.*)|*.*"; dialog.FileName = "SnaSharpSpectrum.png"; if (dialog.ShowDialog() == DialogResult.OK) { /* * PictureBoxBitmap.Dispose(); * PictureBoxBitmap = new Bitmap(2000,2000); * DrawCurveCollection(CurvesList); * PictureBoxBitmap.Save(dialog.FileName, ImageFormat.Png); * PictureBoxBitmap.Dispose(); * PictureBoxBitmap = new Bitmap(Size.Width, Size.Height); * Image = PictureBoxBitmap; */ BackgroundImage.Save(dialog.FileName, ImageFormat.Png); } }