求助 如何在JAVA类里写BMP转GIF 这类型的东西没接触过求助~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;import java.awt.image.*;import java.io.*;import javax.imageio.ImageIO;public class ImageOper{ public Image buildImage(String file) throws FileNotFoundException, IOException { return buildImage(new FileInputStream(new File(file))); } public Image buildImage(InputStream ins) throws IOException { return javax.imageio.ImageIO.read (ins); } public BufferedImage buildBufferImage(Image img) { int w = img.getWidth(null); // 得到源图宽 int h = img.getHeight(null); // 得到源图长 BufferedImage tag = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); tag.getGraphics().drawImage(img, 0, 0, w, h, null); return tag; } public void save(BufferedImage img, String file) throws IOException { OutputStream bos = new FileOutputStream(file); ImageIO.write(img, "gif", bos); bos.close(); } public static void main(String [] args) { ImageOper imgio = ImageOper(); Image img = buildImage("c:\ss.bmp"); BufferedImage bg = buildBufferImage(img); save(bg,"c:\ss.gif"); }} 在意文件夹下的所有BMP文件都要转换 比如icon文件夹下的所有BMP文件如何转换?谢谢 关于正则表达式 局部验证码刷新的问题? 异常输出到页面显示 关于jquery异步的问题.求教; javaBean连接数据库的问题 请问csdn里面的样式用jsp能达到吗? 项目发布后怎么访问?? 如何在win2000下搭建jsp环境?(请详细一点) ftp客户程序的问题 为什么我的<% out.print("this the second test !"); %>没有显示在网页上? javascript的小问题 菜鸟问题
import java.awt.image.*;
import java.io.*;import javax.imageio.ImageIO;public class ImageOper
{
public Image buildImage(String file) throws FileNotFoundException, IOException
{
return buildImage(new FileInputStream(new File(file)));
}
public Image buildImage(InputStream ins) throws IOException
{
return javax.imageio.ImageIO.read (ins);
}
public BufferedImage buildBufferImage(Image img) {
int w = img.getWidth(null); // 得到源图宽
int h = img.getHeight(null); // 得到源图长 BufferedImage tag = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(img, 0, 0, w, h, null);
return tag;
}
public void save(BufferedImage img, String file) throws IOException { OutputStream bos = new FileOutputStream(file);
ImageIO.write(img, "gif", bos);
bos.close();
} public static void main(String [] args)
{
ImageOper imgio = ImageOper();
Image img = buildImage("c:\ss.bmp");
BufferedImage bg = buildBufferImage(img);
save(bg,"c:\ss.gif");
}
}