A JPIP client class which sends server requests and receives responses.
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 again
return;
_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 viewer
viewer.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:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Jpip
Imports Leadtools.Jpip.Client.WinForms
Imports Leadtools.Jpip.Client.InteractiveDecoder
Imports Leadtools.Jpip.Server
Imports Leadtools.Drawing
Private Const SERVER_NAME As String = "LEAD JPIP Server - Test Server"
Private Const ENUMERATION_SERVER_PORT As Integer = 109
Private Const JPIP_SERVER_PORT As Integer = 108
Private 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 JpipServer
Private _imageFileExtensions As List(Of String)
Private _listener As HttpListener
Public _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 Sub
Public Sub ClientRequestReceived(ByVal ar As IAsyncResult)
Dim context As HttpListenerContext
If Nothing Is _listener OrElse (Not _listener.IsListening) Then
Return
End If
Try
context = _listener.EndGetContext(ar)
Catch
Return
End Try
Try
Dim formattedImages As String
Dim 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 Exception
If Not Nothing Is context Then
context.Response.Close()
End If
End Try
End Sub
Public Function GetFormattedServerImagesString() As String
Dim serverImageFile As String
Dim formattedServerImagesString As String = String.Empty
Dim 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 _imageFileExtensions
searchImages.AddRange(Directory.GetFiles(_jpipServer.Configuration.ImagesFolder, extension, SearchOption.AllDirectories))
Next extension
For Each file As String In searchImages
serverImageFile = file.Replace(_jpipServer.Configuration.ImagesFolder, String.Empty)
serverImageFile = serverImageFile.TrimStart("\"c)
formattedServerImagesString &= serverImageFile & ";"
Next file
searchImages.Clear()
For Each aliasFolder As KeyValuePair(Of String, String) In _jpipServer.Configuration.AliasFolders
If (Not Directory.Exists(aliasFolder.Value)) Then
Continue For
End If
For Each extension As String In _imageFileExtensions
searchImages.AddRange(Directory.GetFiles(aliasFolder.Value, extension, SearchOption.AllDirectories))
Next extension
For Each imageFile As String In searchImages
serverImageFile = imageFile.Replace(aliasFolder.Value, aliasFolder.Key)
serverImageFile = serverImageFile.TrimStart("\"c)
formattedServerImagesString &= serverImageFile & ";"
Next imageFile
searchImages.Clear()
Next aliasFolder
Return formattedServerImagesString.TrimEnd(";"c)
End Function
Public 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 again
Return
End 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 Exception
Debug.Fail("Error in server enumeration: " & Constants.vbLf + ex.Message)
End Try
End Sub
Public Sub StopFileEnumerationServer()
Try
If Not _listener Is Nothing Then
_listener.Stop()
End If
Catch ex As Exception
Debug.Fail("Error in server enumeration: " & Constants.vbLf + ex.Message)
End Try
End Sub
Public 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 Then
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
End If
request.UseDefaultCredentials = True
Dim 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 &= temp
count = 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 = 0
For Each image As String In imageFileNames
counter += 1
Debug.Assert(image.Trim().Length > 0, "There is no image to enumerate")
Debug.WriteLine("Image " & counter & ": " & image)
_serverImagesList.Add(image)
Next image
File.WriteAllLines(filename, _serverImagesList.ToArray())
End Sub
Public 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 If
End Sub
Public Sub StopJpipServer()
If _jpipServer.IsRunning Then
_jpipServer.Stop()
End If
End Sub
Public Sub SetJpipViewer(ByVal viewer As JpipRasterImageViewer)
' Initialize JPIP viewer
viewer.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
End Sub
Public 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 Sub
Private Sub OnClientError(ByVal sender As Object, ByVal e As ErrorEventArgs)
Debug.WriteLine(e.GetException().Message)
End Sub
Private Sub OnBytesLoaded(ByVal sender As Object, ByVal e As TotalBytesLoadedEventArgs)
Debug.WriteLine(" Total Bytes: " & e.ByteCount.ToString())
End Sub
Private 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 = 0
Do While i < jpipViewer.NumberOfResolutions
Debug.WriteLine(" Resolution (" & i.ToString() & ") Size" & jpipViewer.GetResolutionSize(i).ToString())
i += 1
Loop
Debug.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 = 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(Constants.vbLf & " 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
Dim count As Integer = jpipViewer.DeleteCacheFiles(deleteCacheFilePriorTo)
Debug.WriteLine(count.ToString() & " Cache File Deleted....")
If jpipViewer.IsActive Then
Debug.WriteLine(" JpipRasterImageViewer.IsActive Test ")
Debug.WriteLine(" CurrentImageSize: " & jpipViewer.CurrentImageSize.ToString())
End If
jpipViewer.Close()
If jpipViewer.IsActive Then
Debug.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 side
StopJpipServer()
End Sub
Public Sub ClientExample()
'Server side
StartJpipServer()
'Client requesting enumerated images from server
StartFileEnumerationServer()
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_DIRECTORY
Dim jpipViewer As JpipRasterImageViewer = New JpipRasterImageViewer()
SetJpipViewer(jpipViewer)
AddHandler jpipViewer.StreamingError, AddressOf OnClientError
AddHandler jpipViewer.TotalBytesLoaded, AddressOf OnBytesLoaded
AddHandler jpipViewer.FileOpened, AddressOf FileOpened
Debug.WriteLine(Constants.vbLf & " Open File: " & _serverImagesList(0))
jpipViewer.Open(_serverImagesList(0))
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS 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