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.

EPSImage.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /**
  20. * EPS image handler.
  21. * This handles the Encapulated PostScript images.
  22. * It gets the dimensions and original data from the analyser.
  23. *
  24. * @see AbstractFopImage
  25. * @see FopImage
  26. */
  27. public class EPSImage extends AbstractFopImage {
  28. private String docName;
  29. private int[] bbox;
  30. private EPSData epsData = null;
  31. /**
  32. * Create an EPS image with the image information.
  33. *
  34. * @param imgInfo the information containing the data and bounding box
  35. */
  36. public EPSImage(FopImage.ImageInfo imgInfo) {
  37. super(imgInfo);
  38. init("");
  39. if (imgInfo.data instanceof EPSData) {
  40. epsData = (EPSData) imgInfo.data;
  41. bbox = new int[4];
  42. bbox[0] = (int) epsData.bbox[0];
  43. bbox[1] = (int) epsData.bbox[1];
  44. bbox[2] = (int) epsData.bbox[2];
  45. bbox[3] = (int) epsData.bbox[3];
  46. loaded = loaded | ORIGINAL_DATA;
  47. }
  48. }
  49. /**
  50. * Initialize docName and bounding box.
  51. * @param name the document name
  52. */
  53. private void init(String name) {
  54. bbox = new int[4];
  55. bbox[0] = 0;
  56. bbox[1] = 0;
  57. bbox[2] = 0;
  58. bbox[3] = 0;
  59. docName = name;
  60. }
  61. /**
  62. * Return the name of the eps
  63. * @return the name of the eps
  64. */
  65. public String getDocName() {
  66. return docName;
  67. }
  68. /**
  69. * Return the bounding box
  70. * @return an int array containing the bounding box
  71. */
  72. public int[] getBBox() {
  73. return bbox;
  74. }
  75. /**
  76. * Get the eps image.
  77. *
  78. * @return the original eps image data
  79. */
  80. public byte[] getEPSImage() {
  81. if (epsData.epsFile == null) {
  82. //log.error("ERROR LOADING EXTERNAL EPS");
  83. }
  84. return epsData.epsFile;
  85. }
  86. /**
  87. * Data for EPS image.
  88. */
  89. public static class EPSData {
  90. public long[] bbox;
  91. public boolean isAscii; // True if plain ascii eps file
  92. // offsets if not ascii
  93. public long psStart = 0;
  94. public long psLength = 0;
  95. public long wmfStart = 0;
  96. public long wmfLength = 0;
  97. public long tiffStart = 0;
  98. public long tiffLength = 0;
  99. /** raw eps file */
  100. public byte[] rawEps;
  101. /** eps part */
  102. public byte[] epsFile;
  103. public byte[] preview = null;
  104. }
  105. }