package zju.archeo.images;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class ImageHelper {
public static ImageIcon loadImage(String name) {
ImageIcon image = null;
try {
URL url = ImageHelper.class.getResource(name);
if (url != null) {
Image img = Toolkit.getDefaultToolkit().createImage(url);
if (img != null) image = new ImageIcon(img);
}
} catch (Throwable ex) {
System.out.println("ERROR: loading image " + name
+ " failed. Exception: " + ex.getMessage());
}
return
Swing图片处理工具类ImageHelper
最新推荐文章于 2022-10-18 20:52:24 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)