xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felicia Ionascu <...@ocegr.fr>
Subject Re: problem when encoding compressed TIFF
Date Mon, 27 Jan 2003 14:43:39 GMT
Hi Thomas,

Thomas E Deweese wrote:


> Hmm, can you send (just to me please) or put up on a web site an
> example file?

I attach the file (it has only 2k, as it is nothing but a header, I guess...)



> FI> The code that I use is below:
>
>     Hmm, well I've personally never used the Tiff encoder for
> Multi-Page or compressed TIFF's (the encoder was generously donated by
> Sun from JAI).

I searched in JAI forums, the difference is that everybody uses a JAI
specific class (ImageCodec) to create the encoder, in a package that doesn't
come with Batik.
This piece of code is reported to work:

OutputStream out = new FileOutputStream(fileName);
TIFFEncodeParam param = new TIFFEncodeParam();
param.setCompression(TIFFEncodeParam.COMPRESSION_DEFLATE);
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, param);
encoder.encode(firstImage);
out.close();




>     Some other questions, is the output stream some form of seekable
> stream (like File for instance?).  Is the code running as an
> application or an applet?

Yes, it's a FileOutputStream. The code runs as an application.


>     Do you get any really helpful messages like:
>
> 'TIFFImageEncoder8'?

No, no message at all. Everything is supposed  to be OK.

I wonder if the sample model or the image type have anything to do with
this...


Felicia



> FI> //NOTES // bufferedImagesList is a Vector containing FormatRed
> FI> objects of type TYPE_3BYTE_BGR and the sample model
> FI> PixelInterleavedSampleModel //renderedImage is a FormatRed object
> FI> of the same type and sample models as the bufferedImagesList
> FI> objects
>
> FI>      TIFFEncodeParam encodeParam = new TIFFEncodeParam();
>
> FI>     //this is for the multipage output
> FI> encodeParam.setExtraImages(bufferedImagesList.iterator());
>
> FI>      //set the image resolution to 150 TIFFField[] extras = new
> FI> TIFFField[2]; extras[0] = new TIFFField(282,
> FI> TIFFField.TIFF_RATIONAL, 1, (Object)new long[][] {{(long)150,
> FI> (long)1},{(long)0 ,(long)0}}); extras[1] = new TIFFField(283,
> FI> TIFFField.TIFF_RATIONAL, 1, (Object)new long[][] {{(long)150,
> FI> (long)1},{(long)0 ,(long)0}}); encodeParam.setExtraFields(extras);
>
> FI>     //this should be for the compression
> FI> encodeParam.setCompression(TIFFEncodeParam.COMPRESSION_PACKBITS);
>
> FI>     //and now... encode it!  OutputStream outputStream = new
> FI> FileOutputStream (outputFilename); TIFFImageEncoder encoder = new
> FI> TIFFImageEncoder (outputStream, encodeParam);
> FI> encoder.encode(renderedImage); outputStream.close(); outputStream
> FI> = null; [...]
>
> FI> I wonder if it is supposed to work. Did you encounter a similar
> FI> situation?
>
> FI> Thanks a lot in advance, Felicia
>

Mime
View raw message