like this gif image
it has transparent background,
when i using ImageIO.write(image,"jpg", file)
to save,it's be broken
the broken result is here
how to fix it problem? thank you
my code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import junit.framework.TestCase;
public class ImageResize1 extends TestCase{
public void testT1() throws IOException{
URL url=new URL("http://ec.europa.eu/culture/media/programme/images/logos/01_tr_media_col/01_tr_media_col_gif.gif");
BufferedImage image=ImageIO.read(url);
File file=new File("C:/temp/java/t7.jpg");
ImageIO.write(image,"jpg", file);
}
}
i used:
for(int x = 0; x < scaled.getWidth(); x++) {
for(int y = 0; y < scaled.getHeight(); y++) {
int rgb = scaled.getRGB(x, y);
int alpha = (rgb >> 24) & 0xff;
if(alpha != 255) {
scaled.setRGB(x, y,-1); //set white
}
}
}
check it from here
it's not right,result is here