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 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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.image;
  19. import java.io.InputStream;
  20. import java.awt.color.ColorSpace;
  21. import java.awt.color.ICC_Profile;
  22. import java.awt.Color;
  23. import org.apache.fop.datatypes.Length;
  24. /**
  25. * Fop image interface for loading images.
  26. */
  27. public interface FopImage {
  28. /**
  29. * Flag for loading dimensions.
  30. */
  31. int DIMENSIONS = 1;
  32. /**
  33. * Flag for loading original data.
  34. */
  35. int ORIGINAL_DATA = 2;
  36. /**
  37. * Flag for loading bitmap data.
  38. */
  39. int BITMAP = 4;
  40. /**
  41. * Get the mime type of this image.
  42. * This is used so that when reading from the image it knows
  43. * what type of image it is.
  44. *
  45. * @return the mime type string
  46. */
  47. String getMimeType();
  48. /** @return the original URI used to access this image. */
  49. String getOriginalURI();
  50. /**
  51. * Load particular inforamtion for this image
  52. * This must be called before attempting to get
  53. * the information.
  54. *
  55. * @param type the type of loading required
  56. * @return boolean true if the information could be loaded
  57. */
  58. boolean load(int type);
  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. * @return the intrinsic image width (in millipoints)
  71. */
  72. int getIntrinsicWidth();
  73. /**
  74. * @return the intrinsic image width (in millipoints)
  75. */
  76. int getIntrinsicHeight();
  77. /**
  78. * @return the intrinsic alignment-adjust value or NULL if the image does
  79. * not have one.
  80. */
  81. Length getIntrinsicAlignmentAdjust();
  82. /**
  83. * @return the horizontal bitmap resolution (in dpi)
  84. */
  85. double getHorizontalResolution();
  86. /**
  87. * @return the vertical bitmap resolution (in dpi)
  88. */
  89. double getVerticalResolution();
  90. /**
  91. * Returns the color space of the image.
  92. * @return the color space
  93. */
  94. ColorSpace getColorSpace();
  95. /**
  96. * Returns the ICC profile.
  97. * @return the ICC profile, null if none is available
  98. */
  99. ICC_Profile getICCProfile();
  100. /**
  101. * Returns the number of bits per pixel for the image.
  102. * @return the number of bits per pixel
  103. */
  104. int getBitsPerPixel();
  105. /**
  106. * Indicates whether the image is transparent.
  107. * @return True if it is transparent
  108. */
  109. boolean isTransparent();
  110. /**
  111. * For transparent images. Returns the transparent color.
  112. * @return the transparent color
  113. */
  114. Color getTransparentColor();
  115. /**
  116. * Indicates whether the image has a Soft Mask (See section 7.5.4 in the
  117. * PDF specs)
  118. * @return True if a Soft Mask exists
  119. */
  120. boolean hasSoftMask();
  121. /**
  122. * For images with a Soft Mask. Returns the Soft Mask as an array.
  123. * @return the Soft Mask
  124. */
  125. byte[] getSoftMask();
  126. /** @return true for CMYK images generated by Adobe Photoshop */
  127. boolean isInverted();
  128. /**
  129. * Returns the decoded and uncompressed image as a array of
  130. * width * height * [colorspace-multiplicator] pixels.
  131. * @return the bitmap
  132. */
  133. byte[] getBitmaps();
  134. /**
  135. * Returns the size of the image.
  136. * width * (bitsPerPixel / 8) * height, no ?
  137. * @return the size
  138. */
  139. int getBitmapsSize();
  140. /**
  141. * Returns the encoded/compressed image as an array of bytes.
  142. * @return the raw image
  143. */
  144. byte[] getRessourceBytes();
  145. /**
  146. * Returns the number of bytes of the raw image.
  147. * @return the size in bytes
  148. */
  149. int getRessourceBytesSize();
  150. /**
  151. * Image info class.
  152. * Information loaded from analyser and passed to image object.
  153. */
  154. public static class ImageInfo {
  155. /** InputStream to load the image from */
  156. public InputStream inputStream;
  157. /** Original URI the image was accessed with */
  158. public String originalURI;
  159. /** image width (in pixels) */
  160. public int width;
  161. /** image height (in pixels) */
  162. public int height;
  163. /** horizontal bitmap resolution (in dpi) */
  164. public double dpiHorizontal = 72.0f;
  165. /** vertical bitmap resolution (in dpi) */
  166. public double dpiVertical = 72.0f;
  167. /** implementation-specific data object (ex. a SVG DOM for SVG images) */
  168. public Object data;
  169. /** MIME type of the image */
  170. public String mimeType;
  171. /** implementation-specific String (ex. the namespace for XML-based images) */
  172. public String str;
  173. /** intrinsic alignment-adjust or null if there is none */
  174. public Length alignmentAdjust;
  175. }
  176. }