i have a problem to store and read TIFF-format images with JAI to an
oracle8 database. I have tried it with the JPG-format and all works
well! But with the TIFF format it doesn't. I don't know what i'm doing
wrong, because loading an image (TIFF) from disk and display it on
screen works fine!
storing the image (in very short form):
// load file
RenderedOp src = JAI.create("fileload",filename);
// open connection...
PreparedStatement pstm = conn.prepareStatement(
"INSERT INTO " + tablename + " (NAME, BILDDATEN) VALUES (?,?)");
pstm.clearParameters();
pstm.setString(1,"....");
// contains the image
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
JAI.create("encode",src,ostream,"TIFF",null );
ostream.flush();
byte[] objBytes = ostream.toByteArray();
pstm.setBytes(2,objBytes);
// then executeUpdate()...
reading the image (short):
// open connection...get ResultSet rs...
ForwardSeekableStream fsstream = new
ForwardSeekableStream(rs.getBinaryStream(2));
ParameterBlock pb = (new ParameterBlock()).add(fsstream);
RenderedOp image1 = JAI.create("tiff", pb);
// then display the image..
ScrollingImagePanel panel = new ScrollingImagePanel(image2,
image2.getWidth(),image2.getHeight());
// add to a frame...
I always get an error like this:
java.lang.NullPointerException
at
com.sun.media.jai.codecimpl.util.PropertyUtil.getString(PropertyUtil.java:127)
at com.sun.media.jai.codec.JaiI18N.getString(JaiI18N.java:28)
at com.sun.media.jai.codec.TIFFDirectory.<init>(Compiled Code)
at com.sun.media.jai.codecimpl.TIFFImage.<init>(Compiled Code)
at
com.sun.media.jai.codecimpl.TIFFImageDecoder.decodeAsRenderedImage(TIFFImageDecoder.java:104)
at
com.sun.media.jai.codec.ImageDecoderImpl.decodeAsRenderedImage(ImageDecoderImpl.java:148)
at
com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:60)
at com.sun.media.jai.opimage.TIFFRIF.create(TIFFRIF.java:53)
at javax.media.jai.OperationRegistry.create(Compiled Code)
at javax.media.jai.RenderedOp.createInstance(Compiled Code)
at blob.SaveTIFFInDatabaseNew.main(Compiled Code)
java.lang.RuntimeException: - Unable to render RenderedOp for this
operation.
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at java.lang.RuntimeException.<init>(Compiled Code)
at javax.media.jai.RenderedOp.createInstance(Compiled Code)
at blob.SaveTIFFInDatabaseNew.main(Compiled Code)
Where blob is the package and SaveTIFFinDatabaseNew the Class that
should test the operation described above!
Thanks,
Jens