how to convert a gif image to jpg?
<p>like this 
<a href="http://ec.europa.eu/culture/media/programme/images/logos/01_tr_media_col/01_tr_media_col_gif.gif" rel="nofollow">gif image</a></p>

<p>it has transparent background, </p>

<p>when i using <code>ImageIO.write(image,"jpg", file)</code> to save,it's be broken</p>

<p>the broken result is <a href="http://clip2net.com/clip/m10494/1284584778-clip-29kb.jpg" rel="nofollow">here</a></p>

<p>how to fix it problem? thank you</p>

<p>my code: </p>

<pre><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);
    }
}
</code></pre>

<p>i used:</p>

<pre><code>for(int x = 0; x &lt; scaled.getWidth(); x++) {
    for(int y = 0; y &lt; scaled.getHeight(); y++) {
        int rgb = scaled.getRGB(x, y);
        int alpha = (rgb &gt;&gt; 24) &amp; 0xff;
        if(alpha != 255) {
            scaled.setRGB(x, y,-1); //set white
        }
    }
}
</code></pre>

<p>check it from <a href="http://stackoverflow.com/questions/464825/converting-transparent-gif-png-to-jpeg-using-java">here</a></p>

<p>it's not right,result is <a href="http://clip2net.com/clip/m10494/1284584873-clip-24kb.jpg" rel="nofollow">here</a></p>
