I used the TiledImageTranscoder Class lying into the Contrib directory of the Batik sources and i find something strange.
As everybody knows, by default, Batik works in ARGB colorspace, then, if you decide to encode your RenderedImage into different colorspace, you have to modify it by yourself like following :


from ARGB to GRAY:
buf = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_GRAY);
mFirstImage = new FormatRed (GraphicsUtil.wrap(result), buf.getColorModel());


from ARGB to Bilevel:
buf = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_BINARY);
mFirstImage = new FormatRed (GraphicsUtil.wrap(result), buf.getColorModel());


Here is the modified TiledImageTranscoder Class snipet considering the colorspace modification

TiledImageTranscoder Class modified:
....
int bands = img.getSampleModel().getNumBands();
int [] off = new int[bands];
for (int i=0; i<bands; i++)
off[i] = i;
SampleModel sm = new PixelInterleavedSampleModel (DataBuffer.TYPE_BYTE, w, (100000+w-1)/w, bands, w*bands, off);
RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(img), sm);


TIFFImageEncoder enc = new TIFFImageEncoder(output.getOutpustream(), null);

BufferedImage buf1 = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_GRAY);
RenderedImage mGrayImage= new FormatRed (GraphicsUtil.wrap(rimg ), buf1.getColorModel());


enc.encode(mGrayImage);

BufferedImage buf2 = new BufferedImage(1,1, BufferedImage.TYPE_BYTE_BINARY);
RenderedImage mBilevelImage= new FormatRed (GraphicsUtil.wrap(rimg ), buf2.getColorModel());


enc.encode(mBilevelImage);
...

There, you could find that mBilevelImage takes more time to encode than mGrayImage, things that i could not understand ... does the mBilevelImage more simpliest image than mGrayImage and therefore easier to encode?


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to