OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C)2011, 2013 D. R. Commander. All Rights Reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are met: |
| 6 * |
| 7 * - Redistributions of source code must retain the above copyright notice, |
| 8 * this list of conditions and the following disclaimer. |
| 9 * - Redistributions in binary form must reproduce the above copyright notice, |
| 10 * this list of conditions and the following disclaimer in the documentation |
| 11 * and/or other materials provided with the distribution. |
| 12 * - Neither the name of the libjpeg-turbo Project nor the names of its |
| 13 * contributors may be used to endorse or promote products derived from this |
| 14 * software without specific prior written permission. |
| 15 * |
| 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", |
| 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
| 28 |
| 29 package org.libjpegturbo.turbojpeg; |
| 30 |
| 31 import java.awt.*; |
| 32 |
| 33 /** |
| 34 * Lossless transform parameters |
| 35 */ |
| 36 public class TJTransform extends Rectangle { |
| 37 |
| 38 private static final long serialVersionUID = -127367705761430371L; |
| 39 |
| 40 /** |
| 41 * The number of lossless transform operations |
| 42 */ |
| 43 public static final int NUMOP = 8; |
| 44 /** |
| 45 * Do not transform the position of the image pixels. |
| 46 */ |
| 47 public static final int OP_NONE = 0; |
| 48 /** |
| 49 * Flip (mirror) image horizontally. This transform is imperfect if there |
| 50 * are any partial MCU blocks on the right edge. |
| 51 * @see #OPT_PERFECT |
| 52 */ |
| 53 public static final int OP_HFLIP = 1; |
| 54 /** |
| 55 * Flip (mirror) image vertically. This transform is imperfect if there are |
| 56 * any partial MCU blocks on the bottom edge. |
| 57 * @see #OPT_PERFECT |
| 58 */ |
| 59 public static final int OP_VFLIP = 2; |
| 60 /** |
| 61 * Transpose image (flip/mirror along upper left to lower right axis). This |
| 62 * transform is always perfect. |
| 63 * @see #OPT_PERFECT |
| 64 */ |
| 65 public static final int OP_TRANSPOSE = 3; |
| 66 /** |
| 67 * Transverse transpose image (flip/mirror along upper right to lower left |
| 68 * axis). This transform is imperfect if there are any partial MCU blocks in |
| 69 * the image. |
| 70 * @see #OPT_PERFECT |
| 71 */ |
| 72 public static final int OP_TRANSVERSE = 4; |
| 73 /** |
| 74 * Rotate image clockwise by 90 degrees. This transform is imperfect if |
| 75 * there are any partial MCU blocks on the bottom edge. |
| 76 * @see #OPT_PERFECT |
| 77 */ |
| 78 public static final int OP_ROT90 = 5; |
| 79 /** |
| 80 * Rotate image 180 degrees. This transform is imperfect if there are any |
| 81 * partial MCU blocks in the image. |
| 82 * @see #OPT_PERFECT |
| 83 */ |
| 84 public static final int OP_ROT180 = 6; |
| 85 /** |
| 86 * Rotate image counter-clockwise by 90 degrees. This transform is imperfect |
| 87 * if there are any partial MCU blocks on the right edge. |
| 88 * @see #OPT_PERFECT |
| 89 */ |
| 90 public static final int OP_ROT270 = 7; |
| 91 |
| 92 |
| 93 /** |
| 94 * This option will cause {@link TJTransformer#transform |
| 95 * TJTransformer.transform()} to throw an exception if the transform is not |
| 96 * perfect. Lossless transforms operate on MCU blocks, whose size depends on |
| 97 * the level of chrominance subsampling used. If the image's width or height |
| 98 * is not evenly divisible by the MCU block size (see {@link TJ#getMCUWidth} |
| 99 * and {@link TJ#getMCUHeight}), then there will be partial MCU blocks on the |
| 100 * right and/or bottom edges. It is not possible to move these partial MCU |
| 101 * blocks to the top or left of the image, so any transform that would |
| 102 * require that is "imperfect." If this option is not specified, then any |
| 103 * partial MCU blocks that cannot be transformed will be left in place, which |
| 104 * will create odd-looking strips on the right or bottom edge of the image. |
| 105 */ |
| 106 public static final int OPT_PERFECT = 1; |
| 107 /** |
| 108 * This option will discard any partial MCU blocks that cannot be |
| 109 * transformed. |
| 110 */ |
| 111 public static final int OPT_TRIM = 2; |
| 112 /** |
| 113 * This option will enable lossless cropping. |
| 114 */ |
| 115 public static final int OPT_CROP = 4; |
| 116 /** |
| 117 * This option will discard the color data in the input image and produce |
| 118 * a grayscale output image. |
| 119 */ |
| 120 public static final int OPT_GRAY = 8; |
| 121 /** |
| 122 * This option will prevent {@link TJTransformer#transform |
| 123 * TJTransformer.transform()} from outputting a JPEG image for this |
| 124 * particular transform. This can be used in conjunction with a custom |
| 125 * filter to capture the transformed DCT coefficients without transcoding |
| 126 * them. |
| 127 */ |
| 128 public static final int OPT_NOOUTPUT = 16; |
| 129 |
| 130 |
| 131 /** |
| 132 * Create a new lossless transform instance. |
| 133 */ |
| 134 public TJTransform() { |
| 135 } |
| 136 |
| 137 /** |
| 138 * Create a new lossless transform instance with the given parameters. |
| 139 * |
| 140 * @param x the left boundary of the cropping region. This must be evenly |
| 141 * divisible by the MCU block width (see {@link TJ#getMCUWidth}) |
| 142 * |
| 143 * @param y the upper boundary of the cropping region. This must be evenly |
| 144 * divisible by the MCU block height (see {@link TJ#getMCUHeight}) |
| 145 * |
| 146 * @param w the width of the cropping region. Setting this to 0 is the |
| 147 * equivalent of setting it to (width of the source JPEG image - |
| 148 * <code>x</code>). |
| 149 * |
| 150 * @param h the height of the cropping region. Setting this to 0 is the |
| 151 * equivalent of setting it to (height of the source JPEG image - |
| 152 * <code>y</code>). |
| 153 * |
| 154 * @param op one of the transform operations (<code>OP_*</code>) |
| 155 * |
| 156 * @param options the bitwise OR of one or more of the transform options |
| 157 * (<code>OPT_*</code>) |
| 158 * |
| 159 * @param cf an instance of an object that implements the {@link |
| 160 * TJCustomFilter} interface, or null if no custom filter is needed |
| 161 */ |
| 162 public TJTransform(int x, int y, int w, int h, int op, int options, |
| 163 TJCustomFilter cf) { |
| 164 super(x, y, w, h); |
| 165 this.op = op; |
| 166 this.options = options; |
| 167 this.cf = cf; |
| 168 } |
| 169 |
| 170 /** |
| 171 * Create a new lossless transform instance with the given parameters. |
| 172 * |
| 173 * @param r a <code>Rectangle</code> instance that specifies the cropping |
| 174 * region. See {@link |
| 175 * #TJTransform(int, int, int, int, int, int, TJCustomFilter)} for more |
| 176 * detail. |
| 177 * |
| 178 * @param op one of the transform operations (<code>OP_*</code>) |
| 179 * |
| 180 * @param options the bitwise OR of one or more of the transform options |
| 181 * (<code>OPT_*</code>) |
| 182 * |
| 183 * @param cf an instance of an object that implements the {@link |
| 184 * TJCustomFilter} interface, or null if no custom filter is needed |
| 185 */ |
| 186 public TJTransform(Rectangle r, int op, int options, |
| 187 TJCustomFilter cf) { |
| 188 super(r); |
| 189 this.op = op; |
| 190 this.options = options; |
| 191 this.cf = cf; |
| 192 } |
| 193 |
| 194 /** |
| 195 * Transform operation (one of <code>OP_*</code>) |
| 196 */ |
| 197 public int op = 0; |
| 198 |
| 199 /** |
| 200 * Transform options (bitwise OR of one or more of <code>OPT_*</code>) |
| 201 */ |
| 202 public int options = 0; |
| 203 |
| 204 /** |
| 205 * Custom filter instance |
| 206 */ |
| 207 public TJCustomFilter cf = null; |
| 208 } |
OLD | NEW |