package com.shine;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
public class Img {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File f = new File("D:\\1.bmp");
String bo = null;
bo = getFormatInFile(f);
System.out.println("bo:" + bo);
if (bo != null) {
cutPic.cutpic("D:\\1.bmp", "D:\\a1.bmp", 0, 0, 20, 20);
}
}
public static boolean isImage(File imageFile) {
if (!imageFile.exists()) {
return false;
}
Image img = null;
try {
img = ImageIO.read(imageFile);
if (img == null || img.getWidth(null) <= 0
|| img.getHeight(null) <= 0) {
return false;
}
return true;
} catch (Exception e) {
return false;
} finally {
img = null;
}
}
}
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
public class Img {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File f = new File("D:\\1.bmp");
String bo = null;
bo = getFormatInFile(f);
System.out.println("bo:" + bo);
if (bo != null) {
cutPic.cutpic("D:\\1.bmp", "D:\\a1.bmp", 0, 0, 20, 20);
}
}
public static boolean isImage(File imageFile) {
if (!imageFile.exists()) {
return false;
}
Image img = null;
try {
img = ImageIO.read(imageFile);
if (img == null || img.getWidth(null) <= 0
|| img.getHeight(null) <= 0) {
return false;
}
return true;
} catch (Exception e) {
return false;
} finally {
img = null;
}
}
}