Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: ImageIO/BufferedImage behaving inconsistently from one day to the next. Date: Tue, 19 Jun 2012 20:22:47 -0700 Organization: A noiseless patient Spider Lines: 64 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 20 Jun 2012 03:22:51 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="IZQsHU8CwMUPnWgvh4wwWA"; logging-data="20922"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+N79suCPVMN4JS2Wn2lml3WEJJAHM5/RE=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Cancel-Lock: sha1:/ryYsIOzP/BBIdaPrV9IG6q8ur0= Xref: csiph.com comp.lang.java.programmer:15443 On 6/19/2012 7:31 PM, Fred Greer wrote: > I have code that used to work perfectly, which processes images in > certain ways, and today it suddenly was not working. I hadn't changed the > code at all. I tracked the problem down to spurious > IllegalArgumentExceptions being thrown by this code: > > public class ImageUtils { > > private static float[] BLUR = {0.1111111, 0.1111111, 0.1111111, > 0.1111111, 0.1111111, 0.1111111, > 0.1111111, 0.1111111, 0.1111111} > ... > public static BufferedImage blur (BufferedImage img) { > Kernel k = new Kernel(3, 3, BLUR); > ConvolveOp co = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null); > BufferedImage dest = new BufferedImage(img.getWidth(), > img.getHeight(),img.getType()); > co.filter(img,dest); > return dest; > } > ... > } So this is the code you say isn't working? It works for me: package quicktest; import java.awt.image.BufferedImage; import java.awt.image.ConvolveOp; import java.awt.image.Kernel; import javax.imageio.ImageIO; /** * * @author Brenden */ public class ConvlPng { public static void main(String[] args) throws Exception { BufferedImage png = ImageIO.read( ConvlPng.class.getResourceAsStream( "conv_test.png" ) ); BufferedImage conv = blur( png ); System.out.println( conv ); } private static float[] BLUR = {0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f, 0.1111111f}; public static BufferedImage blur (BufferedImage img) { Kernel k = new Kernel(3, 3, BLUR); ConvolveOp co = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null); BufferedImage dest = new BufferedImage(img.getWidth(), img.getHeight(),img.getType()); co.filter(img,dest); return dest; } }