This content has been marked as final. Show 2 replies
784013 wrote:<li> Use code tags as mentioned on the 'sticky post' at the top of the forum listing.
I use this code to resize a jpg picture. Sometimes i get the resized image but sometimes instead of the resized image i get a black image.
It is a web application so this code is within a servlet.
<li> For better help sooner, post an SSCCE (http://pscode.org/sscce.html).
<li> Clarify whether 'sometimes' means that some images always fail, while others always work, or alternately if this 'black image' effect can happen for images that resize successfully at other times.
This looks a little hinky: I've never had this work:
BufferedImage dimg = dimg = new BufferedImage(newW, newH, img.getType());
Also if for some reason your img.getType does not work--you'll get a black screen. I seem to remember back amoungst the cobwebs of my mind that GIF formats will sometimes produce strange results. Check your getType return value to see if it is a valid type or not.
BufferedImage dimg = new BufferedImage(newW, newH, img.getType());