1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id$ */
package org.apache.fop.afp.ioca;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.fop.afp.modca.AbstractAFPObject;
import org.apache.fop.afp.util.BinaryUtils;
/**
* The IM Image Input Descriptor structured field contains the
* descriptor data for an IM image data object. This data specifies
* the resolution, size, and color of the IM image.
*/
public class ImageInputDescriptor extends AbstractAFPObject {
/** the resolution of the raster image (default 240) */
private int resolution = 240;
/** {@inheritDoc} */
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[45];
copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE);
data[1] = 0x00; // length
data[2] = 0x2C;
// Constant data.
data[9] = 0x00;
data[10] = 0x00;
data[11] = 0x09;
data[12] = 0x60;
data[13] = 0x09;
data[14] = 0x60;
data[15] = 0x00;
data[16] = 0x00;
data[17] = 0x00;
data[18] = 0x00;
data[19] = 0x00;
data[20] = 0x00;
// X Base (Fixed x00)
data[21] = 0x00;
// Y Base (Fixed x00)
data[22] = 0x00;
byte[] imagepoints = BinaryUtils.convert(resolution * 10, 2);
/**
* Specifies the number of image points per unit base for the X axis
* of the image. This value is ten times the resolution of the image
* in the X direction.
*/
data[23] = imagepoints[0];
data[24] = imagepoints[1];
/**
* Specifies the number of image points per unit base for the Y axis
* of the image. This value is ten times the resolution of the image
* in the Y direction.
*/
data[25] = imagepoints[0];
data[26] = imagepoints[1];
/**
* Specifies the extent in the X direction, in image points, of an
* non-celled (simple) image.
*/
data[27] = 0x00;
data[28] = 0x01;
/**
* Specifies the extent in the Y direction, in image points, of an
* non-celled (simple) image.
*/
data[29] = 0x00;
data[30] = 0x01;
// Constant Data
data[31] = 0x00;
data[32] = 0x00;
data[33] = 0x00;
data[34] = 0x00;
data[35] = 0x2D;
data[36] = 0x00;
// Default size of image cell in X direction
data[37] = 0x00;
data[38] = 0x01;
// Default size of image cell in Y direction
data[39] = 0x00;
data[40] = 0x01;
// Constant Data
data[41] = 0x00;
data[42] = 0x01;
// Image Color
data[43] = (byte)0xFF;
data[44] = (byte)0xFF;
os.write(data);
}
/**
* Sets the resolution information for the raster image
* the default value is a resolution of 240 dpi.
*
* @param resolution The resolution value
*/
public void setResolution(int resolution) {
this.resolution = resolution;
}
}
|