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.

ImageSizeParameter.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * Describes the measurement characteristics of the image when it is created.
  23. */
  24. public class ImageSizeParameter extends AbstractAFPObject {
  25. private int _hresol = 0;
  26. private int _vresol = 0;
  27. private int _hsize = 0;
  28. private int _vsize = 0;
  29. /**
  30. * Constructor for a ImageSizeParameter for the specified
  31. * resolution, hsize and vsize.
  32. * @param hresol The horizontal resolution of the image.
  33. * @param vresol The vertical resolution of the image.
  34. * @param hsize The hsize of the image.
  35. * @param vsize The vsize of the vsize.
  36. */
  37. public ImageSizeParameter(int hresol, int vresol, int hsize, int vsize) {
  38. _hresol = hresol;
  39. _vresol = vresol;
  40. _hsize = hsize;
  41. _vsize = vsize;
  42. }
  43. /**
  44. * Accessor method to write the AFP datastream for the Image Size Parameter
  45. * @param os The stream to write to
  46. * @throws java.io.IOException
  47. */
  48. public void writeDataStream(OutputStream os)
  49. throws IOException {
  50. byte[] data = new byte[] {
  51. (byte)0x94, // ID = Image Size Parameter
  52. 0x09, // Length
  53. 0x00, // Unit base - 10 Inches
  54. 0x00, // HRESOL
  55. 0x00, //
  56. 0x00, // VRESOL
  57. 0x00, //
  58. 0x00, // HSIZE
  59. 0x00, //
  60. 0x00, // VSIZE
  61. 0x00, //
  62. };
  63. byte[] x = BinaryUtils.convert(_hresol, 2);
  64. data[3] = x[0];
  65. data[4] = x[1];
  66. byte[] y = BinaryUtils.convert(_vresol, 2);
  67. data[5] = y[0];
  68. data[6] = y[1];
  69. byte[] w = BinaryUtils.convert(_hsize, 2);
  70. data[7] = w[0];
  71. data[8] = w[1];
  72. byte[] h = BinaryUtils.convert(_vsize, 2);
  73. data[9] = h[0];
  74. data[10] = h[1];
  75. os.write(data);
  76. }
  77. }