Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将已安装的图像颜色配置文件(.icm)添加到C语言中的图像中#_C#_Image_Colors - Fatal编程技术网

C# 将已安装的图像颜色配置文件(.icm)添加到C语言中的图像中#

C# 将已安装的图像颜色配置文件(.icm)添加到C语言中的图像中#,c#,image,colors,C#,Image,Colors,在我的一个C#项目(.net framework 4.0)中,如果windows中已经没有颜色配置文件,我需要将已安装的颜色配置文件添加到图像中。 我在谷歌上搜索,在.net中找不到用于颜色配置文件管理的内容,因此我采用imagemagick库并使用其“addprofile”方法,但在添加并保存图像后,每当我准备好图像时,它都不包含颜色配置文件。在互联网上搜索时,我发现在应用自定义颜色配置文件之前应用了colorprofile.sRGB,我也这样做,当我阅读图像时,图像中包含颜色配置文件“icc

在我的一个C#项目(.net framework 4.0)中,如果windows中已经没有颜色配置文件,我需要将已安装的颜色配置文件添加到图像中。 我在谷歌上搜索,在.net中找不到用于颜色配置文件管理的内容,因此我采用imagemagick库并使用其“addprofile”方法,但在添加并保存图像后,每当我准备好图像时,它都不包含颜色配置文件。在互联网上搜索时,我发现在应用自定义颜色配置文件之前应用了colorprofile.sRGB,我也这样做,当我阅读图像时,图像中包含颜色配置文件“icc”。下面是颜色配置文件添加代码

using (MagickImage image = new MagickImage(outputFilePath))
            {
                ImageMagick.ColorProfile colorProfile = image.GetColorProfile();
                if (colorProfile == null)
                {
                    //Add sRGB color profile before adding your custom color profile
                    image.AddProfile(ImageMagick.ColorProfile.SRGB);
                    //ICSPrfile is the object containing the name and path of availabe prfiles
                    //_profilesRGB is the list containing the ICSProfiles
                    foreach (ICSProfile prof in _profilesRGB)
                        if (prof.Name.Equals(comboBoxRGBProfile.SelectedItem))
                            image.AddProfile(new ImageMagick.ImageProfile(prof.Name, File.ReadAllBytes(prof.FilePath)));

                    //Write update profile file
                    image.Write(outputFilePath);
                }//End if
            }//End using

现在,我不确定,在写了这段代码之后,我的图像是否包含自定义颜色配置文件。我写的代码正确吗?以及如何检查图像中的颜色配置文件

输出图像的类型是什么?它应该与输入图像相同。并非所有格式都支持颜色配置文件。您使用的是什么格式?我打算将颜色配置文件应用于支持它的图像。出于测试目的,我正在使用jpg和PNG,您介意在这里也开始一个主题吗?在那里交流比较容易。