惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
A
About on SuperTechFans
D
Docker
腾讯CDC
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
W
WeLiveSecurity
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
V
Vulnerabilities – Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
P
Privacy International News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Application and Cybersecurity Blog
Application and Cybersecurity Blog
aimingoo的专栏
aimingoo的专栏
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Secure Thoughts
Stack Overflow Blog
Stack Overflow Blog
T
Tenable Blog
T
Threatpost
P
Proofpoint News Feed
博客园 - 司徒正美
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Hacker News: Ask HN
Hacker News: Ask HN
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
Project Zero
Project Zero
Help Net Security
Help Net Security
WordPress大学
WordPress大学
F
Full Disclosure
博客园 - 三生石上(FineUI控件)
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
Security Latest
Security Latest
T
Tor Project blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog

博客园 - 空空色色

转一篇,CentOS后台服务配置 linux kernel 2.6.36 编译升级 linux的UPNP支持(转) UPNP协议细节(转) UPnp协议 from wikipedia 考察智力zz JScollPane以及JPanel相关 bmp文件格式 Java媒体框架(JMF),个人很欣赏.... 常用颜色对照表 YUV/YIQ色彩空间的转换 关于Swing实现透明窗体的。我也很喜欢,收藏! java中的数据库程序应用 A*以及迭代加深的A*算法(IDA*) 我的兄弟们之袋鼠篇 深度优先状态搜索法 我的兄弟们之温J篇 java中的图象处理技术基础 经典搜索算实现之一,广度优先.
java中对图象文件的处理(读写以及转换)
空空色色 · 2007-04-24 · via 博客园 - 空空色色

方法一:
(利用imageio类的读写函数)
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;

public class ChangeImageStyle {

  public static void main(String args[]) throws IOException{
 
    File inputFile = new File("test.bmp");
    BufferedImage input = ImageIO.read(inputFile);

    //转换为gif格式的图片
    File outputFile = new File("test.gif");
    ImageIO.write(input, "GIF", outputFile);

    //转换为jpg格式的图片  
    outputFile = new File("test.jpg");
    ImageIO.write(input, "JPG", outputFile);

    //转换为png格式的图片
    outputFile = new File("test.png");
    ImageIO.write(input, "PNG", outputFile);
  }
}

方法二:
如果你已经把某个文件读入,并存为了Image类的一个实例.
转变方法如下:
其中:image为Image类的一个实例
try{
BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_INT_RGB);
Graphics2D biContext = bi.createGraphics();
biContext.drawImage(image, 0, 0, null);
FileOutputStream out=new FileOutputStream("./a1.jpeg");                    
JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(out);                    
JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam(bi);                     
param.setQuality(1.0f,false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
out.flush();
 out.close();
 }catch(Exception EE)
   {
  System.out.println(EE);
   }

方法三:
也就是最笨的方法,弄清楚文件格式,一个字节一个字节的向文件写内容..

总结:最好使用BUFFEREDIMAGE类,免得多了那么多麻烦........