import java.io.InputStream;
import java.awt.Color;
-// FOP
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
return imageInfo.mimeType;
}
+ /** @see org.apache.fop.image.FopImage#getOriginalURI() */
+ public String getOriginalURI() {
+ return this.imageInfo.originalURI;
+ }
+
/**
* Load image data and initialize its properties.
*
* @param type the type of loading to do
- * @param ua the user agent for handling logging etc.
* @return true if the loading was successful
*/
public synchronized boolean load(int type) {
* All implementations should override this to get and
* return the dimensions.
*
- * @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadDimensions() {
* If the renderer requires a bitmap image then the
* implementations should override this to load the bitmap.
*
- * @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadBitmap() {
* In some cases the original data can be used by the renderer.
* This should load the data and any other associated information.
*
- * @param ua the user agent
* @return true if the loading was successful
*/
protected boolean loadOriginalData() {
/**
* Flag for loading dimensions.
*/
- public static final int DIMENSIONS = 1;
+ int DIMENSIONS = 1;
/**
* Flag for loading original data.
*/
- public static final int ORIGINAL_DATA = 2;
+ int ORIGINAL_DATA = 2;
/**
* Flag for loading bitmap data.
*/
- public static final int BITMAP = 4;
+ int BITMAP = 4;
/**
* Get the mime type of this image.
*/
String getMimeType();
+ /** @return the original URI used to access this image. */
+ String getOriginalURI();
+
/**
* Load particular inforamtion for this image
* This must be called before attempting to get
public static class ImageInfo {
/** InputStream to load the image from */
public InputStream inputStream;
+ /** Original URI the image was accessed with */
+ public String originalURI;
/** image width (in pixels) */
public int width;
/** image height (in pixels) */
* ImageReader object for BMP image type.
*
* @author Pankaj Narula
- * @version $Id: BMPReader.java,v 1.8 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class BMPReader implements ImageReader {
&& (header[1] == (byte) 0x4d));
if (supported) {
FopImage.ImageInfo info = getDimension(header);
+ info.originalURI = uri;
+ info.mimeType = getMimeType();
info.inputStream = bis;
return info;
} else {
private FopImage.ImageInfo getDimension(byte[] header) {
FopImage.ImageInfo info = new FopImage.ImageInfo();
- info.mimeType = getMimeType();
// little endian notation
int byte1 = header[WIDTH_OFFSET] & 0xff;
/**
* ImageReader object for EPS document image type.
*
- * @version $Id: EPSReader.java,v 1.9 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class EPSReader implements ImageReader {
if (isEPS) {
FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.data = data;
readEPSImage(bis, data);
* ImageReader object for GIF image type.
*
* @author Pankaj Narula
- * @version $Id: GIFReader.java,v 1.8 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class GIFReader implements ImageReader {
&& (header[5] == 'a'));
if (supported) {
FopImage.ImageInfo info = getDimension(header);
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
return info;
* ImageReader object for JPEG image type.
*
* @author Pankaj Narula
- * @version $Id: JPEGReader.java,v 1.8 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class JPEGReader implements ImageReader {
&& (header[1] == (byte) 0xd8));
if (supported) {
FopImage.ImageInfo info = getDimension(fis);
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = fis;
return info;
* ImageReader object for PNG image type.
*
* @author Pankaj Narula
- * @version $Id: PNGReader.java,v 1.8 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class PNGReader implements ImageReader {
if (supported) {
FopImage.ImageInfo info = getDimension(header);
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
return info;
FopImage.ImageInfo info = new FopImage.ImageInfo();
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.str = SVGDOMImplementation.SVG_NAMESPACE_URI;
* ImageReader object for TIFF image type.
*
* @author Pankaj Narula, Michael Lee
- * @version $Id: TIFFReader.java,v 1.9 2003/03/06 21:25:45 jeremias Exp $
+ * @version $Id$
*/
public class TIFFReader implements ImageReader {
if (supported) {
FopImage.ImageInfo info = getDimension(header);
+ info.originalURI = uri;
info.mimeType = getMimeType();
info.inputStream = bis;
return info;
FOUserAgent ua)
throws IOException {
FopImage.ImageInfo info = loadImage(uri, fis, ua);
+ info.originalURI = uri;
if (info != null) {
IOUtils.closeQuietly(fis);
}
private int width;
private int bitsPerPixel;
private ColorSpace colorSpace;
- private int bitmapSiye;
private byte[] bitmaps;
private byte[] mask;
private Color transparentColor;
return "application/octet-stream";
}
+ public String getOriginalURI() {
+ return "temp-image:" + this.toString();
+ }
+
/**
* @see org.apache.fop.image.FopImage#load(int, org.apache.commons.logging.Log)
*/
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.commons.io.output.CountingOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.image.EPSImage;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.JpegImage;
-import org.apache.fop.image.XMLImage;
import org.apache.fop.util.ASCII85OutputStream;
import org.apache.fop.util.Finalizable;
import org.apache.fop.util.FlateEncodeOutputStream;
import org.apache.fop.util.RunLengthEncodeOutputStream;
-import org.w3c.dom.Document;
/**
* Utility code for rendering images in PostScript.
byte[] imgmap = img.getBitmaps();
gen.saveGraphicsState();
- gen.commentln("%FOPBeginBitmap: " + img.getMimeType());
+ gen.writeln(x + " " + y + " translate");
+ gen.writeln(w + " " + h + " scale");
+
+ gen.commentln("%FOPBeginBitmap: " + img.getMimeType() + " " + img.getOriginalURI());
if (img.getColorSpace().getType() == ColorSpace.TYPE_CMYK) {
gen.writeln("/DeviceCMYK setcolorspace");
} else if (img.getColorSpace().getType() == ColorSpace.CS_GRAY) {
gen.writeln("/DeviceRGB setcolorspace");
}
- gen.writeln(x + " " + y + " translate");
- gen.writeln(w + " " + h + " scale");
-
gen.writeln("{{");
// Template: (RawData is used for the EOF signal only)
// gen.write("/RawData currentfile <first filter> filter def");