Guest User

Untitled

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