⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client-server imaging.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 4 页
字号:
    <P></P></DD></DL><A name=51162>
  <H2>12.5 <IMG src="Client-Server Imaging.files/space.gif">Running Remote 
  Imaging</H2></A>To run remote imaging in JAI, you have to do the following: 
  <P>
  <UL>1. Create a security policy file
    <P>2. Start the RMI registry
    <P>3. Start the remote image server
    <P>4. Run the local application
    <P></P></UL>These four steps are explained in more detail in the following 
  sections. 
  <P><A name=54942>
  <H3>12.5.1 <IMG src="Client-Server Imaging.files/space.gif">Step 1: Create a 
  Security Policy File</H3></A>The default RMI security policy implementation is 
  specified within one or more policy configuration files. These configuration 
  files specify what permissions are allowed for code from various sources. 
  There is a default system-wide policy file and a single user policy file. For 
  more information on policy files and permissions, see: 
  <P><PRE>     http://java.sun.com/products/jdk/1.2/docs/guide/security/
PolicyFiles.html
     http://java.sun.com/products/jdk/1.2/docs/guide/security/
permissions.html
</PRE>The policy file is located in the base directory where Java Advanced 
  Imaging is installed. If <CODE>$JAI</CODE> is the base directory where Java 
  Advanced Imaging is installed, use any simple text editor to create a text 
  file named <CODE>$JAI/policy</CODE> containing the following: 
  <P><PRE>     grant {
     // Allow everything for now
        permission java.security.AllPermission;
     };
</PRE>Note that this policy file is for testing purposes only. 
  <P><A name=55056>
  <H3>12.5.2 <IMG src="Client-Server Imaging.files/space.gif">Step 2: Start the 
  RMI Registry</H3></A>The RMI registry is a simple server-side name server that 
  allows remote clients to get a reference to a remote object. Typically, the 
  registry is used only to locate the first remote object an application needs 
  to talk to. Then that object in turn provides application-specific support for 
  finding other objects. 
  <P>
  <HR noShade>
  <B>Note:</B> Before starting the rmiregistry, make sure that the shell or 
  window in which you will run the registry either has no <CODE>CLASSPATH</CODE> 
  set or has a <CODE>CLASSPATH</CODE> that does not include the path to any 
  classes you want downloaded to your client, including the stubs for your 
  remote object implementation classes. 
  <HR noShade>
  To start the registry on the server, log in to the remote system where the 
  image server will be running and execute the <CODE>rmiregistry</CODE> command. 

  <P>For example, in the <STRONG>Solaris</STRONG> operating environment using a 
  Bourne-compatible shell (e.g., /bin/sh): 
  <P><PRE>     $ unset CLASSPATH
     $ rmiregistry &amp;
</PRE>Note that the <CODE>CLASSPATH</CODE> environment variable is 
  deliberately not set. 
  <P>For example, on <STRONG>Windows 95</STRONG> or <STRONG>Windows NT</STRONG>: 

  <P><PRE>     start rmiregistry
</PRE>If the <CODE>start</CODE> command is not available, use 
  <CODE>javaw</CODE>. 
  <P><A name=54962>
  <H3>12.5.3 <IMG src="Client-Server Imaging.files/space.gif">Step 3: Start the 
  Remote Image Server</H3></A>While still logged in to the remote server system, 
  set the <CODE>CLASSPATH</CODE> and <CODE>LD_LIBRARY_PATH</CODE> environment 
  variables as required for JAI (see the <CODE>INSTALL</CODE> file) and start 
  the remote imaging server. For example: 
  <P><PRE>     $ CLASSPATH=$JAI/lib/jai.jar:\
                 $JAI/lib/mlibwrapper_jai.jar
     $ export CLASSPATH
     $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAI/lib
     $ export LD_LIBRARY_PATH
     $ java \
     -Djava.rmi.server.codebase=\
          file:$JAI/lib/jai.jar \
     -Djava.rmi.server.useCodebaseOnly=false \
     -Djava.security.policy=file:$JAI/policy \
           com.sun.media.jai.rmi.RMIImageImpl
</PRE>For example, when the above steps are executed on a machine with IP 
  address 123.456.78.90 the following is printed: 
  <P><PRE>     Server: using host 123.456.78.90 port 1099
     Registering image server as
       "rmi://123.456.78.90:1099/RemoteImageServer".
     Server: Bound RemoteImageServer into
       the registry.
