001/* 002 * $RCSfile: J2KImageReadParamJava.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.1 $ 042 * $Date: 2005/02/11 05:01:33 $ 043 * $State: Exp $ 044 */ 045package com.github.jaiimageio.jpeg2000.impl; 046 047import javax.imageio.ImageReadParam; 048 049import com.github.jaiimageio.jpeg2000.J2KImageReadParam; 050/** 051 * A subclass of <code>ImageReadParam</code> for reading images in 052 * the JPEG 2000 format. 053 * 054 * <p>The decoding parameters for JPEG 2000 are listed below: 055 * 056 * <p><table border=1> 057 * <caption><b>JPEG 2000 Plugin Decoding Parameters</b></caption> 058 * <tr><th>Parameter Name</th> <th>Description</th></tr> 059 * <tr> 060 * <td>decodingRate</td> 061 * <td>Specifies the decoding rate in bits per pixel (bpp) where the 062 * number of pixels is related to the image's original size (Note: 063 * this parameter is not affected by <code>resolution</code>). The 064 * codestream is either parsed (default) or truncated depending 065 * <code>parsingEnabled</code>. The default is <code>Double.MAX_VALUE</code>. 066 * It means decoding with the encoding rate. 067 * </td> 068 * </tr> 069 * <tr> 070 * <td>resolution</td> 071 * <td>Specifies the resolution level wanted for the decoded image 072 * (0 means the lowest available resolution, the resolution 073 * level gives an image with the original dimension). If the given index 074 * is greater than the number of available resolution levels of the 075 * compressed image, the decoded image has the lowest available 076 * resolution (among all tile-components). This parameter affects only 077 * the inverse wavelet transform and not the number of bytes read by the 078 * codestream parser, which depends only on <code>decodingRate</code>. 079 * </td> 080 * </tr> 081 * <tr> 082 * <td>noROIDescaling</td> 083 * <td>Ensures that no ROI de-scaling is performed. Decompression is done 084 * like there is no ROI in the image. 085 * </td> 086 * </tr> 087 * <tr> 088 * <td>parsingEnabled</td> 089 * <td>Enable the parsing mode or not when the decoding rate is specified. 090 * If it is false, the codestream is decoded as if it were truncated to 091 * the given rate. If it is true, the decoder creates, truncates and 092 * decodes a virtual layer progressive codestream with the same 093 * truncation points in each code-block. 094 * </td> 095 * </tr> 096 * </table> 097 */ 098public class J2KImageReadParamJava extends J2KImageReadParam { 099 100 /** Ensures that no ROI de-scaling is performed. Decompression 101 * is done like there is no ROI in the image. 102 */ 103 private boolean noROIDescaling = true; 104 105 /** Enable the parsing mode or not when the decoding rate is specified . 106 * If it is false, the codestream is decoded as if it were truncated to 107 * the given rate. If it is true, the decoder creates, truncates and 108 * decodes a virtual layer progressive codestream with the same 109 * truncation points in each code-block. 110 */ 111 private boolean parsingEnabled = true; 112 113 /** Constructs a default instance of <code>J2KImageReadParamJava</code>. */ 114 public J2KImageReadParamJava() { 115 super(); 116 } 117 118 public J2KImageReadParamJava(ImageReadParam param) { 119 super(); 120 121 // Generic settings. 122 if(param.hasController()) { 123 setController(param.getController()); 124 } 125 setSourceRegion(param.getSourceRegion()); 126 setSourceBands(param.getSourceBands()); 127 setDestinationBands(param.getDestinationBands()); 128 setDestination(param.getDestination()); 129 130 setDestinationOffset(param.getDestinationOffset()); 131 setSourceSubsampling(param.getSourceXSubsampling(), 132 param.getSourceYSubsampling(), 133 param.getSubsamplingXOffset(), 134 param.getSubsamplingYOffset()); 135 setDestinationType(param.getDestinationType()); 136 137 // J2K settings. 138 J2KImageReadParam j2kParam; 139 if(param instanceof J2KImageReadParam) { 140 j2kParam = (J2KImageReadParam)param; 141 } else { 142 j2kParam = new J2KImageReadParam(); 143 } 144 setDecodingRate(j2kParam.getDecodingRate()); 145 setResolution(j2kParam.getResolution()); 146 } 147 148 /** Sets <code>noROIDescaling</code> */ 149 public void setNoROIDescaling(boolean value) { 150 this.noROIDescaling = value; 151 } 152 153 /** Gets <code>noROIDescaling</code> */ 154 public boolean getNoROIDescaling() { 155 return noROIDescaling; 156 } 157 158 /** Sets <code>parsingEnabled</code> */ 159 public void setParsingEnabled(boolean value) { 160 this.parsingEnabled = value; 161 } 162 163 /** Gets <code>parsingEnabled</code> */ 164 public boolean getParsingEnabled() { 165 return parsingEnabled; 166 } 167}