GDI+ エラーに関する多くのスレッドが表示されます。一部は Web 画像用で、他のフォーム画像編集用です...スクリーンショットで見つかったのは 1 つだけです: GDI+ の一般的なエラーはスクリーン キャプチャ で発生し、解決策はありません。私はこのガイドに従っています
私の「唯一のスクリーンショットプログラム」はこれです:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
private static Bitmap bmpScreenshot;
private static Graphics gfxScreenshot;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
bmpScreenshot.Save("c:\\test.png", ImageFormat.Png);
this.Show();
}
}
}
しかし、GDI+ で一般的なエラーが発生します。非表示にし、画面を取得し、保存して再表示する必要があります。代わりに、ブロックしてそのエラーを行に表示します。
bmpScreenshot.Save("c:\\test.png", ImageFormat.Png);
読んでくれてありがとう、もし私が新しい文法を「発明」したならごめんなさい、私は英語じゃない!