Changeset 4677


Ignore:
Timestamp:
12/05/08 08:31:46 (11 years ago)
Author:
melissa
Message:

Fixed exception when scaling MNG images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/MNGReader.java

    r4649 r4677  
    2424package loci.formats.in; 
    2525 
     26import java.awt.image.ColorModel; 
     27import java.awt.image.IndexColorModel; 
    2628import java.awt.image.BufferedImage; 
    2729import java.io.*; 
     
    9698    b[7] = 0x0a; 
    9799 
    98     return ImageIO.read(new ByteArrayInputStream(b)).getSubimage(x, y, w, h); 
     100    BufferedImage img = ImageIO.read(new ByteArrayInputStream(b)); 
     101    img = img.getSubimage(x, y, w, h); 
     102 
     103    // reconstruct the image to use an appropriate raster 
     104    // ImageIO often returns images that cannot be scaled because a 
     105    // BytePackedRaster is used 
     106    byte[][] pix = AWTImageTools.getPixelBytes(img, isLittleEndian()); 
     107    img = AWTImageTools.makeImage(pix, w, h, 
     108      FormatTools.getBytesPerPixel(getPixelType()), isLittleEndian()); 
     109 
     110    return img; 
    99111  } 
    100112 
Note: See TracChangeset for help on using the changeset viewer.