KickJava   Java API By Example, From Geeks To Geeks.

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


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: ImageDataDescriptor.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  */

28 public class ImageDataDescriptor extends AbstractAFPObject {
29
30     private int _xresol = 0;
31     private int _yresol = 0;
32     private int _width = 0;
33     private int _height = 0;
34
35     /**
36      * Constructor for a ImageDataDescriptor for the specified
37      * resolution, width and height.
38      * @param xresol The horizontal resolution of the image.
39      * @param yresol The vertical resolution of the image.
40      * @param width The width of the image.
41      * @param height The height of the height.
42      */

43     public ImageDataDescriptor(int xresol, int yresol, int width, int height) {
44
45         _xresol = xresol;
46         _yresol = yresol;
47         _width = width;
48         _height = height;
49
50     }
51
52     /**
53      * Accessor method to write the AFP datastream for the Image Data Descriptor
54      * @param os The stream to write to
55      * @throws java.io.IOException
56      */

57     public void writeDataStream(OutputStream JavaDoc os)
58         throws IOException JavaDoc {
59
60         byte[] data = new byte[] {
61             0x5A,
62             0x00,
63             0x20,
64             (byte) 0xD3,
65             (byte) 0xA6,
66             (byte) 0xFB,
67             0x00, // Flags
68
0x00, // Reserved
69
0x00, // Reserved
70
0x00, // Unit base - 10 Inches
71
0x00, // XRESOL
72
0x00, //
73
0x00, // YRESOL
74
0x00, //
75
0x00, // XSIZE
76
0x00, //
77
0x00, // YSIZE
78
0x00, //
79
(byte)0xF7, // ID = Set IOCA Function Set
80
0x02, // Length
81
0x01, // Category = Function set identifier
82
0x0B, // FCNSET = IOCA FS 11
83
};
84
85         byte[] l = BinaryUtils.convert(data.length - 1, 2);
86         data[1] = l[0];
87         data[2] = l[1];
88
89         byte[] x = BinaryUtils.convert(_xresol, 2);
90         data[10] = x[0];
91         data[11] = x[1];
92
93         byte[] y = BinaryUtils.convert(_yresol, 2);
94         data[12] = y[0];
95         data[13] = y[1];
96
97         byte[] w = BinaryUtils.convert(_width, 2);
98         data[14] = w[0];
99         data[15] = w[1];
100
101         byte[] h = BinaryUtils.convert(_height, 2);
102         data[16] = h[0];
103         data[17] = h[1];
104
105         os.write(data);
106
107     }
108
109 }
110
Popular Tags