AddIccProfile(Byte[]) Метод (JpegVirtualMetadata)
В этом разделе
Добавляет профиль ICC к метаданным JPEG.
Синтаксис
'Declaration
Public Overrides Sub AddIccProfile( _
ByVal () As Byte _
)
public override void AddIccProfile(
byte[]
)
public: void AddIccProfile(
byte[]*
); override
public:
void AddIccProfile(
array<byte>^
); override
Parameters
- iccProfileData
- Данные профиля ICC.
Пример
Вот C#/VB.NET код, который демонстрирует, как добавить профиль ICC к изображению.
''' <summary>
''' Adds ICC profile to the metadata of image page.
''' </summary>
''' <param name="imageFilePath">The image to which the ICC profile must be added.</param>
''' <param name="outputImageFilePath">The result image with added ICC profile.</param>
''' <param name="iccProfilePath">ICC profile file path.</param>
Public Sub AddIccProfileToPageMetadata(imageFilePath As String, outputImageFilePath As String, iccProfilePath As String)
' open an image file
Using image As New Vintasoft.Imaging.VintasoftImage(imageFilePath)
' get ICC profile data
Dim iccProfileData As Byte() = System.IO.File.ReadAllBytes(iccProfilePath)
' add ICC profile to the metadata of image page
AddIccProfileToPageMetadata(image, iccProfileData)
' save the image
image.Save(outputImageFilePath)
End Using
End Sub
''' <summary>
''' Adds ICC profile to the metadata of image page.
''' </summary>
''' <param name="image">The image to which the ICC profile must be added.</param>
''' <param name="iccProfileData">ICC profile data.</param>
''' <exception cref="System.ArgumentException">Thrown if image page does not have metadata.</exception>
Public Sub AddIccProfileToPageMetadata(image As Vintasoft.Imaging.VintasoftImage, iccProfileData As Byte())
' get metadata of image page
Dim pageMetadata As Vintasoft.Imaging.Metadata.PageMetadata = image.Metadata.MetadataTree
' if image has metadata
If pageMetadata IsNot Nothing Then
' add ICC profile data to metadata
pageMetadata.AddIccProfile(iccProfileData)
Else
Throw New System.ArgumentException("The image does not have metadata.")
End If
End Sub
/// <summary>
/// Adds ICC profile to the metadata of image page.
/// </summary>
/// <param name="imageFilePath">The image to which the ICC profile must be added.</param>
/// <param name="outputImageFilePath">The result image with added ICC profile.</param>
/// <param name="iccProfilePath">ICC profile file path.</param>
public void AddIccProfileToPageMetadata(string imageFilePath, string outputImageFilePath, string iccProfilePath)
{
// open an image file
using (Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage(imageFilePath))
{
// get ICC profile data
byte[] iccProfileData = System.IO.File.ReadAllBytes(iccProfilePath);
// add ICC profile to the metadata of image page
AddIccProfileToPageMetadata(image, iccProfileData);
// save the image
image.Save(outputImageFilePath);
}
}
/// <summary>
/// Adds ICC profile to the metadata of image page.
/// </summary>
/// <param name="image">The image to which the ICC profile must be added.</param>
/// <param name="iccProfileData">ICC profile data.</param>
/// <exception cref="System.ArgumentException">Thrown if image page does not have metadata.</exception>
public void AddIccProfileToPageMetadata(Vintasoft.Imaging.VintasoftImage image, byte[] iccProfileData)
{
// get metadata of image page
Vintasoft.Imaging.Metadata.PageMetadata pageMetadata = image.Metadata.MetadataTree;
// if image has metadata
if (pageMetadata != null)
{
// add ICC profile data to metadata
pageMetadata.AddIccProfile(iccProfileData);
}
else
{
throw new System.ArgumentException("The image does not have metadata.");
}
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также