[ http://jira.magnolia-cms.com/browse/MGNLDAM-85?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Lipp reopened MGNLDAM-85: -------------------------------- We should not rely on exceptions for control flow. Looks like a could easily check the type before doing the cast and hence avoid the ClassCastException. > Displaying a png image fails in some case > ----------------------------------------- > > Key: MGNLDAM-85 > URL: http://jira.magnolia-cms.com/browse/MGNLDAM-85 > Project: Magnolia DAM Module > Issue Type: Bug > Affects Versions: 1.0 Alpha2 s011 > Reporter: Eric Hechinger > Assignee: Christopher Zimmermann > Priority: Critical > Fix For: 1.0 Alpha2 s012 > > > For some png (dam/demo-project/img/logo/magnolia-logo), we have the following > exception when displaying an Image. > This is related to the following resolved issue MGNLIMG-38. > From ImageUtil.class > final boolean isOpaque = img.getTransparency() == Transparency.OPAQUE; > if (!isOpaque && !outputFormat.supportsTransparency()) { > final WritableRaster raster = img.getRaster(); > final WritableRaster newRaster = raster.createWritableChild(0, 0, > img.getWidth(), img.getHeight(), 0, 0, new int[]{0, 1, 2}); > // create a ColorModel that represents the one of the ARGB except > the alpha channel > final DirectColorModel cm = (DirectColorModel) > img.getColorModel(); > The image isOpack = false && supportsTransparency = false --> jump in the if > statement. > Issue is that this cast is failing: (DirectColorModel) img.getColorModel() > img.getColoredModel() --> type ComponentColorModel > and ComponentColorModel is not a sub class of DirectColorModel. > ------------------------- > Caused by: java.lang.ClassCastException: java.awt.image.ComponentColorModel > cannot be cast to java.awt.image.DirectColorModel > at > info.magnolia.imaging.util.ImageUtil.flattenTransparentImageForOpaqueFormat(ImageUtil.java:68) > at > info.magnolia.imaging.DefaultImageStreamer.serveImage(DefaultImageStreamer.java:68) > at > info.magnolia.imaging.caching.CachingImageStreamer.generateAndStore(CachingImageStreamer.java:197) > at > info.magnolia.imaging.caching.CachingImageStreamer$1.apply(CachingImageStreamer.java:118) > at > info.magnolia.imaging.caching.CachingImageStreamer$1.apply(CachingImageStreamer.java:114) > at > com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355) > at > com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184) > at > com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153) > at > com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69) > at > com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393) > at > info.magnolia.imaging.caching.CachingImageStreamer.serveImage(CachingImageStreamer.java:136) > ... 82 more -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.magnolia-cms.com/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ---------------------------------------------------------------- For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <dev-list-unsubscr...@magnolia-cms.com> ----------------------------------------------------------------