You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TIFFCompressionValue.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render.bitmap;
  19. import java.awt.image.BufferedImage;
  20. /**
  21. * Compression constants for TIFF image output.
  22. */
  23. public enum TIFFCompressionValue {
  24. /** No compression */
  25. NONE("NONE"),
  26. /** JPEG compression */
  27. JPEG("JPEG"),
  28. /** Packbits (RLE) compression */
  29. PACKBITS("PackBits"),
  30. /** Deflate compression */
  31. DEFLATE("Deflate"),
  32. /** LZW compression */
  33. LZW("LZW"),
  34. /** ZLib compression */
  35. ZLIB("ZLib"),
  36. /** CCITT Group 3 (T.4) compression */
  37. CCITT_T4("CCITT T.4", BufferedImage.TYPE_BYTE_BINARY, true),
  38. /** CCITT Group 4 (T.6) compression */
  39. CCITT_T6("CCITT T.6", BufferedImage.TYPE_BYTE_BINARY, true);
  40. private final String name;
  41. private final int imageType;
  42. private boolean isCcitt;
  43. private TIFFCompressionValue(String name, int imageType, boolean isCcitt) {
  44. this.name = name;
  45. this.imageType = imageType;
  46. this.isCcitt = isCcitt;
  47. }
  48. private TIFFCompressionValue(String name) {
  49. this(name, BufferedImage.TYPE_INT_ARGB, false);
  50. }
  51. /**
  52. * Returns the name of this compression type.
  53. * @return the compression name
  54. */
  55. String getName() {
  56. return name;
  57. }
  58. /**
  59. * Returns an image type for this compression type, a constant from {@link BufferedImage} e.g.
  60. * {@link BufferedImage#TYPE_INT_ARGB} for {@link #ZLIB}
  61. * @return the image type
  62. */
  63. int getImageType() {
  64. return imageType;
  65. }
  66. /**
  67. * Returns whether or not this compression type is a CCITT type.
  68. * @return true if the compression type is CCITT
  69. */
  70. boolean hasCCITTCompression() {
  71. return isCcitt;
  72. }
  73. /**
  74. * Return the TIFF compression constant given the string representing the type. In the case that
  75. * the name doesn't match any of the compression values, <code>null</code> is returned.
  76. * @param name the compression type name
  77. * @return the compression constant
  78. */
  79. static TIFFCompressionValue getType(String name) {
  80. for (TIFFCompressionValue tiffConst : TIFFCompressionValue.values()) {
  81. if (tiffConst.name.equalsIgnoreCase(name)) {
  82. return tiffConst;
  83. }
  84. }
  85. return null;
  86. }
  87. }