KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > afp > modca > ImageRasterData


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
18 /* $Id: ImageRasterData.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.modca;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import org.apache.fop.render.afp.tools.BinaryUtils;
25
26 /**
27  * Contains the image points that define the IM image raster pattern.
28  *
29  * A raster pattern is the array of presentation device pels that forms
30  * the image. The image data is uncompressed. Bits are grouped into
31  * bytes and are ordered from left to right within each byte. Each bit
32  * in the image data represents an image point and is mapped to
33  * presentation device pels as specified in the IOC structured field.
34  * A bit with value B'1' indicates a significant image point; a bit
35  * with value B'0' indicates an insignificant image point.
36  * Image points are recorded from left to right in rows that represents
37  * scan lines (X direction), and rows representing scan lines are
38  * recorded from top to bottom (Y direction). When the image is
39  * presented, all image points in a row are presented before any
40  * image points in the next sequential row are presented, and all rows
41  * have the same number of image points. If the total number of image
42  * points is not a multiple of 8, the last byte of the image data is
43  * padded to a byte boundary. The padding bits do not represent image
44  * points and are ignored by presentation devices.
45  */

46 public class ImageRasterData extends AbstractAFPObject {
47
48     /**
49      * The image raster data
50      */

51     private byte[] _rasterdata;
52
53     /**
54      * Constructor for the image raster data object
55      * @param rasterdata The raster image data
56      */

57     public ImageRasterData(byte[] rasterdata) {
58
59         _rasterdata = rasterdata;
60
61     }
62
63     /**
64      * Accessor method to write the AFP datastream for the Image Raster Data
65      * @param os The stream to write to
66      * @throws java.io.IOException
67      */

68     public void writeDataStream(OutputStream JavaDoc os)
69         throws IOException JavaDoc {
70
71         byte[] data = new byte[9];
72
73         data[0] = 0x5A;
74
75         // The size of the structured field
76
byte[] x = BinaryUtils.convert(_rasterdata.length + 8, 2);
77         data[1] = x[0];
78         data[2] = x[1];
79
80         data[3] = (byte) 0xD3;
81         data[4] = (byte) 0xEE;
82         data[5] = (byte) 0x7B;
83         data[6] = 0x00;
84         data[7] = 0x00;
85         data[8] = 0x00;
86
87         os.write(data);
88         os.write(_rasterdata);
89
90     }
91
92 }
Popular Tags