Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ImageDataDescriptor.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright 2006 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.render.afp.modca;
  18. import java.io.IOException;
  19. import java.io.OutputStream;
  20. import org.apache.fop.render.afp.tools.BinaryUtils;
  21. /**
  22. */
  23. public class ImageDataDescriptor extends AbstractAFPObject {
  24. private int _xresol = 0;
  25. private int _yresol = 0;
  26. private int _width = 0;
  27. private int _height = 0;
  28. /**
  29. * Constructor for a ImageDataDescriptor for the specified
  30. * resolution, width and height.
  31. * @param xresol The horizontal resolution of the image.
  32. * @param yresol The vertical resolution of the image.
  33. * @param width The width of the image.
  34. * @param height The height of the height.
  35. */
  36. public ImageDataDescriptor(int xresol, int yresol, int width, int height) {
  37. _xresol = xresol;
  38. _yresol = yresol;
  39. _width = width;
  40. _height = height;
  41. }
  42. /**
  43. * Accessor method to write the AFP datastream for the Image Data Descriptor
  44. * @param os The stream to write to
  45. * @throws java.io.IOException
  46. */
  47. public void writeDataStream(OutputStream os)
  48. throws IOException {
  49. byte[] data = new byte[] {
  50. 0x5A,
  51. 0x00,
  52. 0x20,
  53. (byte) 0xD3,
  54. (byte) 0xA6,
  55. (byte) 0xFB,
  56. 0x00, // Flags
  57. 0x00, // Reserved
  58. 0x00, // Reserved
  59. 0x00, // Unit base - 10 Inches
  60. 0x00, // XRESOL
  61. 0x00, //
  62. 0x00, // YRESOL
  63. 0x00, //
  64. 0x00, // XSIZE
  65. 0x00, //
  66. 0x00, // YSIZE
  67. 0x00, //
  68. (byte)0xF7, // ID = Set IOCA Function Set
  69. 0x02, // Length
  70. 0x01, // Category = Function set identifier
  71. 0x0B, // FCNSET = IOCA FS 11
  72. };
  73. byte[] l = BinaryUtils.convert(data.length - 1, 2);
  74. data[1] = l[0];
  75. data[2] = l[1];
  76. byte[] x = BinaryUtils.convert(_xresol, 2);
  77. data[10] = x[0];
  78. data[11] = x[1];
  79. byte[] y = BinaryUtils.convert(_yresol, 2);
  80. data[12] = y[0];
  81. data[13] = y[1];
  82. byte[] w = BinaryUtils.convert(_width, 2);
  83. data[14] = w[0];
  84. data[15] = w[1];
  85. byte[] h = BinaryUtils.convert(_height, 2);
  86. data[16] = h[0];
  87. data[17] = h[1];
  88. os.write(data);
  89. }
  90. }