小编Mai*_*non的帖子

值不能为空。参数名称:编码器

我需要截取屏幕的一部分并检查屏幕截图是否与pictureBox2.

这是行不通的:

pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
Run Code Online (Sandbox Code Playgroud)

错误是

值不能为空。
参数名称:编码器

在此处输入图片说明

我的代码如下所示:

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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Bitmap screenshot = new Bitmap(SystemInformation.VirtualScreen.Width,
            SystemInformation.VirtualScreen.Height,
            PixelFormat.Format32bppArgb);
        public Form1()
        {
            InitializeComponent();

        }



        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Bitmap screenshot = new Bitmap(SystemInformation.VirtualScreen.Width,
                SystemInformation.VirtualScreen.Height,
                PixelFormat.Format32bppArgb);
            Graphics screenGraph = Graphics.FromImage(screenshot);
            screenGraph.CopyFromScreen(
                SystemInformation.VirtualScreen.X …
Run Code Online (Sandbox Code Playgroud)

c# memorystream save-image

1
推荐指数
1
解决办法
6471
查看次数

标签 统计

c# ×1

memorystream ×1

save-image ×1