Bug 25142 - TIFF 1bpp image with svgbrowser not drawable
Summary: TIFF 1bpp image with svgbrowser not drawable
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: SVG Viewer (show other bugs)
Version: 1.5
Hardware: PC All
: P5 normal
Target Milestone: ---
Assignee: Batik Developer's Mailing list
Depends on:
Reported: 2003-12-02 17:04 UTC by Klaus Bartz
Modified: 2008-11-21 10:22 UTC (History)
0 users

Test case adapted from comment 0 (261 bytes, image/svg+xml)
2008-11-21 10:22 UTC, Helder Magalhães

Note You need to log in before you can comment on or make changes to this bug.
Description Klaus Bartz 2003-12-02 17:04:18 UTC
If a SVG file contains an image tag which references a TIFF
1 bpp CCITT T.6 like

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"

<svg xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink" width="450" height="800" viewBox="0 
0 450 800">

        <image xlink:href="tests/resources/images/a4.tif" 
               x="0" y="0" width="100%" height="100%" />


the error

java.lang.ArrayIndexOutOfBoundsException: 1728
	at java.awt.image.SinglePixelPackedSampleModel.setPixels
	at java.awt.image.WritableRaster.setPixels(WritableRaster.java:547)
	at sun.awt.image.SunWritableRaster.setPixels(SunWritableRaster.java:132)
	at org.apache.batik.ext.awt.image.GraphicsUtil.copyData_FALLBACK
	at org.apache.batik.ext.awt.image.GraphicsUtil.copyData
	at org.apache.batik.ext.awt.image.rendered.Any2sRGBRed.copyData
	at org.apache.batik.ext.awt.image.rendered.AbstractRed.getData

occurs with org.apache.batik.apps.svgbrowser.Main.
This is done because the source has 1 band, the destination 3;
An ColorConvertOp is not done because the ColorSpaces are 
compared; but the TIFFImage has the same ColorSpace as the Destination.
Following change helpes me:

 * @version $Id: Any2sRGBRed.java,v 1.5 2003/04/11 13:57:59 vhardy Exp $ */

<             if (srcCM.getColorSpace() == dstCM.getColorSpace() 
<             	&& srcCM.isCompatibleRaster(wr)) {
>             if (srcCM.getColorSpace() == dstCM.getColorSpace()) {
Comment 1 Thomas Deweese 2003-12-09 11:59:57 UTC
I had to back this out because it caused problems with a number of PNG
images (as PNG is required by SVG and Tiff is not I choose the
lesser of two evils).  If you can update the patch so it also
works with samples/tests/spec/color/colorProfile.svg I may reapply
Comment 2 Thomas Deweese 2005-03-22 12:15:42 UTC
Reassigning all open bugs to the development list.
Sorry for the mass mailing.
Comment 3 Helder Magalhães 2008-11-21 04:32:02 UTC
(In reply to comment #0)
> If a SVG file contains an image tag which references a TIFF
> 1 bpp CCITT T.6 like

Could a sample TIFF file which reproduces this be attached to this report? As this is a somehow specific format, it could help reproducing this issue. :-)
Comment 5 Helder Magalhães 2008-11-21 10:22:14 UTC
Created attachment 22914 [details]
Test case adapted from comment 0

This is a tricky one. Downloaded the TIFF file sample and adapted the test case to realize that this isn't supported by most implementations... :-|

Renders in:
 * Inkscape 0.46

Doesn't render in:
 * Squiggle (Batik) 1.8pre
 * Firefox 3.0.1
 * Opera 9.62
 * ActiveX-based plug-ins:
   * Adobe SVG Viewer 6.0 Development Release 1 (a.k.a. ASV6)
   * Adobe SVG Viewer 3.03 (a.k.a. ASV3)
   * Renesis Player 1.1.1
   * Corel SVG Viewer 2.1 (a.k.a. CSV)
   * GPAC 0.4.5-dev
   * SVG Map Toolkit 0.7 (a.k.a. SMT)

This is mostly just for the record, but may save some time if someone else tries to find a working implementation. ;-)