Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.image.*;
- import javax.imageio.*;
- import java.io.*;
- import java.util.*;
- /**
- * ImageFileManager is a small utility class with static methods to load
- * and save images
- *
- * @author Ahmad Lamaul Farid
- * @version 9 Desember 2020
- */
- public class ImageFileManager
- {
- private static final String IMAGE_FORMAT = "jpg";
- public static OFImage loadImage(File imageFile)
- {
- try
- {
- BufferedImage image = ImageIO.read(imageFile);
- if (image == null || image.getWidth(null) < 0)
- {
- return null;
- }
- return new OFImage(image);
- }
- catch (IOException exc)
- {
- return null;
- }
- }
- public static void saveImage(OFImage image, File file)
- {
- try
- {
- ImageIO.write(image, IMAGE_FORMAT, file);
- }
- catch (IOException exc)
- {
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement