c#图像保存点

本文关键字:保存 图像 | 更新日期: 2023-09-27 18:14:06

我不知道我做错了,我一直在网上寻找,并尝试了很多不同的东西,但没有工作,当我试图保存图像有很多灰色点

结果可以在这里看到
http://postimg.org/image/btvob8f6l/

    public static void ExifSave(List<InfoList> data)
    {
        ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
        EncoderParameters myEncoderParameters = new EncoderParameters(1);
        EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L);
        myEncoderParameter = new EncoderParameter(myEncoder, 100L);
        myEncoderParameters.Param[0] = myEncoderParameter;
        list = data;
        foreach (InfoList i in data)
        {
            SetProperty(ref prop, i.id, i.value);
            image.SetPropertyItem(prop);
        }
        fs.Dispose();
        try
        {
            image.Save(Path);
        }
        catch (Exception e)
        {
            new MessagePromt("DEBUG::LoadImages()::Error attempting to create image::" + e.Message, e.Message);
        }
    }
    private static ImageCodecInfo GetEncoder(ImageFormat format)
    {
        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
        foreach (ImageCodecInfo codec in codecs)
        {
            if (codec.FormatID == format.Guid)
            {
                return codec;
            }
        }
        return null;
    }

c#图像保存点

如果imageBitmap类,则可能需要将EncoderParameters传递到Save方法

image.Save(Path, jgpEncoder, myEncoderParameters);