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.6KB

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