View | Details | Raw Unified | Return to bug 43506
Collapse All | Expand All

(-)src/java/org/apache/fop/image/TIFFImage.java (-18 / +27 lines)
Lines 73-98 Link Here
73
            = new org.apache.xmlgraphics.image.codec.tiff.TIFFImage
73
            = new org.apache.xmlgraphics.image.codec.tiff.TIFFImage
74
                (stream, null, 0);
74
                (stream, null, 0);
75
        TIFFDirectory dir = (TIFFDirectory)img.getProperty("tiff_directory");
75
        TIFFDirectory dir = (TIFFDirectory)img.getProperty("tiff_directory");
76
        TIFFField fld = dir.getField(TIFFImageDecoder.TIFF_RESOLUTION_UNIT);
76
        TIFFField fld = dir.getField(TIFFImageDecoder.TIFF_X_RESOLUTION);
77
        int resUnit = fld.getAsInt(0);
77
        if (fld != null) {
78
        fld = dir.getField(TIFFImageDecoder.TIFF_X_RESOLUTION);
78
            log.debug("x resolution = " + fld.getAsDouble(0));                
79
        double xRes = fld.getAsDouble(0);
79
            this.dpiHorizontal = fld.getAsDouble(0); 
80
        } else {
81
            log.warn("Cannot determine x resolution.");
82
        }
80
        fld = dir.getField(TIFFImageDecoder.TIFF_Y_RESOLUTION);
83
        fld = dir.getField(TIFFImageDecoder.TIFF_Y_RESOLUTION);
81
        double yRes = fld.getAsDouble(0);
84
        if (fld != null) {
82
        switch (resUnit) {
85
            log.debug("y resolution = " + fld.getAsDouble(0));                
83
        case 2: //inch
86
            this.dpiVertical = fld.getAsDouble(0); 
84
            this.dpiHorizontal = xRes;
87
        } else {
85
            this.dpiVertical = yRes;
88
            log.warn("Cannot determine y resolution.");
86
            break;
87
        case 3: //cm
88
            this.dpiHorizontal = xRes * 2.54f;
89
            this.dpiVertical = yRes * 2.54f;
90
            break;
91
        default:
92
            //ignored
93
            log.warn("Cannot determine bitmap resolution."
94
                    + " Unimplemented resolution unit: " + resUnit);
95
        }
89
        }
90
        fld = dir.getField(TIFFImageDecoder.TIFF_RESOLUTION_UNIT);
91
        if (fld != null) {
92
            int resUnit = fld.getAsInt(0);
93
            if (resUnit == 3) {
94
              //cm
95
                this.dpiHorizontal *= 2.54f;
96
                this.dpiVertical *= 2.54f;
97
            } else if (resUnit != 2) {
98
                //ignored
99
                log.warn("Cannot determine bitmap resolution."
100
                        + " Unimplemented resolution unit: " + resUnit);
101
            }
102
        } else {
103
            log.warn("Cannot determine bitmap resolution unit.");
104
        }            
96
        fld = dir.getField(TIFFImageDecoder.TIFF_COMPRESSION);
105
        fld = dir.getField(TIFFImageDecoder.TIFF_COMPRESSION);
97
        if (fld != null) {
106
        if (fld != null) {
98
            compression = fld.getAsInt(0);
107
            compression = fld.getAsInt(0);

Return to bug 43506