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.

FopImage.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.image;
  18. import java.io.InputStream;
  19. import java.awt.color.ColorSpace;
  20. import java.awt.color.ICC_Profile;
  21. import java.awt.Color;
  22. import org.apache.avalon.framework.logger.Logger;
  23. /**
  24. * Fop image interface for loading images.
  25. *
  26. * @author Eric SCHAEFFER
  27. */
  28. public interface FopImage {
  29. /**
  30. * Flag for loading dimensions.
  31. */
  32. public static final int DIMENSIONS = 1;
  33. /**
  34. * Flag for loading original data.
  35. */
  36. public static final int ORIGINAL_DATA = 2;
  37. /**
  38. * Flag for loading bitmap data.
  39. */
  40. public static final int BITMAP = 4;
  41. /**
  42. * Get the mime type of this image.
  43. * This is used so that when reading from the image it knows
  44. * what type of image it is.
  45. *
  46. * @return the mime type string
  47. */
  48. String getMimeType();
  49. /**
  50. * Load particular inforamtion for this image
  51. * This must be called before attempting to get
  52. * the information.
  53. *
  54. * @param type the type of loading required
  55. * @param logger the Avalon logger
  56. * @return boolean true if the information could be loaded
  57. */
  58. boolean load(int type, Logger logger);
  59. /**
  60. * Returns the image width.
  61. * @return the width in pixels
  62. */
  63. int getWidth();
  64. /**
  65. * Returns the image height.
  66. * @return the height in pixels
  67. */
  68. int getHeight();
  69. /**
  70. * Returns the color space of the image.
  71. * @return the color space
  72. */
  73. ColorSpace getColorSpace();
  74. /**
  75. * Returns the ICC profile.
  76. * @return the ICC profile, null if none is available
  77. */
  78. ICC_Profile getICCProfile();
  79. /**
  80. * Returns the number of bits per pixel for the image.
  81. * @return the number of bits per pixel
  82. */
  83. int getBitsPerPixel();
  84. /**
  85. * Indicates whether the image is transparent.
  86. * @return True if it is transparent
  87. */
  88. boolean isTransparent();
  89. /**
  90. * For transparent images. Returns the transparent color.
  91. * @return the transparent color
  92. */
  93. Color getTransparentColor();
  94. /**
  95. * Indicates whether the image has a Soft Mask (See section 7.5.4 in the
  96. * PDF specs)
  97. * @return True if a Soft Mask exists
  98. */
  99. boolean hasSoftMask();
  100. /**
  101. * For images with a Soft Mask. Returns the Soft Mask as an array.
  102. * @return the Soft Mask
  103. */
  104. byte[] getSoftMask();
  105. /**
  106. * Returns the decoded and uncompressed image as a array of
  107. * width * height * [colorspace-multiplicator] pixels.
  108. * @return the bitmap
  109. */
  110. byte[] getBitmaps();
  111. /**
  112. * Returns the size of the image.
  113. * width * (bitsPerPixel / 8) * height, no ?
  114. * @return the size
  115. */
  116. int getBitmapsSize();
  117. /**
  118. * Returns the encoded/compressed image as an array of bytes.
  119. * @return the raw image
  120. */
  121. byte[] getRessourceBytes();
  122. /**
  123. * Returns the number of bytes of the raw image.
  124. * @return the size in bytes
  125. */
  126. int getRessourceBytesSize();
  127. /**
  128. * Image info class.
  129. * Information loaded from analyser and passed to image object.
  130. */
  131. public static class ImageInfo {
  132. public InputStream inputStream;
  133. public int width;
  134. public int height;
  135. public Object data;
  136. public String mimeType;
  137. public String str;
  138. }
  139. }