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.

PDFImage.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.pdf;
  18. import java.io.IOException;
  19. import java.io.OutputStream;
  20. /**
  21. * Interface for a PDF image.
  22. * This is used for inserting an image into PDF.
  23. */
  24. public interface PDFImage {
  25. /**
  26. * Key to look up XObject.
  27. * This should be a unique key to refer to the image.
  28. *
  29. * @return the key for this image
  30. */
  31. String getKey();
  32. /**
  33. * Setup the PDF image for the current document.
  34. * Some image formats may need to access the document (for example to
  35. * add an ICC profile to the document).
  36. *
  37. * @param doc the PDF parent document
  38. * (todo) Remove this and delegate to the XObject
  39. */
  40. void setup(PDFDocument doc);
  41. /**
  42. * Get the image width in pixels.
  43. *
  44. * @return the image width
  45. */
  46. int getWidth();
  47. /**
  48. * Get the image height in pixels.
  49. *
  50. * @return the image height
  51. */
  52. int getHeight();
  53. /**
  54. * Get the color space for this image.
  55. * Possible results are: DeviceGray, DeviceRGB, or DeviceCMYK
  56. *
  57. * @return the color space
  58. */
  59. PDFColorSpace getColorSpace();
  60. /**
  61. * Get the bits per pixel for this image.
  62. *
  63. * @return the bits per pixel
  64. */
  65. int getBitsPerPixel();
  66. /**
  67. * Check if this image is a PostScript image.
  68. *
  69. * @return true if this is a PostScript image
  70. */
  71. boolean isPS();
  72. /**
  73. * Check if this image is a DCT encoded image (for JPEG images).
  74. *
  75. * @return true if this is a DCT image
  76. */
  77. boolean isDCT();
  78. /**
  79. * Check if this image has a transparent color transparency.
  80. *
  81. * @return true if it has transparency
  82. */
  83. boolean isTransparent();
  84. /**
  85. * Get the transparent color.
  86. *
  87. * @return the transparent color for this image
  88. */
  89. PDFColor getTransparentColor();
  90. /**
  91. * Get the PDF reference for a bitmap mask.
  92. *
  93. * @return the PDF reference for the mask image
  94. */
  95. String getMask();
  96. /**
  97. * Get the PDF reference for a soft mask.
  98. *
  99. * @return the PDF reference for a soft mask image
  100. */
  101. String getSoftMask();
  102. // get the image bytes, and bytes properties
  103. /**
  104. * Writes the raw, unencoded contents of the image to a given output stream.
  105. *
  106. * @param out OutputStream to write to
  107. * @throws IOException if there creating stream
  108. */
  109. void outputContents(OutputStream out) throws IOException;
  110. /**
  111. * Get the ICC stream for this image.
  112. *
  113. * @return the ICC stream for this image if any
  114. */
  115. PDFICCStream getICCStream();
  116. /**
  117. * Returns a hint in form of a String (Possible values from PDFFilterList)
  118. * indicating which filter setup should be used to encode the object.
  119. * @return the filter setup hint
  120. */
  121. String getFilterHint();
  122. }