Here you can find the source of fixImage(BufferedImage img, String ext)
Parameter | Description |
---|---|
img | a parameter |
ext | a parameter |
static BufferedImage fixImage(BufferedImage img, String ext)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; public class Main { /**/* w w w . j a v a2 s. c om*/ * Fixes image type based on the file extension. If you write argb images as jpg, things * get messed up. * @param img * @param ext * @return */ static BufferedImage fixImage(BufferedImage img, String ext) { if ("jpg".equalsIgnoreCase(ext)) { // log.info("Adjusting JPG image during Java Colorspace Issue for file " + file); // set rgb color for image, because of issues in java jpeg colorspaces int w = img.getWidth(); int h = img.getHeight(); BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); int[] rgb = img.getRGB(0, 0, w, h, null, 0, w); newImage.setRGB(0, 0, w, h, rgb, 0, w); img = newImage; } return img; } }