ImageGear Professional v18.2 > User Guide > Using ImageGear > Loading, Saving, and Acquiring Images > Loading/Saving a Single Page |
The following examples show how you might load and then save a single-page file; first using LoadPageFromFile Method, second showing the equivalent LoadPage Method, and third showing LoadPage Method to obtain an image over the Internet. Since these examples are only concerned with the loading and saving functions, they do not show the code that would have modified the image (thus necessitating the save processing). If your application does not modify the image in any way, then it will not need to include the "save" logic.
You could use any of these same techniques to load a single page from a multi- page file. In that case, you'd specify the desired page number (they're numbered starting at 1) in the LoadPage Method or LoadPageFromFile Method call. |
These examples use a hard-coded filename. A real application would provide some mechanism for choosing the file to load (for example, a File-Chooser dialog - see Dialogs, below). Also, these examples use all default values for the IGLoadOptions Object. |
Copy Code
|
|
---|---|
Dim page As IGPage IGCoreCtl1.License.SetSolutionName "Accusoft" IGCoreCtl1.Result.NotificationMode = IG_ERR_NO_ACTION IGCoreCtl1.AssociateComponent IGFormatsCtl1.ComponentInterface Set page = IGCoreCtl1.CreatePage IGFormatsCtl1.LoadPageFromFile page, "myfile.jpg", 0 . . (image modification logic not shown) . IGFormatsCtl1.SavePageToFile page, "myfile.jpg", 0, IG_PAGESAVEMODE_OVERWRITE, IG_SAVE_UNKNOWN |
Copy Code
|
|
---|---|
Dim page As IGPage Dim file As IGIOFile Dim options as IGLoadOptions IGCoreCtl1.License.SetSolutionName "Accusoft" IGCoreCtl1.Result.NotificationMode = IG_ERR_NO_ACTION IGCoreCtl1.AssociateComponent IGFormatsCtl1.ComponentInterface Set file = IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_IOFILE) Set options = IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_LOADOPTIONS) file.FileName = "myfile.jpg" options.Format = IGFormatsCtl1.DetectImageFormat(file) options.Cropping.Enabled = False options.Resizing.Enabled = False options.Reduction.Enabled = False Set page = IGCoreCtl1.CreatePage IGFormatsCtl1.LoadPage page, file, 0, 0, options . . (image modification logic not shown) . IGFormatsCtl1.SavePage page, file, 0, IG_PAGESAVEMODE_OVERWRITE, IG_SAVE_UNKNOWN |
Copy Code
|
|
---|---|
Dim page As IGPage Dim url As IGIOURL Dim options as IGLoadOptions IGCoreCtl1.License.SetSolutionName "Accusoft" IGCoreCtl1.Result.NotificationMode = IG_ERR_NO_ACTION IGCoreCtl1.AssociateComponent IGFormatsCtl1.ComponentInterface Set url = IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_IOURL) Set options = IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_LOADOPTIONS) url.InetService = IG_INETSERV_HTTP url.HostName = "www.accusoft.com" url.URLPath = "rsc/ts/pr/9999/myfile.jpg" url.UserName = "Anonymous" url.Password = "" options.Format = IGFormatsCtl1.DetectImageFormat(url) options.Cropping.Enabled = False options.Resizing.Enabled = False options.Reduction.Enabled = False Set page = IGCoreCtl1.CreatePage IGFormatsCtl1.LoadPage page, url, 0, 0, options . . (image modification logic not shown) . IGFormatsCtl1.SavePage page, url, 0, IG_PAGESAVEMODE_OVERWRITE, IG_SAVE_UNKNOWN |