In JAI there is a bug when a transparent gif is converted to jpeg (happens probably with other formats too). I solved the bug in convertJAI.java by changing the image to RGB mode when necessary.
 
        if (! (format.equals("gif") || format.equals("png")) &&
            img.getColorModel()instanceof IndexColorModel) {
          IndexColorModel icm = (IndexColorModel) img.getColorModel();
          if (icm.getTransparency() == Transparency.BITMASK) {
            byte[][] data = "" byte[3][icm.getMapSize()];
            icm.getReds(data[0]);
            icm.getGreens(data[1]);
            icm.getBlues(data[2]);
            LookupTableJAI lut = new LookupTableJAI(data);
            img = JAI.create("lookup", img, lut);
            log.debug("palette-color image converted to RGB");
          }
        }
 
I added also a gif encoder to convertJAI.java, so now JAI works well with gif's. Because I am not able to change the MMBase code I will send everything to Daniel Ockeloen, who is the author of convertJAI.java.
 
Martijn Houtman
 
 
 

Reply via email to