VintaSoft Imaging .NET SDK 15.1: Документация для .NET разработчика
В этом разделе
Как сохранить изображение с теми же настройками энкодера?
В этом разделе
Иногда необходимо загрузить изображение из файла, изменить его и сохранить измененное изображение в файл с настройками, которые использовались при кодировании исходного изображения.
VintaSoft Imaging .NET SDK позволяет получить настройки, которые использовались для кодирования изображения, с помощью следующих методов:
Вот C#/VB.NET код, который демонстрирует, как сохранить изображение с теми же настройками энкодера, которые использовались для кодирования исходного изображения:
// open a TIFF file
using (System.IO.FileStream fStream = new System.IO.FileStream(
     "multipage.tif",
     System.IO.FileMode.Open,
     System.IO.FileAccess.ReadWrite))
{
    // create an image collection
    Vintasoft.Imaging.ImageCollection images =
        new Vintasoft.Imaging.ImageCollection();
    // add images from the stream to the image collection
    images.Add(fStream);

    // rotate the second page of TIFF file
    images[1].Rotate(90);

    // create a TIFF encoder
    using (Vintasoft.Imaging.Codecs.Encoders.EncoderBase encoder =
        Vintasoft.Imaging.Codecs.Encoders.AvailableEncoders.CreateEncoder("multipage.tif"))
    {
        // specify that encoder must switch the image source to the saved file
        encoder.SaveAndSwitchSource = true;
        // set the encoder settings similar to the settings, which was used for encoding the first page of TIFF file
        encoder.SetSettingsFromImage(images[0]);
        // save changes to the TIFF file
        images.SaveSync(fStream, encoder);
    }

    // clear the image collection and dispose the images
    images.ClearAndDisposeItems();
}
' open a TIFF file
Using fStream As New System.IO.FileStream("multipage.tif", System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)
    ' create an image collection
    Dim images As New Vintasoft.Imaging.ImageCollection()
    ' add images from the stream to the image collection
    images.Add(fStream)

    ' rotate the second page of TIFF file
    images(1).Rotate(90)

    ' create a TIFF encoder
    Using encoder As Vintasoft.Imaging.Codecs.Encoders.EncoderBase = Vintasoft.Imaging.Codecs.Encoders.AvailableEncoders.CreateEncoder("multipage.tif")
        ' specify that encoder must switch the image source to the saved file
        encoder.SaveAndSwitchSource = True
        ' set the encoder settings similar to the settings, which was used for encoding the first page of TIFF file
        encoder.SetSettingsFromImage(images(0))
        ' save changes to the TIFF file
        images.SaveSync(fStream, encoder)
    End Using

    ' clear the image collection and dispose the images
    images.ClearAndDisposeItems()
End Using