001/* 002 * $RCSfile: J2KImageReadParam.java,v $ 003 * 004 * 005 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without 008 * modification, are permitted provided that the following conditions 009 * are met: 010 * 011 * - Redistribution of source code must retain the above copyright 012 * notice, this list of conditions and the following disclaimer. 013 * 014 * - Redistribution in binary form must reproduce the above copyright 015 * notice, this list of conditions and the following disclaimer in 016 * the documentation and/or other materials provided with the 017 * distribution. 018 * 019 * Neither the name of Sun Microsystems, Inc. or the names of 020 * contributors may be used to endorse or promote products derived 021 * from this software without specific prior written permission. 022 * 023 * This software is provided "AS IS," without a warranty of any 024 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 025 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 026 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY 027 * EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL 028 * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 029 * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS 030 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR 031 * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, 032 * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND 033 * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR 034 * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE 035 * POSSIBILITY OF SUCH DAMAGES. 036 * 037 * You acknowledge that this software is not designed or intended for 038 * use in the design, construction, operation or maintenance of any 039 * nuclear facility. 040 * 041 * $Revision: 1.3 $ 042 * $Date: 2006/09/29 19:25:32 $ 043 * $State: Exp $ 044 */ 045package com.github.jaiimageio.jpeg2000; 046 047import javax.imageio.ImageReadParam; 048 049/** 050 * A subclass of <code>ImageReadParam</code> for reading images in 051 * the JPEG 2000 format. 052 * 053 * <p>The decoding parameters for JPEG 2000 are listed below: 054 * 055 * <p><table border=1> 056 * <caption><b>JPEG 2000 Plugin Decoding Parameters</b></caption> 057 * <tr><th>Parameter Name</th> <th>Description</th></tr> 058 * <tr> 059 * <td>decodingRate</td> 060 * <td>Specifies the decoding rate in bits per pixel (bpp) where the 061 * number of pixels is related to the image's original size (Note: 062 * this parameter is not affected by <code>resolution</code>). 063 * The default is <code>Double.MAX_VALUE</code>. 064 * It means decoding with the encoding rate. 065 * </td> 066 * </tr> 067 * <tr> 068 * <td>resolution</td> 069 * <td>Specifies the resolution level wanted for the decoded image 070 * (0 means the lowest available resolution, the resolution 071 * level gives an image with the original dimension). If the given index 072 * is greater than the number of available resolution levels of the 073 * compressed image, the decoded image has the lowest available 074 * resolution (among all tile-components). This parameter affects only 075 * the inverse wavelet transform and not the number of bytes read by the 076 * codestream parser, which depends only on <code>decodingRate</code>. 077 * The default value, -1, means to use the resolution level at encoding. 078 * </td> 079 * </tr> 080 * </table> 081 */ 082public class J2KImageReadParam extends ImageReadParam { 083 /** Specifies the decoding rate in bits per pixel (bpp) where the 084 * number of pixels is related to the image's original size 085 * (Note: this number is not affected by <code>resolution</code>). 086 */ 087 private double decodingRate = Double.MAX_VALUE; 088 089 /** Specifies the resolution level wanted for the decoded image 090 * (0 means the lowest available resolution, the resolution 091 * level gives an image with the original dimension). If the given index 092 * is greater than the number of available resolution levels of the 093 * compressed image, the decoded image has the lowest available 094 * resolution (among all tile-components). This parameter 095 * affects only the inverse wavelet transform but not the number 096 * of bytes read by the codestream parser, which 097 * depends only on <code>decodingRate</code>. 098 */ 099 private int resolution = -1; 100 101 /** Constructs a default instance of <code>J2KImageReadParam</code>. */ 102 public J2KImageReadParam() { 103 super(); 104 } 105 106 /** 107 * Sets <code>decodingRate</code>. 108 * 109 * @param rate the decoding rate in bits per pixel. 110 * @see #getDecodingRate() 111 */ 112 public void setDecodingRate(double rate) { 113 this.decodingRate = rate; 114 } 115 116 /** 117 * Gets <code>decodingRate</code>. 118 * 119 * @return the decoding rate in bits per pixel. 120 * @see #setDecodingRate(double) 121 */ 122 public double getDecodingRate() { 123 return decodingRate; 124 } 125 126 /** 127 * Sets <code>resolution</code>. 128 * 129 * @param resolution the resolution level with 0 being 130 * the lowest available. 131 * @see #getResolution() 132 */ 133 public void setResolution(int resolution) { 134 this.resolution = Math.max(resolution, -1); 135 } 136 137 /** 138 * Gets <code>resolution</code>. 139 * 140 * @return the resolution level with 0 being 141 * the lowest available. 142 * @see #setResolution(int) 143 */ 144 public int getResolution() { 145 return resolution; 146 } 147}