public class JpipClient Public Class JpipClient
public ref class JpipClient Use this class to make a request to a JPIP server by filling out the request parameters and calling the BeginGetJpipResponse(String,RequestFields,AsyncCallback,Object) method.
This class support asynchronous calls.
using Leadtools;using Leadtools.Codecs;using Leadtools.Jpip;using Leadtools.Jpip.Client.WinForms;using Leadtools.Jpip.Client.InteractiveDecoder;using Leadtools.Jpip.Server;using Leadtools.Drawing;private const string SERVER_NAME = "LEAD JPIP Server - Test Server";private const int ENUMERATION_SERVER_PORT = 109;private const int JPIP_SERVER_PORT = 107;private const string LOCAL_IP_ADDRESS = "127.0.0.1";private string CLIENT_CACHE_DIRECTORY = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000");private string SERVER_CACHE_DIRECTORY = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000");private string SERVER_IMAGES_FOLDER = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000");private string IMAGE_FILE_EXTENSIONS = "*.j2k;*.jp2;*.jpx";private string CLIENT_SAVED_FILE_NAME = Path.Combine(LEAD_VARS.ImagesDir, "test.bmp");private JpipServer _jpipServer;private List<string> _imageFileExtensions;private HttpListener _listener;public List<string> _serverImagesList = new List<string>();public JpipClientExample(){_imageFileExtensions = new List<string>();_jpipServer = new JpipServer();}public void ClientRequestReceived(IAsyncResult ar){HttpListenerContext context;if (null == _listener || !_listener.IsListening){return;}try{context = _listener.EndGetContext(ar);}catch{return;}try{string formattedImages;byte[] sendBuffer;_listener.BeginGetContext(ClientRequestReceived, null);formattedImages = GetFormattedServerImagesString();sendBuffer = Encoding.ASCII.GetBytes(formattedImages);context.Response.OutputStream.Write(sendBuffer, 0, sendBuffer.Length);context.Response.Close();}catch (Exception){if (null != context){context.Response.Close();}}}public string GetFormattedServerImagesString(){string serverImageFile;string formattedServerImagesString = string.Empty;List<string> searchImages = new List<string>();List<string> serverImages = new List<string>();foreach (string extension in _imageFileExtensions){searchImages.AddRange(Directory.GetFiles(_jpipServer.Configuration.ImagesFolder,extension,SearchOption.AllDirectories));}foreach (string file in searchImages){serverImageFile = file.Replace(_jpipServer.Configuration.ImagesFolder,string.Empty);serverImageFile = serverImageFile.TrimStart('\\');formattedServerImagesString += serverImageFile + ";";}searchImages.Clear();foreach (KeyValuePair<string, string> aliasFolder in _jpipServer.Configuration.AliasFolders){if (!Directory.Exists(aliasFolder.Value)){continue;}foreach (string extension in _imageFileExtensions){searchImages.AddRange(Directory.GetFiles(aliasFolder.Value,extension,SearchOption.AllDirectories));}foreach (string imageFile in searchImages){serverImageFile = imageFile.Replace(aliasFolder.Value, aliasFolder.Key);serverImageFile = serverImageFile.TrimStart('\\');formattedServerImagesString += serverImageFile + ";";}searchImages.Clear();}return formattedServerImagesString.TrimEnd(';');}public void StartFileEnumerationServer(){try{_imageFileExtensions.Clear();_imageFileExtensions.AddRange(IMAGE_FILE_EXTENSIONS.Split(';'));if (_listener != null)//if _listner is already created, then do not create againreturn;_listener = new HttpListener();_listener.Prefixes.Add(string.Format("http://{0}:{1}/", LOCAL_IP_ADDRESS, ENUMERATION_SERVER_PORT));_listener.Start();_listener.BeginGetContext(ClientRequestReceived, null);}catch (Exception ex){Debug.Fail("Error in server enumeration: \n" + ex.Message);}}public void StopFileEnumerationServer(){try{if (_listener != null)_listener.Stop();}catch (Exception ex){Debug.Fail("Error in server enumeration: \n" + ex.Message);}}public void GetEnumeratedFiles(string filename){HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://{0}:{1}/", LOCAL_IP_ADDRESS, ENUMERATION_SERVER_PORT));if (null != request.Proxy){request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;}request.UseDefaultCredentials = true;HttpWebResponse response = (HttpWebResponse)request.GetResponse();System.IO.Stream receivedStream = response.GetResponseStream();System.IO.StreamReader reader = new System.IO.StreamReader(receivedStream);Char[] read = new Char[256];// Reads 256 characters at a time.int count = reader.Read(read, 0, 256);string imageNames = "";while (count > 0){// Dumps the 256 characters on a string and displays the string to the console.String temp = new String(read, 0, count);imageNames += temp;count = reader.Read(read, 0, 256);}// Releases the resources of the response.response.Close();// Releases the resources of the Stream.reader.Close();string[] imageFileNames = imageNames.Split(';');int counter = 0;foreach (string image in imageFileNames){counter++;Debug.Assert(image.Trim().Length > 0, "There is no image to enumerate");Debug.WriteLine("Image " + counter + ": " + image);_serverImagesList.Add(image);}File.WriteAllLines(filename, _serverImagesList.ToArray());}public void StartJpipServer(){if (!_jpipServer.IsRunning){//Server Settings_jpipServer.Configuration.ServerName = SERVER_NAME;_jpipServer.Configuration.IPAddress = LOCAL_IP_ADDRESS;_jpipServer.Configuration.Port = JPIP_SERVER_PORT;_jpipServer.Configuration.ImagesFolder = SERVER_IMAGES_FOLDER;_jpipServer.Configuration.CacheFolder = SERVER_CACHE_DIRECTORY;_jpipServer.Configuration.MaxServerBandwidth = _jpipServer.Configuration.MaxServerBandwidth;_jpipServer.Configuration.CacheSize = 200;_jpipServer.Configuration.DivideSuperBoxes = true;_jpipServer.Configuration.ChunkSize = 512;_jpipServer.Configuration.MaxClientCount = 5;_jpipServer.Configuration.ConnectionIdleTimeout = new TimeSpan(0, 0, 9100);_jpipServer.Configuration.MaxSessionLifetime = new TimeSpan(0, 0, 9900);_jpipServer.Configuration.MaxConnectionBandwidth = _jpipServer.Configuration.MaxConnectionBandwidth;//Communication Settings_jpipServer.Configuration.MaxTransportConnections = 15;_jpipServer.Configuration.HandshakeTimeout = new TimeSpan(0, 0, 9600);_jpipServer.Configuration.RequestTimeout = new TimeSpan(0, 0, 920);_jpipServer.Configuration.ChunkSize = 512;//Images Settings_jpipServer.Configuration.ImageParsingTimeout = new TimeSpan(0, 0, 9180);_jpipServer.Configuration.PartitionBoxSize = 40;_jpipServer.Configuration.DivideSuperBoxes = true;//Logging Settings_jpipServer.Configuration.LogInformation = false;_jpipServer.Configuration.LogWarnings = false;_jpipServer.Configuration.LogDebug = false;_jpipServer.Configuration.LogErrors = false;//Start server and delegates_jpipServer.Start();Debug.Assert(_jpipServer.IsRunning, "Server did not start.");}}public void StopJpipServer(){if (_jpipServer.IsRunning)_jpipServer.Stop();}public void SetJpipViewer(JpipRasterImageViewer viewer){// Initialize JPIP viewerviewer.CacheDirectoryName = CLIENT_CACHE_DIRECTORY;viewer.PortNumber = JPIP_SERVER_PORT;viewer.IPAddress = LOCAL_IP_ADDRESS;viewer.PacketSize = 16384;viewer.RequestTimeout = new TimeSpan(0, 1, 0);viewer.ChannelType = JpipChannelTypes.HttpChannel;}public void SaveJpipViewerImageToFile(JpipRasterImageViewer viewer, string fileName){RasterCodecs rc = new Leadtools.Codecs.RasterCodecs();rc.Save(viewer.Image, fileName, RasterImageFormat.Bmp, 24);}private void OnClientError(object sender, ErrorEventArgs e){Debug.WriteLine(e.GetException().Message);}private void OnBytesLoaded(object sender, TotalBytesLoadedEventArgs e){Debug.WriteLine(" Total Bytes: " + e.ByteCount.ToString());}public void ClientExample(){/*Server side*/StartJpipServer();/*Client requesting enumerated images from server*/StartFileEnumerationServer();GetEnumeratedFiles(Path.Combine(LEAD_VARS.ImagesDir, "Client_Enumerated_Images.txt"));StopFileEnumerationServer();JpipRasterImageViewer jpipViewer = new JpipRasterImageViewer();SetJpipViewer(jpipViewer);jpipViewer.StreamingError += OnClientError;jpipViewer.TotalBytesLoaded += OnBytesLoaded;jpipViewer.FileOpened += new EventHandler(jpipViewer_FileOpened);Debug.WriteLine("\n Open File: " + _serverImagesList[0]);jpipViewer.Open(_serverImagesList[0]);}void jpipViewer_FileOpened(object sender, EventArgs e){JpipRasterImageViewer jpipViewer = (JpipRasterImageViewer)sender;/*Client requests an image, copies to local file, then deletes cached files prior to given date from CACHE_DIRECTORY*/DateTime deleteCacheFilePriorTo = new DateTime(2008, 8, 8);Debug.WriteLine("\n FullImageSize: " + jpipViewer.FullImageSize.ToString());Debug.WriteLine(" NumberOfColorComponents: " + jpipViewer.NumberOfColorComponents.ToString());Debug.WriteLine(" NumberOfResolutions: " + jpipViewer.NumberOfResolutions.ToString());Debug.WriteLine(" InteractiveMode: " + jpipViewer.InteractiveMode.ToString());Debug.WriteLine(" PaintProperties: " + jpipViewer.PaintProperties.ToString());Debug.WriteLine(" Available Resolutions");for (int i = 0; i < jpipViewer.NumberOfResolutions; i++){Debug.WriteLine(" Resolution (" + i.ToString() + ") Size" + jpipViewer.GetResolutionSize(i).ToString());}Debug.WriteLine("\nOpen Image");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.ZoomIn();Debug.WriteLine("\n Zoomed in");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.ZoomIn();Debug.WriteLine("\n Zoomed in");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.ComponentIndex = 0;Debug.WriteLine("Component Index value set to 1 ");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.ZoomOut();Debug.WriteLine("\n ZoomOut ");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.ComponentIndex = -1;Debug.WriteLine("Component Index value set to 1 ");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());jpipViewer.Zoom(jpipViewer.GetResolutionSize(2));Debug.WriteLine(" Resolution size set to 2");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());Debug.WriteLine(" ComponentIndex: " + jpipViewer.ComponentIndex.ToString());Debug.WriteLine(" CurrentResolutionIndex: " + jpipViewer.CurrentResolutionIndex.ToString());SaveJpipViewerImageToFile(jpipViewer, CLIENT_SAVED_FILE_NAME);/*Client side function to delete cached files of type LCCACHE File (Not LTCACHE File) prior to given date from CACHE_DIRECTORY*/int count = jpipViewer.DeleteCacheFiles(deleteCacheFilePriorTo);Debug.WriteLine(count.ToString() + " Cache File Deleted....");if (jpipViewer.IsActive){Debug.WriteLine(" JpipRasterImageViewer.IsActive Test ");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());}jpipViewer.Close();if (jpipViewer.IsActive){Debug.WriteLine(" JpipRasterImageViewer.IsActive Test (this should not happen becaue no image is loaded at this point");Debug.WriteLine(" CurrentImageSize: " + jpipViewer.CurrentImageSize.ToString());}/*Server side*/StopJpipServer();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.JpipImports Leadtools.Jpip.Client.WinFormsImports Leadtools.Jpip.Client.InteractiveDecoderImports Leadtools.Jpip.ServerImports Leadtools.DrawingPrivate Const SERVER_NAME As String = "LEAD JPIP Server - Test Server"Private Const ENUMERATION_SERVER_PORT As Integer = 109Private Const JPIP_SERVER_PORT As Integer = 108Private Const LOCAL_IP_ADDRESS As String = "127.0.0.1"Private CLIENT_CACHE_DIRECTORY As String = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000")Private SERVER_CACHE_DIRECTORY As String = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000")Private SERVER_IMAGES_FOLDER As String = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000")Private Const IMAGE_FILE_EXTENSIONS As String = "*.j2k;*.jp2;*.jpx"Private CLIENT_SAVED_FILE_NAME As String = Path.Combine(LEAD_VARS.ImagesDir, "test.bmp")Private _jpipServer As JpipServerPrivate _imageFileExtensions As List(Of String)Private _listener As HttpListenerPublic _serverImagesList As List(Of String) = New List(Of String)()Public Sub New()Leadtools.Examples.Support.SetLicense()_imageFileExtensions = New List(Of String)()_jpipServer = New JpipServer()End SubPublic Sub ClientRequestReceived(ByVal ar As IAsyncResult)Dim context As HttpListenerContextIf Nothing Is _listener OrElse (Not _listener.IsListening) ThenReturnEnd IfTrycontext = _listener.EndGetContext(ar)CatchReturnEnd TryTryDim formattedImages As StringDim sendBuffer As Byte()_listener.BeginGetContext(AddressOf ClientRequestReceived, Nothing)formattedImages = GetFormattedServerImagesString()sendBuffer = Encoding.ASCII.GetBytes(formattedImages)context.Response.OutputStream.Write(sendBuffer, 0, sendBuffer.Length)context.Response.Close()Catch e1 As ExceptionIf Not Nothing Is context Thencontext.Response.Close()End IfEnd TryEnd SubPublic Function GetFormattedServerImagesString() As StringDim serverImageFile As StringDim formattedServerImagesString As String = String.EmptyDim searchImages As List(Of String) = New List(Of String)()Dim serverImages As List(Of String) = New List(Of String)()For Each extension As String In _imageFileExtensionssearchImages.AddRange(Directory.GetFiles(_jpipServer.Configuration.ImagesFolder, extension, SearchOption.AllDirectories))Next extensionFor Each file As String In searchImagesserverImageFile = file.Replace(_jpipServer.Configuration.ImagesFolder, String.Empty)serverImageFile = serverImageFile.TrimStart("\"c)formattedServerImagesString &= serverImageFile & ";"Next filesearchImages.Clear()For Each aliasFolder As KeyValuePair(Of String, String) In _jpipServer.Configuration.AliasFoldersIf (Not Directory.Exists(aliasFolder.Value)) ThenContinue ForEnd IfFor Each extension As String In _imageFileExtensionssearchImages.AddRange(Directory.GetFiles(aliasFolder.Value, extension, SearchOption.AllDirectories))Next extensionFor Each imageFile As String In searchImagesserverImageFile = imageFile.Replace(aliasFolder.Value, aliasFolder.Key)serverImageFile = serverImageFile.TrimStart("\"c)formattedServerImagesString &= serverImageFile & ";"Next imageFilesearchImages.Clear()Next aliasFolderReturn formattedServerImagesString.TrimEnd(";"c)End FunctionPublic Sub StartFileEnumerationServer()Try_imageFileExtensions.Clear()_imageFileExtensions.AddRange(IMAGE_FILE_EXTENSIONS.Split(";"c))If Not _listener Is Nothing Then 'if _listner is already created, then do not create againReturnEnd If_listener = New HttpListener()_listener.Prefixes.Add(String.Format("http://{0}:{1}/", LOCAL_IP_ADDRESS, ENUMERATION_SERVER_PORT))_listener.Start()_listener.BeginGetContext(AddressOf ClientRequestReceived, Nothing)Catch ex As ExceptionDebug.Fail("Error in server enumeration: " & Constants.vbLf + ex.Message)End TryEnd SubPublic Sub StopFileEnumerationServer()TryIf Not _listener Is Nothing Then_listener.Stop()End IfCatch ex As ExceptionDebug.Fail("Error in server enumeration: " & Constants.vbLf + ex.Message)End TryEnd SubPublic Sub GetEnumeratedFiles(ByVal filename As String)Dim request As HttpWebRequest = CType(HttpWebRequest.Create(String.Format("http://{0}:{1}/", LOCAL_IP_ADDRESS, ENUMERATION_SERVER_PORT)), HttpWebRequest)If Not Nothing Is request.Proxy Thenrequest.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentialsEnd Ifrequest.UseDefaultCredentials = TrueDim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)Dim receivedStream As System.IO.Stream = response.GetResponseStream()Dim reader As System.IO.StreamReader = New System.IO.StreamReader(receivedStream)Dim read As Char() = New Char(255) {}' Reads 256 characters at a time.Dim count As Integer = reader.Read(read, 0, 256)Dim imageNames As String = ""Do While count > 0' Dumps the 256 characters on a string and displays the string to the console.Dim temp As String = New String(read, 0, count)imageNames &= tempcount = reader.Read(read, 0, 256)Loop' Releases the resources of the response.response.Close()' Releases the resources of the Stream.reader.Close()Dim imageFileNames As String() = imageNames.Split(";"c)Dim counter As Integer = 0For Each image As String In imageFileNamescounter += 1Debug.Assert(image.Trim().Length > 0, "There is no image to enumerate")Debug.WriteLine("Image " & counter & ": " & image)_serverImagesList.Add(image)Next imageFile.WriteAllLines(filename, _serverImagesList.ToArray())End SubPublic Sub StartJpipServer()If (Not _jpipServer.IsRunning) Then'Server Settings_jpipServer.Configuration.ServerName = SERVER_NAME_jpipServer.Configuration.IPAddress = LOCAL_IP_ADDRESS_jpipServer.Configuration.Port = JPIP_SERVER_PORT_jpipServer.Configuration.ImagesFolder = SERVER_IMAGES_FOLDER_jpipServer.Configuration.CacheFolder = SERVER_CACHE_DIRECTORY_jpipServer.Configuration.MaxServerBandwidth = _jpipServer.Configuration.MaxServerBandwidth_jpipServer.Configuration.CacheSize = 200_jpipServer.Configuration.DivideSuperBoxes = True_jpipServer.Configuration.ChunkSize = 512_jpipServer.Configuration.MaxClientCount = 5_jpipServer.Configuration.ConnectionIdleTimeout = New TimeSpan(0, 0, 9100)_jpipServer.Configuration.MaxSessionLifetime = New TimeSpan(0, 0, 9900)_jpipServer.Configuration.MaxConnectionBandwidth = _jpipServer.Configuration.MaxConnectionBandwidth'Communication Settings_jpipServer.Configuration.MaxTransportConnections = 15_jpipServer.Configuration.HandshakeTimeout = New TimeSpan(0, 0, 9600)_jpipServer.Configuration.RequestTimeout = New TimeSpan(0, 0, 920)_jpipServer.Configuration.ChunkSize = 512'Images Settings_jpipServer.Configuration.ImageParsingTimeout = New TimeSpan(0, 0, 9180)_jpipServer.Configuration.PartitionBoxSize = 40_jpipServer.Configuration.DivideSuperBoxes = True'Logging Settings_jpipServer.Configuration.LogInformation = False_jpipServer.Configuration.LogWarnings = False_jpipServer.Configuration.LogDebug = False_jpipServer.Configuration.LogErrors = False'Start server and delegates_jpipServer.Start()Debug.Assert(_jpipServer.IsRunning, "Server did not start.")End IfEnd SubPublic Sub StopJpipServer()If _jpipServer.IsRunning Then_jpipServer.Stop()End IfEnd SubPublic Sub SetJpipViewer(ByVal viewer As JpipRasterImageViewer)' Initialize JPIP viewerviewer.CacheDirectoryName = CLIENT_CACHE_DIRECTORYviewer.PortNumber = JPIP_SERVER_PORTviewer.IPAddress = LOCAL_IP_ADDRESSviewer.PacketSize = 16384viewer.RequestTimeout = New TimeSpan(0, 1, 0)viewer.ChannelType = JpipChannelTypes.HttpChannelEnd SubPublic Sub SaveJpipViewerImageToFile(ByVal viewer As JpipRasterImageViewer, ByVal fileName As String)Dim rc As RasterCodecs = New Leadtools.Codecs.RasterCodecs()rc.Save(viewer.Image, fileName, RasterImageFormat.Bmp, 24)End SubPrivate Sub OnClientError(ByVal sender As Object, ByVal e As ErrorEventArgs)Debug.WriteLine(e.GetException().Message)End SubPrivate Sub OnBytesLoaded(ByVal sender As Object, ByVal e As TotalBytesLoadedEventArgs)Debug.WriteLine(" Total Bytes: " & e.ByteCount.ToString())End SubPrivate Sub FileOpened(ByVal sender As Object, ByVal e As EventArgs)Dim jpipViewer As JpipRasterImageViewer = DirectCast(sender, JpipRasterImageViewer)Dim deleteCacheFilePriorTo As DateTime = New DateTime(2008, 8, 8)Debug.WriteLine(Constants.vbLf & " FullImageSize: " & jpipViewer.FullImageSize.ToString())Debug.WriteLine(" NumberOfColorComponents: " & jpipViewer.NumberOfColorComponents.ToString())Debug.WriteLine(" NumberOfResolutions: " & jpipViewer.NumberOfResolutions.ToString())Debug.WriteLine(" InteractiveMode: " & jpipViewer.InteractiveMode.ToString())Debug.WriteLine(" PaintProperties: " & jpipViewer.PaintProperties.ToString())Debug.WriteLine(" Available Resolutions")Dim i As Integer = 0Do While i < jpipViewer.NumberOfResolutionsDebug.WriteLine(" Resolution (" & i.ToString() & ") Size" & jpipViewer.GetResolutionSize(i).ToString())i += 1LoopDebug.WriteLine(Constants.vbLf & "Open Image")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.ZoomIn()Debug.WriteLine(Constants.vbLf & " Zoomed in")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.ZoomIn()Debug.WriteLine(Constants.vbLf & " Zoomed in")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.ComponentIndex = 0Debug.WriteLine("Component Index value set to 1 ")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.ZoomOut()Debug.WriteLine(Constants.vbLf & " ZoomOut ")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.ComponentIndex = -1Debug.WriteLine("Component Index value set to 1 ")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())jpipViewer.Zoom(jpipViewer.GetResolutionSize(2))Debug.WriteLine(" Resolution size set to 2")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())Debug.WriteLine(" ComponentIndex: " & jpipViewer.ComponentIndex.ToString())Debug.WriteLine(" CurrentResolutionIndex: " & jpipViewer.CurrentResolutionIndex.ToString())SaveJpipViewerImageToFile(jpipViewer, CLIENT_SAVED_FILE_NAME)'Client side function to delete cached files of type LCCACHE File (Not LTCACHE File) prior to given date from CACHE_DIRECTORYDim count As Integer = jpipViewer.DeleteCacheFiles(deleteCacheFilePriorTo)Debug.WriteLine(count.ToString() & " Cache File Deleted....")If jpipViewer.IsActive ThenDebug.WriteLine(" JpipRasterImageViewer.IsActive Test ")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())End IfjpipViewer.Close()If jpipViewer.IsActive ThenDebug.WriteLine(" JpipRasterImageViewer.IsActive Test (this should not happen becaue no image is loaded at this point")Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())End If'Server sideStopJpipServer()End SubPublic Sub ClientExample()'Server sideStartJpipServer()'Client requesting enumerated images from serverStartFileEnumerationServer()GetEnumeratedFiles(Path.Combine(LEAD_VARS.ImagesDir, "Client_Enumerated_Images.txt"))StopFileEnumerationServer()'Client requests an image, copies to local file, then deletes cached files prior to given date from CACHE_DIRECTORYDim jpipViewer As JpipRasterImageViewer = New JpipRasterImageViewer()SetJpipViewer(jpipViewer)AddHandler jpipViewer.StreamingError, AddressOf OnClientErrorAddHandler jpipViewer.TotalBytesLoaded, AddressOf OnBytesLoadedAddHandler jpipViewer.FileOpened, AddressOf FileOpenedDebug.WriteLine(Constants.vbLf & " Open File: " & _serverImagesList(0))jpipViewer.Open(_serverImagesList(0))End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
