DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26848>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26848

PNG images using JIMI instead JAI





------- Additional Comments From [EMAIL PROTECTED]  2004-02-12 07:46 -------
Solution:

    private static String getGenericImageClassName() {

        if (m_genericImageClassName == null) {
            try {
                Class.forName("org.apache.fop.image.JAIImage");
                m_genericImageClassName = "org.apache.fop.image.JAIImage";
            } catch (Throwable ex) {
                /* on any exception assume Jai is not present and use Jimi 
instead */
                m_genericImageClassName = "org.apache.fop.image.JimiImage";
            }
        }
        return m_genericImageClassName;
    }

Workaround:

    public static String checkFOP() {

        try {
            FopImageFactory.Make(PDFGenerator.class.getResource("blank.png");
            return "png"; 
        } catch (Throwable t) {
            try {
                // trying to set by hand Bug#: 26848 from FOP
                Class clazz = Class.forName
("org.apache.fop.image.FopImageFactory");
                java.lang.reflect.Field field = clazz.getDeclaredField
("m_genericImageClassName");
                field.setAccessible(true);
                field.set(null, "org.apache.fop.image.JimiImage");
                FopImageFactory.Make(PDFGenerator.class.getResource
("blank.png");
                return "png"; 
            } catch (Throwable _t) {
                return "jpeg"; 
            }
        }
    }

Reply via email to