ClearImage .NET API
Open(String,Int32) Method
Example 





Inlite.ClearImage Namespace > CiImage Class > Open Method : Open(String,Int32) Method
.
Create image from image file
Syntax
'Declaration
 
Public Overloads Function Open( _
   ByVal FileName As System.String, _
   ByVal PageNumber As System.Integer _
) As System.Integer
'Usage
 
Dim instance As CiImage
Dim FileName As System.String
Dim PageNumber As System.Integer
Dim value As System.Integer
 
value = instance.Open(FileName, PageNumber)
public System.int Open( 
   System.string FileName,
   System.int PageNumber
)
public function Open( 
    FileName: System.String;
    PageNumber: System.Integer
): System.Integer; 
public function Open( 
   FileName : System.String,
   PageNumber : System.int
) : System.int;
public:
System.int Open( 
   System.String^ FileName,
   System.int PageNumber
) 

Parameters

FileName
PageNumber
.
Remarks

This method generates an error if object.Image.IsZone is true.

This method reads the following image file formats:

Bitonal:   TIFF, PDF, PCX, BMP
Color and Grayscale: TIFF, PDF, BMP, WMF, JPEG, PCX, and PICT.
Multi Page TIFF and PDF image files are supported.  See EFileFormat for list of supported formats.

See Image file opening guidelines on Inlite's How-to Web Site

Example
Open, Save, Append Image. List image properties
void OpenSaveAppendImages(string imageFile1, string imageFile2, string pdfFileOut)
{
    CiServer ci = Inlite.ClearImageNet.Server.GetThreadServer();
    CiImage Image = ci.CreateImage();
    // Create PDF file with image from the first file
    Image.Open(imageFile1, 1);
    Image.SaveAs(pdfFileOut, EFileFormat.cifPDF);
    // Append to PDF file image from the second file
    Image.Open(imageFile2, 1);
    Image.Append(pdfFileOut, EFileFormat.cifPDF);
    // Open PDF page and show image information
    Image.Open(pdfFileOut, 2);
    ShowImageInfo(Image);
    // Close image
    Image.Close();
}

void ShowImageInfo(CiImage Image)
{
    Console.WriteLine("  File='" + Image.FileName + "'" + " Page=" + Image.PageNumber + " PageCount=" + Image.PageCount + "  Format=" + Image.Format);
    Console.WriteLine("  Width=" + Image.Width + "  Height=" + Image.Height + "  BPP=" + Image.BitsPerPixel + " HorzDpi=" + Image.HorzDpi + "   VertDpi=" + Image.VertDpi);
}
Sub OpenSaveAppendImages(imageFile1 As String, imageFile2 As String, pdfFileOut As String)
    Dim ci As CiServer = Inlite.ClearImageNet.Server.GetThreadServer()
    Dim Image As CiImage = ci.CreateImage()
    ' Create PDF file with image from the first file
    Image.Open(imageFile1, 1)
    Image.SaveAs(pdfFileOut, EFileFormat.cifPDF)
    ' Append to PDF file image from the second file
    Image.Open(imageFile2, 1)
    Image.Append(pdfFileOut, EFileFormat.cifPDF)
    '  Open PDF page and show image information
    Image.Open(pdfFileOut, 2)
    ShowImageInfo(Image)
    '  Close image
    Image.Close()
End Sub

Sub ShowImageInfo(Image As CiImage)
    Console.WriteLine("  File='" + Image.FileName + "'" + " Page=" + Image.PageNumber + " PageCount=" + Image.PageCount + "  Format=" + Image.Format)
    Console.WriteLine("  Width=" + Image.Width + "  Height=" + Image.Height + "  BPP=" + Image.BitsPerPixel + " HorzDpi=" + Image.HorzDpi + "   VertDpi=" + Image.VertDpi)
End Sub
Process multi-page file
void ProcessMultiPageFile(string imageFile)
{
    CiServer ci = Inlite.ClearImageNet.Server.GetThreadServer();
    CiImage Image = ci.CreateImage();
    Image.Open(imageFile, 1);
    for (int page = 1; page <= Image.PageCount; page++)
    {
        Image.Open(imageFile, page);
        //  Process  image page, for example
        //  ==== Read barcodes
        //     BarcodePro.Image = Image;
        //     BarcodePro.Find(0);
        //     // process barcodes
        //  ==== Repair image
        //     Repair.Image = Image;
        //     Repair.AutoDeskew();
        //     Image.Append (pdfFileOut, EFileFormat.cifPDF);
    }
 }
Sub ProcessMultiPageFile(imageFile As String)
    Dim ci As CiServer = Inlite.ClearImageNet.Server.GetThreadServer()
    Dim Image As CiImage = ci.CreateImage()
    Dim page As Integer
    Image.Open(imageFile, 1)
    For page = 1 To Image.PageCount
        Image.Open(imageFile, page)
        '  Process  image page, for example
        '  ==== Read barcodes
        '     BarcodePro.Image = Image
        '     BarcodePro.Find(0)
        '     ' process barcodes
        '  ==== Repair image
        '     Repair.Image = Image
        '     Repair.AutoDeskew()
        '     Image.Append (pdfFileOut, EFileFormat.cifPDF)
    Next
End Sub
See Also

Reference

CiImage Class
CiImage Members
Overload List
CiPdf Class
Append Method
Open Method
Save Method
SaveAs Method