C#图像保存点

时间:2013-05-18 00:03:35

标签: c# image image-processing filestream exif

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

结果可以在这里看到 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;
    }

1 个答案:

答案 0 :(得分:0)

如果imageBitmap课程,您可能需要将EncoderParameters传递给Save方法

image.Save(Path, jgpEncoder, myEncoderParameters);