KickJava   Java API By Example, From Geeks To Geeks.

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


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: ImageInputDescriptor.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  * The IM Image Input Descriptor structured field contains the
28  * descriptor data for an IM image data object. This data specifies
29  * the resolution, size, and color of the IM image.
30  */

31 public class ImageInputDescriptor extends AbstractAFPObject {
32
33     /**
34      * The resolution of the raster image (default 240)
35      */

36     private int _resolution = 240;
37
38
39     /**
40      * Accessor method to write the AFP datastream for the Image Input Descriptor
41      * @param os The stream to write to
42      * @throws java.io.IOException
43      */

44     public void writeDataStream(OutputStream JavaDoc os)
45         throws IOException JavaDoc {
46
47         byte[] data = new byte[45];
48
49         data[0] = 0x5A;
50         data[1] = 0x00;
51         data[2] = 0x2C;
52         data[3] = (byte) 0xD3;
53         data[4] = (byte) 0xA6;
54         data[5] = (byte) 0x7B;
55         data[6] = 0x00;
56         data[7] = 0x00;
57         data[8] = 0x00;
58
59         // Constant data.
60
data[9] = 0x00;
61         data[10] = 0x00;
62         data[11] = 0x09;
63         data[12] = 0x60;
64         data[13] = 0x09;
65         data[14] = 0x60;
66         data[15] = 0x00;
67         data[16] = 0x00;
68         data[17] = 0x00;
69         data[18] = 0x00;
70         data[19] = 0x00;
71         data[20] = 0x00;
72
73         // X Base (Fixed x00)
74
data[21] = 0x00;
75         // Y Base (Fixed x00)
76
data[22] = 0x00;
77
78         byte[] imagepoints = BinaryUtils.convert(_resolution * 10, 2);
79
80         /**
81          * Specifies the number of image points per unit base for the X axis
82          * of the image. This value is ten times the resolution of the image
83          * in the X direction.
84          */

85         data[23] = imagepoints[0];
86         data[24] = imagepoints[1];
87
88         /**
89          * Specifies the number of image points per unit base for the Y axis
90          * of the image. This value is ten times the resolution of the image
91          * in the Y direction.
92          */

93         data[25] = imagepoints[0];
94         data[26] = imagepoints[1];
95
96         /**
97          * Specifies the extent in the X direction, in image points, of an
98          * non-celled (simple) image.
99          */

100         data[27] = 0x00;
101         data[28] = 0x01;
102
103         /**
104          * Specifies the extent in the Y direction, in image points, of an
105          * non-celled (simple) image.
106          */

107         data[29] = 0x00;
108         data[30] = 0x01;
109
110         // Constant Data
111
data[31] = 0x00;
112         data[32] = 0x00;
113         data[33] = 0x00;
114         data[34] = 0x00;
115         data[35] = 0x2D;
116         data[36] = 0x00;
117
118         // Default size of image cell in X direction
119
data[37] = 0x00;
120         data[38] = 0x01;
121
122         // Default size of image cell in Y direction
123
data[39] = 0x00;
124         data[40] = 0x01;
125
126         // Constant Data
127
data[41] = 0x00;
128         data[42] = 0x01;
129
130         // Image Color
131
data[43] = (byte)0xFF;
132         data[44] = (byte)0xFF;
133
134         os.write(data);
135
136     }
137
138     /**
139      * Sets the resolution information for the raster image
140      * the default value is a resolution of 240 dpi.
141      * @param resolution The resolution value
142      */

143     public void setResolution(int resolution) {
144         _resolution = resolution;
145     }
146
147 }
Popular Tags