Guest User

Untitled

a guest
Dec 7th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class ImageFileManager here.
  4.  *
  5.  * @author (Aristya)
  6.  * @version (7.12)
  7.  */
  8. import java.awt.image.*;
  9. import javax.imageio.*;
  10. import java.io.*;
  11. import java.util.*;
  12.  
  13. public class ImageFileManager {
  14.     private static final String IMAGE_FORMAT = "jpg";
  15.  
  16.     public static OFImage loadImage(File imageFile)
  17.     {
  18.         try
  19.         {
  20.             BufferedImage image = ImageIO.read(imageFile);
  21.             if (image == null || image.getWidth(null) < 0)
  22.             {
  23.                 return null;
  24.             }
  25.             return new OFImage(image);
  26.         }
  27.        
  28.         catch (IOException exc)
  29.         {
  30.             return null;
  31.         }
  32.     }
  33.  
  34.     public static void saveImage(OFImage image, File file)
  35.     {
  36.         try
  37.         {
  38.             ImageIO.write(image, IMAGE_FORMAT, file);
  39.         }
  40.         catch (IOException exc)
  41.         {
  42.             return;
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment