Here you can find the source of fixImageIOJpegBug(BufferedImage image)
private static BufferedImage fixImageIOJpegBug(BufferedImage image)
//package com.java2s; /*/* w w w . j a v a2 s . c om*/ * Copyright (C) 2010-2016 JPEXS, All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; public class Main { private static BufferedImage fixImageIOJpegBug(BufferedImage image) { int type = image.getType(); if (type != BufferedImage.TYPE_INT_RGB) { // convert to RGB without alpha channel int width = image.getWidth(); int height = image.getHeight(); BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] pixels2 = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); int[] pixels = image.getRGB(0, 0, width, height, null, 0, width); for (int i = 0; i < pixels.length; i++) { pixels2[i] = pixels[i] & 0xffffff; } return newImage; } return image; } }