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.

ImageRasterData.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * Contains the image points that define the IM image raster pattern.
  25. *
  26. * A raster pattern is the array of presentation device pels that forms
  27. * the image. The image data is uncompressed. Bits are grouped into
  28. * bytes and are ordered from left to right within each byte. Each bit
  29. * in the image data represents an image point and is mapped to
  30. * presentation device pels as specified in the IOC structured field.
  31. * A bit with value B'1' indicates a significant image point; a bit
  32. * with value B'0' indicates an insignificant image point.
  33. * Image points are recorded from left to right in rows that represents
  34. * scan lines (X direction), and rows representing scan lines are
  35. * recorded from top to bottom (Y direction). When the image is
  36. * presented, all image points in a row are presented before any
  37. * image points in the next sequential row are presented, and all rows
  38. * have the same number of image points. If the total number of image
  39. * points is not a multiple of 8, the last byte of the image data is
  40. * padded to a byte boundary. The padding bits do not represent image
  41. * points and are ignored by presentation devices.
  42. */
  43. public class ImageRasterData extends AbstractAFPObject {
  44. /** the image raster data */
  45. private final byte[] rasterData;
  46. /**
  47. * Constructor for the image raster data object
  48. *
  49. * @param data The raster image data
  50. */
  51. public ImageRasterData(byte[] data) {
  52. this.rasterData = data;
  53. }
  54. /** {@inheritDoc} */
  55. public void writeToStream(OutputStream os) throws IOException {
  56. byte[] data = new byte[9];
  57. copySF(data, Type.DATA, Category.IM_IMAGE);
  58. // The size of the structured field
  59. byte[] len = BinaryUtils.convert(rasterData.length + 8, 2);
  60. data[1] = len[0];
  61. data[2] = len[1];
  62. os.write(data);
  63. os.write(rasterData);
  64. }
  65. }