blob: f9999f4dd40d98deb049ebe4948043b949ee7a4a (
plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.image;
// Java
import java.net.URL;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
// FOP
import org.apache.fop.pdf.PDFColor;
import org.apache.fop.pdf.PDFFilter;
import org.apache.fop.image.analyser.ImageReaderFactory;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.fo.FOUserAgent;
/**
* Base class to implement the FopImage interface.
* @author Eric SCHAEFFER
* @author Modified by Eric Dalquist - 9/14/2001 - ebdalqui@mtu.edu
* @see FopImage
*/
public abstract class AbstractFopImage implements FopImage {
protected int loaded = 0;
/**
* Image width (in pixel).
*/
protected int m_width = 0;
/**
* Image height (in pixel).
*/
protected int m_height = 0;
/**
* Image URL.
*/
protected URL m_href = null;
/**
* ImageReader object (to obtain image header informations).
*/
protected FopImage.ImageInfo imageInfo = null;
/**
* Image color space (java.awt.color.ColorSpace).
*/
protected ColorSpace m_colorSpace = null;
/**
* Bits per pixel.
*/
protected int m_bitsPerPixel = 0;
/**
* Image data (uncompressed).
*/
protected byte[] m_bitmaps = null;
/**
* Image data size.
*/
protected int m_bitmapsSize = 0;
/**
* Image transparency.
*/
protected boolean m_isTransparent = false;
/**
* Transparent color (org.apache.fop.pdf.PDFColor).
*/
protected PDFColor m_transparentColor = null;
/**
* Constructor.
* Construct a new FopImage object and initialize its default properties:
* <UL>
* <LI>image width
* <LI>image height
* </UL>
* The image data isn't kept in memory.
* @param href image URL
* imgReader ImageReader object
* @return a new FopImage object
*/
public AbstractFopImage(URL href, FopImage.ImageInfo info) {
this.m_href = href;
this.imageInfo = info;
if(this.imageInfo.width != -1) {
m_width = imageInfo.width;
m_height = imageInfo.height;
loaded = loaded | DIMENSIONS;
}
}
public String getMimeType() {
return imageInfo.mimeType;
}
/**
* Load image data and initialize its properties.
*/
public synchronized boolean load(int type, FOUserAgent ua) {
if((loaded & type) != 0) {
return true;
}
boolean success = true;
if(((type & DIMENSIONS) != 0) && ((loaded & DIMENSIONS) == 0)) {
success = success && loadDimensions(ua);
if(!success) {
return false;
}
loaded = loaded | DIMENSIONS;
}
if(((type & BITMAP) != 0) && ((loaded & BITMAP) == 0)) {
success = success && loadBitmap(ua);
if(success) {
loaded = loaded | BITMAP;
}
}
if(((type & ORIGINAL_DATA) != 0) && ((loaded & ORIGINAL_DATA) == 0)) {
success = success && loadOriginalData(ua);
if(success) {
loaded = loaded | ORIGINAL_DATA;
}
}
return success;
}
protected boolean loadDimensions(FOUserAgent ua) {
return false;
}
protected boolean loadBitmap(FOUserAgent ua) {
return false;
}
protected boolean loadOriginalData(FOUserAgent ua) {
return false;
}
/**
* Return the image URL.
* @return the image URL (as String)
*/
public String getURL() {
return this.m_href.toString();
}
/**
* Return the image width.
* @return the image width
*/
public int getWidth() {
return this.m_width;
}
/**
* Return the image height.
* @return the image height
*/
public int getHeight() {
return this.m_height;
}
/**
* Return the image color space.
* @return the image color space (java.awt.color.ColorSpace)
*/
public ColorSpace getColorSpace() {
return this.m_colorSpace;
}
public ICC_Profile getICCProfile() {
return null;
}
/**
* Return the number of bits per pixel.
* @return number of bits per pixel
*/
public int getBitsPerPixel() {
return this.m_bitsPerPixel;
}
/**
* Return the image transparency.
* @return true if the image is transparent
*/
public boolean isTransparent() {
return this.m_isTransparent;
}
public boolean hasSoftMask() {
return false;
}
public byte[] getSoftMask() {
return null;
}
/**
* Return the transparent color.
* @return the transparent color (org.apache.fop.pdf.PDFColor)
*/
public PDFColor getTransparentColor() {
return this.m_transparentColor;
}
/**
* Return the image data (uncompressed).
* @return the image data
*/
public byte[] getBitmaps() {
return this.m_bitmaps;
}
/**
* Return the image data size (uncompressed).
* @return the image data size
*/
public int getBitmapsSize() {
return this.m_bitmapsSize;
}
/**
* Return the original image data (compressed).
* @return the original image data
*/
public byte[] getRessourceBytes() {
return null;
}
/**
* Return the original image data size (compressed).
* @return the original image data size
*/
public int getRessourceBytesSize() {
return 0;
}
}
|