Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Save(RasterImage,Uri,RasterImageFormat,Int32,Int32,Int32) Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class > Save Method : Save(RasterImage,Uri,RasterImageFormat,Int32,Int32,Int32) Method



image
The RasterImage object that holds the image data.
uri
The Uri containing the output URL name.
format
The output file format. For valid values, Summary of All Supported Image File Formats.
bitsPerPixel
Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Summary of All Supported Image File Formats. If bitsPerPixel is 0, the image will be stored using the closet bits/pixel value supported by that format. For example, if a file format supports 1, 4, and 24 bits/pixel, and RasterImage.BitsPerPixel is 5, the file will be stored as 24 bit. Likewise, if RasterImage.BitsPerPixel is 2, the file will be stored as 4 bit.
firstPage
1-based index of the first page in image to save.
lastPage
1-based index of the last page in image to save. Pass -1 to save from firstPage to the last page in image.
Saves one or more pages of a RasterImage to a remote URL in any of the supported compressed or uncompressed formats.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Save( _
   ByVal image As RasterImage, _
   ByVal uri As Uri, _
   ByVal format As RasterImageFormat, _
   ByVal bitsPerPixel As Integer, _
   ByVal firstPage As Integer, _
   ByVal lastPage As Integer _
) As HttpStatusCode
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim image As RasterImage
Dim uri As Uri
Dim format As RasterImageFormat
Dim bitsPerPixel As Integer
Dim firstPage As Integer
Dim lastPage As Integer
Dim value As HttpStatusCode
 
value = instance.Save(image, uri, format, bitsPerPixel, firstPage, lastPage)
C# 
public HttpStatusCode Save( 
   RasterImage image,
   Uri uri,
   RasterImageFormat format,
   int bitsPerPixel,
   int firstPage,
   int lastPage
)
C++/CLI 
public:
HttpStatusCode Save( 
   RasterImage image,
   Uri uri,
   RasterImageFormat format,
   int bitsPerPixel,
   int firstPage,
   int lastPage
) 

Parameters

image
The RasterImage object that holds the image data.
uri
The Uri containing the output URL name.
format
The output file format. For valid values, Summary of All Supported Image File Formats.
bitsPerPixel
Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Summary of All Supported Image File Formats. If bitsPerPixel is 0, the image will be stored using the closet bits/pixel value supported by that format. For example, if a file format supports 1, 4, and 24 bits/pixel, and RasterImage.BitsPerPixel is 5, the file will be stored as 24 bit. Likewise, if RasterImage.BitsPerPixel is 2, the file will be stored as 4 bit.
firstPage
1-based index of the first page in image to save.
lastPage
1-based index of the last page in image to save. Pass -1 to save from firstPage to the last page in image.

Example

This example will create a multipage image and then upload only the second page to a share point server "Shared Document" folder.

Visual BasicCopy Code
Public Sub SaveToSharePointExample()
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()
   Dim imagesFolder As String = LeadtoolsExamples.Common.ImagesPath.Path

   ' Change the path to a server you have access to
   Dim mySharePointServer As String = "http://leadweb3/Shared%20Documents"

   Dim myDocumentFileName As String = mySharePointServer + "/MyJpegFile.jpg"

   Dim image As RasterImage = Nothing

   ' Create a multi-page TIF file
   For i As Integer = 0 To 3
      Dim pageFileName As String = Path.Combine(imagesFolder, "Ocr" + (i + 1).ToString() + ".tif")
      Dim pageImage As RasterImage = codecs.Load(pageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)

      If (image Is Nothing) Then
         image = pageImage
      Else
         image.AddPage(pageImage)
         pageImage.Dispose()
      End If
   Next

   ' We have the image, upload it

   ' Use the credentials of the logged in user
   ' Change this if you have different user name/password/domain
   ' For example:
   ' codecs.UriOperationCredentials = New System.Net.NetworkCredential("myuser", "mypassword", "mydomain")
   codecs.UriOperationCredentials = System.Net.CredentialCache.DefaultCredentials

   ' Use the default proxy
   codecs.UriOperationProxy = WebRequest.DefaultWebProxy

   ' Upload the second page of the file to the server as JPEG
   codecs.Save(image, New Uri(myDocumentFileName), RasterImageFormat.Jpeg, 24, 2, 2)

   image.Dispose()

   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void SaveToSharePointExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   string imagesFolder = LeadtoolsExamples.Common.ImagesPath.Path; 
 
   // Change the path to a server you have access to 
   string mySharePointServer = @"http://leadweb3/Shared%20Documents"; 
 
   string myDocumentFileName = mySharePointServer + "/MyJpegFile.jpg"; 
 
   RasterImage image = null; 
 
   // Create a multi-page TIF file 
   for(int i = 0; i < 4; i++) 
   { 
      string pageFileName = Path.Combine(imagesFolder, "Ocr" + (i + 1).ToString() + ".tif"); 
      RasterImage pageImage = codecs.Load(pageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); 
 
      if(image == null) 
         image = pageImage; 
      else 
      { 
         image.AddPage(pageImage); 
         pageImage.Dispose(); 
      } 
   } 
 
   // We have the image, upload it 
 
   // Use the credentials of the logged in user 
   // Change this if you have different user name/password/domain 
   // For example: 
   // codecs.UriOperationCredentials = new System.Net.NetworkCredential("myuser", "mypassword", "mydomain"); 
   codecs.UriOperationCredentials = System.Net.CredentialCache.DefaultCredentials; 
 
   // Use the default proxy 
   codecs.UriOperationProxy = WebRequest.DefaultWebProxy; 
 
   // Upload the second page of the file to the server as JPEG 
   codecs.Save(image, new Uri(myDocumentFileName), RasterImageFormat.Jpeg, 24, 2, 2); 
 
   image.Dispose(); 
 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

The remote URL defined by uri can be any resource that accepts an HTML "PUT" method. For example, an FTP or SharePoint server.

To setup the authentication and proxy information to use when accessing uri, use UriOperationCredentials and UriOperationProxy.

If the image is 8 bits per pixel or greater, use the LEAD CMP format or one of the JPEG (JTIF or JFIF) formats to save disk space.

If the image is 1-bit per pixel, use the LEAD 1-bit format or a CCITT Group 3 or 4 format to save disk space.

If the image has a region, the region stored in the image will be saved, if the image is saved as one of the TIFF file formats. For more information, refer to Saving A Region. Note, however, that the ability to save a region inside a TIFF file must be unlocked. This requires a Document Imaging or Medical Imaging toolkit.

Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling RasterImage.WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing, by using the WindowLevelCommand or by loading an image from a file format that supports Window Leveling. If a window-leveled image is saved as any other file format, the image data will be converted before being saved. For more information, refer to Saving Window-Leveled Images.

Use the CodecsSaveOptions class to set up other save options parameters before calling this method.

This method supports signed data images, but only DICOM and TIFF formats support signed data. This method will throw an exception if you attempt to save a signed image to a format other than DICOM or TIFF.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also