VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    JBIG2: How to add images to JBIG2 document?
    In This Topic
    Image can be added to JBIG2 document by several ways.


    Here is C#/VB.NET code that shows how to synchronously add images from image collection to JBIG2 file using Jbig2Encoder class:
    public void AddImagesToJbig2UsingJbig2Encoder(
        System.IO.Stream stream, 
        Vintasoft.Imaging.ImageCollection images)
    {
        // add images to JBIG2 file
        using (Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder encoder = 
            new Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(false))
        {
            // add images to JBIG2 file
            encoder.SaveImages(images, stream);
        }
    }
    
    Public Sub AddImagesToJbig2UsingJbig2Encoder(stream As System.IO.Stream, images As Vintasoft.Imaging.ImageCollection)
        ' add images to JBIG2 file
        Using encoder As New Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(False)
            ' add images to JBIG2 file
            encoder.SaveImages(images, stream)
        End Using
    End Sub
    


    Here is C#/VB.NET code that shows how to synchronously add images from image collection to JBIG2 file using Jbig2File class:
    public void AddImagesToJbig2UsingJbig2File(
        System.IO.Stream stream, 
        Vintasoft.Imaging.ImageCollection images)
    {
        // open existing JBIG2 file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File jbig2File = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream))
        {
            // add image to JBIG2 file
            jbig2File.Pages.Add(images);
    
            // save changes
            jbig2File.SaveChanges();
        }
    }
    
    Public Sub AddImagesToJbig2UsingJbig2File(stream As System.IO.Stream, images As Vintasoft.Imaging.ImageCollection)
        ' open existing JBIG2 file
        Using jbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream)
            ' add image to JBIG2 file
            jbig2File.Pages.Add(images)
    
            ' save changes
            jbig2File.SaveChanges()
        End Using
    End Sub
    


    Here is C#/VB.NET code that shows how to synchronously add images from image collection to JBIG2 file using ImageCollection and Jbig2Encoder classes:
    public void AddImagesToJbig2UsingImageCollectionSync(
        System.IO.Stream stream, 
        Vintasoft.Imaging.ImageCollection images)
    {
        // add images to JBIG2 file
        Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder encoder = 
            new Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(false);
    
        // add images to JBIG2 file synchronously
        images.SaveSync(stream, encoder);
    
        // release resources used by encoder
        encoder.Dispose();
    }
    
    Public Sub AddImagesToJbig2UsingImageCollectionSync(stream As System.IO.Stream, images As Vintasoft.Imaging.ImageCollection)
        ' add images to JBIG2 file
        Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(False)
    
        ' add images to JBIG2 file synchronously
        images.SaveSync(stream, encoder)
    
        ' release resources used by encoder
        encoder.Dispose()
    End Sub
    


    Here is C#/VB.NET code that shows how to asynchronously add images from image collection to JBIG2 file using ImageCollection and Jbig2Encoder classes.:
    public void AddImagesJbig2UsingImageCollectionAsync(
        System.IO.Stream stream, 
        Vintasoft.Imaging.ImageCollection images)
    {
        // add images to JBIG2 file
        Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder encoder = 
            new Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(false);
    
        // add images to JBIG2 file asynchronously
        images.SaveAsync(stream, encoder);
    }
    
    Public Sub AddImagesJbig2UsingImageCollectionAsync(stream As System.IO.Stream, images As Vintasoft.Imaging.ImageCollection)
        ' add images to JBIG2 file
        Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.Jbig2Encoder(False)
    
        ' add images to JBIG2 file asynchronously
        images.SaveAsync(stream, encoder)
    End Sub