</PRE><A name=54969>
  <H3>12.5.4 <IMG src="Client-Server Imaging.files/space.gif">Step 4: Run the 
  Local Application</H3></A>After completing steps 1 through 3, you are ready to 
  run the local application. When running the local application, make sure that 
  the <CODE>serverName</CODE> parameter of any RemoteImage constructors 
  corresponds to the machine on which the remote image server is running. For 
  example, if the machine with IP address 123.456.78.90 above is named 
  <CODE>myserver</CODE>, the <CODE>serverName</CODE> parameter of any 
  <CODE>RemoteImage()</CODE> constructors should be <CODE>"myserver"</CODE>. 
  <P><A name=55174>
  <H2>12.6 <IMG src="Client-Server Imaging.files/space.gif">Internet Imaging 
  Protocol (IIP)</H2></A>There are two JAI operations that support Internet 
  Imaging Protocol (IIP) operations. Two separate operations provide client-side 
  support of the Internet Imaging Protocol. These operations, <CODE>IIP</CODE> 
  and <CODE>IIPResolution</CODE>, request an image from an IIP server then 
  create either a RenderedImage or a RenderableImage. 
  <P><A name=55178>
  <H3>12.6.1 <IMG src="Client-Server Imaging.files/space.gif">IIP 
  Operation</H3></A>The <CODE>IIP</CODE> operation provides client-side support 
  of the Internet Imaging Protocol (IIP) in both the rendered and renderable 
  modes. It creates a <CODE>RenderedImage</CODE> or a 
  <CODE>RenderableImage</CODE> based on the data received from the IIP server, 
  and optionally applies a sequence of operations to the created image. 
  <P>The operations that may be applied and the order in which they are applied 
  are defined in section 2.2.1.1 of the <EM>Internet Imaging Protocol 
  Specification</EM> version 1.0.5. Some or all of the requested operations may 
  be executed on the IIP server if it is determined that the server supports 
  such operations. Any of the requested operations not supported by the server 
  will be executed on the host on which the operation chain is rendered. 
  <P>The processing sequence for the supplied operations is as follows: 
  <P>
  <UL>
    <LI>Filtering (blur or sharpen)
    <P></P></LI></UL>
  <UL>
    <LI>Tone and color correction ("color twist")
    <P></P></LI></UL>
  <UL>
    <LI>Contrast adjustment
    <P></P></LI></UL>
  <UL>
    <LI>Selection of source rectangle of interest
    <P></P></LI></UL>
  <UL>
    <LI>Spatial orientation (rendering-independent affine transformation)
    <P></P></LI></UL>
  <UL>
    <LI>Selection of destination rectangle of interest
    <P></P></LI></UL>
  <UL>
    <LI>Rendering transformation (renderable mode only)
    <P></P></LI></UL>
  <UL>
    <LI>Transposition (rotation and/or mirroring).
    <P></P></LI></UL>As indicated, the rendering transformation is performed only 
  in renderable mode processing. This transformation is derived from the 
  AffineTransform supplied in the RenderContext when rendering actually occurs. 
  Rendered mode processing creates a RenderedImage which is the default 
  rendering of the RenderableImage created in renderable mode processing. 
  <P>The <CODE>IIP</CODE> operation takes 14 parameters.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=55324>Parameter </A>
      <TH><A name=55326>Type </A>
      <TH><A name=55328>Description </A>
    <TR vAlign=top>
      <TD><A name=55330>URL</A><BR>
      <TD><A name=55332>String</A><BR>
      <TD><A name=55334>The URL of the IIP image</A><BR>
    <TR vAlign=top>
      <TD><A name=55336>subImages</A><BR>
      <TD><A name=55338>int[]</A><BR>
      <TD><A name=55340>The sub-images to be used by the server for images at 
        each resolution level</A><BR>
    <TR vAlign=top>
      <TD><A name=55342>filter</A><BR>
      <TD><A name=55344>Float</A><BR>
      <TD><A name=55346>The filtering value</A><BR>
    <TR vAlign=top>
      <TD><A name=55424>colorTwist</A><BR>
      <TD><A name=55426>float[]</A><BR>
      <TD><A name=55428>The color twist matrix</A><BR>
    <TR vAlign=top>
      <TD><A name=55418>contrast</A><BR>
      <TD><A name=55420>Float</A><BR>
      <TD><A name=55422>The contrast value</A><BR>
    <TR vAlign=top>
      <TD><A name=55412>sourceROI</A><BR>
      <TD><A name=55414>Rectangle2D.Float</A><BR>
      <TD><A name=55416>The source rectangle of interest in 
        rendering-independent coordinates</A><BR>
    <TR vAlign=top>
      <TD><A name=55406>transform</A><BR>
      <TD><A name=55408>AffineTransform</A><BR>
      <TD><A name=55410>The rendering-independent spatial orientation 
        transform</A><BR>
    <TR vAlign=top>
      <TD><A name=55400>aspectRatio</A><BR>
      <TD><A name=55402>Float</A><BR>
      <TD><A name=55404>The aspect ratio of the destination image</A><BR>
    <TR vAlign=top>
      <TD><A name=55394>destROI</A><BR>
      <TD><A name=55396>Rectangle2D.Float</A><BR>
      <TD><A name=55398>The destination rectangle of interest in 
        rendering-independent coordinates</A><BR>
    <TR vAlign=top>
      <TD><A name=55388>rotation</A><BR>
      <TD><A name=55390>Integer</A><BR>
      <TD><A name=55392>The counterclockwise rotation angle to be applied to 
        the destination</A><BR>
    <TR vAlign=top>
      <TD><A name=55382>mirrorAxis</A><BR>
      <TD><A name=55384>String</A><BR>
      <TD><A name=55386>The mirror axis</A><BR>
    <TR vAlign=top>
      <TD><A name=55376>ICCProfile</A><BR>
      <TD><A name=55378>color.ICC_Profile</A><BR>
      <TD><A name=55380>The ICC profile used to represent the color space of 
        the source image</A><BR>
    <TR vAlign=top>
      <TD><A name=55370>JPEGQuality</A><BR>
      <TD><A name=55372>Integer</A><BR>
      <TD><A name=55374>The JPEG quality factor</A><BR>
    <TR vAlign=top>
      <TD><A name=55364>JPEGTable</A><BR>
      <TD><A name=55366>Integer</A><BR>
      <TD><A name=55368>The JPEG compression group index 
    number</A><BR></TR></TBODY></TABLE>
  <P>The <CODE>URL</CODE> parameter specifies the URL of the IIP image as a 
  <CODE>java.lang.String</CODE>. It must represent a valid URL and include any 
  required FIF or SDS commands. It cannot be null. 
  <P>The <CODE>subImages</CODE> parameter optionally indicates the sub-images to 
  be used by the server to get the images at each resolution level. The values 
  in this <CODE>int</CODE> array cannot be negative. If this parameter is not 
  specified, or if the array is too short (length is 0), or if a negative value 
  is specified, this operation will use the zeroth sub-image of the resolution 
  level actually processed. 
  <P>The <CODE>filter</CODE> parameter specifies a blur or sharpen operation; a 
  positive value indicates sharpen and a negative value blur. A unit step should 
  produce a perceptible change in the image. The default value is 0 which 
  signifies that no filtering will occur. 
  <P>The <CODE>colorTwist</CODE> parameter represents a 4 x 4 matrix stored in 
  row-major order and should have an array length of at least 16. If an array of 
  length greater than 16 is specified, all elements from index 16 and beyond are 
  ignored. Elements 12, 13, and 14 must be 0. This matrix will be applied to the 
  (possibly padded) data in an intermediate normalized PhotoYCC color space with 
  a premultiplied alpha channel. This operation will force an alpha channel to 
  be added to the image if the last column of the last row of the color twist 
  matrix is not 1.0F. Also, if the image originally has a grayscale color space 
  it will be cast up to RGB if casting the data back to grayscale after applying 
  the color twist matrix would result in any loss of data. The default value is 
  null. 
  <P>The <CODE>contrast</CODE> parameter specifies a contrast enhancement 
  operation with increasing contrast for larger value. It must be greater than 
  or equal to 1.0F. A value of 1.0F indicates no contrast adjustment. The 
  default value is 1.0F. 
  <P>The <CODE>sourceROI</CODE> parameter specifies the rectangle of interest in 
  the source image in rendering-independent coordinates. The intersection of 
  this rectangle with the rendering-independent bounds of the source image must 
  equal itself. The rendering-independent bounds of the source image are defined 
  to be (0.0F, 0.0F, r, 1.0F) where r is the aspect ratio (width/height) of the 
  source image. Note that the source image will not in fact be cropped to these 
  limits but values outside of this rectangle will be suppressed. 
  <P>The <CODE>transform</CODE> parameter represents an affine backward mapping 
  to be applied in rendering-independent coordinates. Note that the direction of 
  transformation is opposite to that of the AffineTransform supplied in the 
  RenderContext which is a forward mapping. The default value of this transform 
  is the identity mapping. The supplied AffineTransform must be invertible. 
  <P>The <CODE>aspectRatio</CODE> parameter specifies the rendering-independent 
  width of the destination image and must be positive. The rendering-independent 
  bounds of the destination image are (0.0F, 0.0F, aspectRatio, 1.0F). If this 
  parameter is not provided, the destination aspect ratio defaults to that of 
  the source. 
  <P>The <CODE>destROI</CODE> parameter specifies the rectangle of interest in 
  the destination image in rendering-independent coordinates. This rectangle 
  must have a non-empty intersection with the rendering-independent bounds of 
  the destination image but is not constrained to the destination image bounds. 
  <P>The <CODE>rotation</CODE> parameter specifies a counter-clockwise rotation 
  angle of the destination image. The rotation angle is limited to 0, 90, 180, 
  or 270 degrees. By default, the destination image is not rotated. 
  <P>The <CODE>mirrorAxis</CODE> parameter may be null, in which case no 
  flipping is applied, or a String of <CODE>x</CODE>, <CODE>X</CODE>, 
  <CODE>y</CODE>, or <CODE>Y</CODE>. 
  <P>The <CODE>ICCProfile</CODE> parameter may only be used with client-side 
  processing or with server-side processing if the connection protocol supports 
  the ability to transfer a profile. 
  <P>The <CODE>JPEGQuality</CODE> and <CODE>JPEGTable</CODE> parameters are only 
  used with server-side processing. If provided, <CODE>JPEGQuality</CODE> must 
  be in the range [0,100] and <CODE>JPEGTable</CODE> in [1,255]. 
  <P>There is no source image associated with this operation. 
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Client-server.doc.html#56227">Listing 
  12-3</A> shows a code sample for an <CODE>IIP</CODE> operation.
  <P><CAPTION><FONT size=-1><B><A name=56227>
  <CENTER><FONT size=-1><B><I>Listing 12-3 </I><IMG 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -