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

📄 client-server imaging.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 4 页
字号:
  src="Client-Server Imaging.files/sm-blank.gif" border=0> IIP Operation Example 
  </B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD><PRE>     public static final String SERVER = "http://istserver:8087/";
     public static final String DEFAULT_IMAGE = "cat.fpx";
     public static final int DEFAULT_HEIGHT = 512;
</PRE><TR valign="top"><TD><PRE>     public static void main(String[] args) {
         String imagePath = DEFAULT_IMAGE;
</PRE><TR valign="top"><TD><PRE>        for(int i = 0; i &lt; args.length; i++) {
            if(args[i].equalsIgnoreCase("-image")) {
                imagePath = args[++i];
                if(!(imagePath.toLowerCase().endsWith(".fpx"))) {
                     imagePath += ".fpx";
                }
            }
        }
</PRE><TR valign="top"><TD><PRE>        String url = SERVER + "FIF=" + imagePath;
</PRE><TR valign="top"><TD><PRE>        new IIPTest(url);
     }
</PRE><TR valign="top"><TD rowspan="2" colspan="1"><PRE>     // Define the parameter block.
     ParameterBlock pb = (new ParameterBlock()).add(url);
</PRE><TR valign="top"><TR valign="top"><TD rowspan="12" colspan="1"><PRE>     // Default sub-image array
     pb.set(-10.0F, 2); // filter
     float[] colorTwist = new float[]
         {1.0F, 0.0F, 0.0F, 0.0F,
          0.0F, 0.0F, 1.0F, 0.0F,
          0.0F, 1.0F, 0.0F, 0.0F,
          0.0F, 0.0F, 0.0F, 1.0F};
     pb.set(colorTwist, 3); //color-twist
     pb.set(2.0F, 4); // contrast
     pb.set(new Rectangle2D.Float(0.10F, 0.10F,
                                  0.80F*aspectRatioSource, 0.80F),
            5); // srcROI
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD 
  rowspan="3" colspan="1"><PRE>     AffineTransform afn = AffineTransform.getShearInstance(0.2,<BR>
                        0.1);
     pb.set(afn, 6); // transform
     Rectangle2D destBounds = null;
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TD rowspan="8" 
  colspan="1"><PRE>     try {
          Rectangle2D sourceRect =
                new Rectangle2D.Float(0.0F, 0.0F, aspectRatioSource,<BR>
                                   1.0F);
          Shape shape =
              afn.createInverse().createTransformedShape(sourceRect);
          destBounds = shape.getBounds2D();
     } catch(Exception e) {
     }
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD 
  rowspan="6" colspan="1"><PRE>     float aspectRatio = (float)destBounds.getHeight();
     pb.set(aspectRatio, 7); // destination aspect ratio
     pb.set(new Rectangle2D.Float(0.0F, 0.0F,
                              0.75F*aspectRatio, 0.75F), 8); // dstROI
     pb.set(90, 9); // rotation angle
     pb.set("x", 10); // mirror axis
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TD rowspan="4" colspan="1"><PRE>     // Default ICC profile
     // Default JPEG quality
     // Default JPEG table index
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD 
  rowspan="4" colspan="1"><PRE>     int height = DEFAULT_HEIGHT;
     AffineTransform at =
         AffineTransform.getScaleInstance(height*aspectRatioSource,<BR>
                      height);
     RenderContext rc = new RenderContext(at);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD><PRE>     // Create a RenderableImage.
     RenderableImage renderable = JAI.createRenderable("iip", pb);
</PRE>
  <HR>

  <P><A name=55791>
  <H3>12.6.2 <IMG src="Client-Server Imaging.files/space.gif">IIPResolution 
  Operation</H3></A>The <CODE>IIPResolution</CODE> operation provides 
  client-side support of the Internet Imaging Protocol (IIP) in the rendered 
  mode. It is resolution-specific. It requests from the IIP server an image at a 
  particular resolution level, and creates a <CODE>RenderedImage</CODE> based on 
  the data received from the server. Once the <CODE>RenderedImage</CODE> is 
  created, the resolution level cannot be changed. 
  <P>The layout of the created RenderedImage is set as follows: 
  <P>
  <UL>
    <LI>minX, minY, tileGridXOffset, and tileGridYOffset are set to 0
    <P></P></LI></UL>
  <UL>
    <LI>width and height are determined based on the specified resolution level
    <P></P></LI></UL>
  <UL>
    <LI>tileWidth and tileHeight are set to 64
    <P></P></LI></UL>
  <UL>
    <LI>sampleModel is of the type <CODE>PixelInterleavedSampleModel</CODE> with 
    byte data type and the appropriate number of bands
    <P></P></LI></UL>
  <UL>
    <LI>colorModel is of the type 
    <CODE>java.awt.image.ComponentColorModel</CODE>, with the ColorSpace set to 
    sRGB, PhotoYCC, or Grayscale, depending on the color space of the remote 
    image; if an alpha channel is present, it will be premultiplied
    <P></P></LI></UL>The <CODE>IIPResolution</CODE> operation takes three 
  parameters.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=55886>Parameter </A>
      <TH><A name=55888>Type </A>
      <TH><A name=55890>Description </A>
    <TR vAlign=top>
      <TD><A name=55892>URL</A><BR>
      <TD><A name=55894>String</A><BR>
      <TD><A name=55896>The URL of the IIP image</A><BR>
    <TR vAlign=top>
      <TD><A name=55898>resolution</A><BR>
      <TD><A name=55900>Integer</A><BR>
      <TD><A name=55902>The resolution level to request</A><BR>
    <TR vAlign=top>
      <TD><A name=55904>subImage</A><BR>
      <TD><A name=55906>Integer</A><BR>
      <TD><A name=55908>The sub-image to be used by the 
  server</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>resolution</CODE> parameter specifies the resolution level of the 
  requested IIP image from the server. The lowest resolution level is 0, with 
  larger integers representing higher resolution levels. If the requested 
  resolution level does not exist, the nearest resolution level is used. If this 
  parameter is not specified, it is set to the default value 
  <CODE>IIPResolutionDescriptor.MAX_RESOLUTION</CODE>, which indicates the 
  highest resolution level. 
  <P>The <CODE>subImage</CODE> parameter indicates the sub-image to be used by 
  the server to get the image at the specified resolution level. This parameter 
  cannot be negative. If this parameter is not specified, it is set to the 
  default value 0. 
  <P>There is no source image associated with this operation. 
  <P>If available from the IIP server certain properties may be set on the 
  RenderedImage. The names of properties and the class types of their associated 
  values are listed in the following table. See the IIP specification for 
  information on each of these properties.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=56055>Property </A>
      <TH><A name=56057>Type </A>
    <TR vAlign=top>
      <TD><A name=56151>affine-transform</A><BR>
      <TD><A name=56153>java.awt.geom.AffineTransform</A><BR>
    <TR vAlign=top>
      <TD><A name=56059>app-name</A><BR>
      <TD><A name=56061>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56063>aspect-ratio</A><BR>
      <TD><A name=56065>java.lang.Float</A><BR>
    <TR vAlign=top>
      <TD><A name=56067>author</A><BR>
      <TD><A name=56069>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56071>colorspace</A><BR>
      <TD><A name=56073>int[]</A><BR>
    <TR vAlign=top>
      <TD><A name=56075>color-twist</A><BR>
      <TD><A name=56077>float[16]</A><BR>
    <TR vAlign=top>
      <TD><A name=56079>comment</A><BR>
      <TD><A name=56081>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56083>contrast-adjust</A><BR>
      <TD><A name=56085>java.lang.Float</A><BR>
    <TR vAlign=top>
      <TD><A name=56087>copyright</A><BR>
      <TD><A name=56089>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56091>create-dtm</A><BR>
      <TD><A name=56093>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56095>edit-time</A><BR>
      <TD><A name=56097>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56099>filtering-value</A><BR>
      <TD><A name=56101>java.lang.Float</A><BR>
    <TR vAlign=top>
      <TD><A name=56103>iip</A><BR>
      <TD><A name=56105>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56107>iip-server</A><BR>
      <TD><A name=56109>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56111>keywords</A><BR>
      <TD><A name=56113>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56115>last-author</A><BR>
      <TD><A name=56117>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56119>last-printed</A><BR>
      <TD><A name=56121>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56123>last-save-dtm</A><BR>
      <TD><A name=56125>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56127>max-size</A><BR>
      <TD><A name=56129>int[2]</A><BR>
    <TR vAlign=top>
      <TD><A name=56131>resolution-number</A><BR>
      <TD><A name=56133>java.lang.Integer</A><BR>
    <TR vAlign=top>
      <TD><A name=56135>rev-number</A><BR>
      <TD><A name=56137>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56139>roi-iip</A><BR>
      <TD><A name=56141>java.awt.geom.Rectangle2D.Float</A><BR>
    <TR vAlign=top>
      <TD><A name=56143>subject</A><BR>
      <TD><A name=56145>java.lang.String</A><BR>
    <TR vAlign=top>
      <TD><A name=56147>title</A><BR>
      <TD><A name=56149>java.lang.String</A><BR></TR></TBODY></TABLE>
  <P><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Client-server.doc.html#56497">Listing 
  12-4</A> shows a code sample for an <CODE>IIPResolution</CODE> operation.
  <P><CAPTION><FONT size=-1><B><A name=56497>
  <CENTER><FONT size=-1><B><I>Listing 12-4 </I><IMG 
  src="Client-Server Imaging.files/sm-blank.gif" border=0> IIPResolution 
  Operation Example </B></FONT></CENTER></A>
  <P></B></FONT></CAPTION>
  <HR>
  <TR valign="top"><TD rowspan="5" colspan="1"><PRE>     public static final String SERVER = "http://istserver:8087/";
     public static final String DEFAULT_IMAGE = "cat.fpx";
     public static final int DEFAULT_RESOLUTION = 3;
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TD rowspan="4" colspan="1"><PRE>     public static void main(String[] args) {
         String imagePath = DEFAULT_IMAGE;
         int resolution = DEFAULT_RESOLUTION;
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD 
  rowspan="11" colspan="1"><PRE>         for(int i = 0; i &lt; args.length; i++) {
             if(args[i].equalsIgnoreCase("-image")) {
                 imagePath = args[++i];
                 if(!(imagePath.toLowerCase().endsWith(".fpx"))) {
                     imagePath += ".fpx";
                 }
             } else if(args[i].equalsIgnoreCase("-res")) {
                 resolution = Integer.valueOf(args[++i]).intValue();
             }
         }
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR 
  valign="top"><TR valign="top"><TR valign="top"><TD rowspan="2" colspan="1"><PRE>         String url = SERVER + "FIF=" + imagePath;
</PRE><TR valign="top"><TR valign="top"><TD rowspan="2" colspan="1"><PRE>         new IIPResolutionTest(url, resolution);
     }
</PRE><TR valign="top"><TR valign="top"><TD rowspan="3" colspan="1"><PRE>     ParameterBlock pb = new ParameterBlock();
     pb.add(url).add(resolution);
     PlanarImage pi = JAI.create("iipresolution", pb);
</PRE><TR valign="top"><TR valign="top">
  <HR>

  <P><PRE>     
</PRE>
  <HR>
  <BR>
  <CENTER><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html"><IMG 
  alt=Contents src="Client-Server Imaging.files/contents.gif"></A> <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Properties.doc.html"><IMG 
  alt=Previous src="Client-Server Imaging.files/previous.gif"></A> <A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html"><IMG 
  alt=Next src="Client-Server Imaging.files/next.gif"></A> 
  <P><FONT size=5><I>Programming in Java Advanced Imaging</I></FONT> 
  </CENTER><BR>
  <H5><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/copyright.html">Copyright</A> 
  &copy; 1999, Sun Microsystems, Inc. All rights reserved.</H5><!-- Last updated: Tue Nov 02 18:08:46 1999 --></BLOCKQUOTE>
<SCRIPT language=JavaScript 
src="Client-Server Imaging.files/s_code_remote.js"></SCRIPT>
</BODY></HTML>

⌨️ 快捷键说明

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