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


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


    Here is C#/VB.NET code that shows how to add image to JBIG2 file using Jbig2File class:
    public void AddImageToJbig2UsingJbig2File(
        System.IO.Stream stream, 
        Vintasoft.Imaging.VintasoftImage image)
    {
        // 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(image);
    
            // save changes
            jbig2File.SaveChanges();
        }
    }
    
    Public Sub AddImageToJbig2UsingJbig2File(stream As System.IO.Stream, image As Vintasoft.Imaging.VintasoftImage)
        ' open existing JBIG2 file
        Using jbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream)
            ' add image to JBIG2 file
            jbig2File.Pages.Add(image)
    
            ' save changes
            jbig2File.SaveChanges()
        End Using
    End Sub
    


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