Skip to main content

[JAI] Tiff transparency and IndexColorModel

2 replies [Last post]
Anonymous

Hi list,
I am having troubles writing an image to a tiff file.

I have a PlanarImage
with the following characteristics:
1>IndexColorModel with one byte-based band. Support for
transparency is set to true, the transparency index is set to 0. Alpha
is not premultiplied
2>PixelInterleavedSampleModel, transfertype is 0 (byte), 1 band

I am using the following code to write it down as a TIFF

ImageIO.write(bufferedImage, "tiff",
new File("c:/temp/" + tmpFile.getName() + ".tiff"));

The file is created without any errors but with no transparency. If I
instead try to write a GIF or a PNG transparency is fine.

Any clues?

Simone

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

I don't believe TIFF supports transparency in the colormap. I think you need
to add an alpha band (premultiplied/associated or
nonpremultiplied/unassociated). If the original image is index color as you
indicated you would have first to expand to RGB with 3 samples per pixel.

Brian

On Thu, 12 May 2005, simone giannecchini wrote:

> Hi list,
> I am having troubles writing an image to a tiff file.
>
> I have a PlanarImage
> with the following characteristics:
> 1>IndexColorModel with one byte-based band. Support for
> transparency is set to true, the transparency index is set to 0. Alpha
> is not premultiplied
> 2>PixelInterleavedSampleModel, transfertype is 0 (byte), 1 band
>
> I am using the following code to write it down as a TIFF
>
> ImageIO.write(bufferedImage, "tiff",
> new File("c:/temp/" + tmpFile.getName() + ".tiff"));
>
>
> The file is created without any errors but with no transparency. If I
> instead try to write a GIF or a PNG transparency is fine.
>
> Any clues?
>
> Simone

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

simone giannecchini

Well i figured that out by myself, thanks though. I am now converting the
image to component color model before saving it.
Simone.

On 6/2/05, Brian Burkhalter wrote:
>
> I don't believe TIFF supports transparency in the colormap. I think you
> need
> to add an alpha band (premultiplied/associated or
> nonpremultiplied/unassociated). If the original image is index color as
> you
> indicated you would have first to expand to RGB with 3 samples per pixel.
>
> Brian
>
> On Thu, 12 May 2005, simone giannecchini wrote:
>
> > Hi list,
> > I am having troubles writing an image to a tiff file.
> >
> > I have a PlanarImage
> > with the following characteristics:
> > 1>IndexColorModel with one byte-based band. Support for
> > transparency is set to true, the transparency index is set to 0. Alpha
> > is not premultiplied
> > 2>PixelInterleavedSampleModel, transfertype is 0 (byte), 1 band
> >
> > I am using the following code to write it down as a TIFF
> >
> > ImageIO.write(bufferedImage, "tiff",
> > new File("c:/temp/" + tmpFile.getName() + ".tiff"));
> >
> >
> > The file is created without any errors but with no transparency. If I
> > instead try to write a GIF or a PNG transparency is fine.
> >
> > Any clues?
> >
> > Simone
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
[att1.html]