[go: up one dir, main page]

Menu

[25f834]: / src / BMPTool.java  Maximize  Restore  History

Download this file

53 lines (43 with data), 1.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.imageio.ImageIO;
public class BMPTool {
String [] SupportedFormat={".png",".jpg",".jpeg",".gif",".tiff",".tif",".raw",".pnm",".pdf",".html",".ico"};
ImageTool IT = new ImageTool();
public void BMPConverter(String Path,String Target,String Extension){
if(Extension.equalsIgnoreCase(".png")||Extension.equalsIgnoreCase(".jpeg")||Extension.equalsIgnoreCase(".jpg")||Extension.equalsIgnoreCase(".gif")||Extension.equalsIgnoreCase(".pnm")||Extension.equalsIgnoreCase(".tif")||Extension.equalsIgnoreCase(".tiff")||Extension.equalsIgnoreCase(".raw")){
BufferedImage bufferedImage;
File file = new File(Path);
try {
bufferedImage = ImageIO.read(new File(Path));
BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(),
bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB);
newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.WHITE, null);
ImageIO.write(newBufferedImage, Extension.replace(".",""), new File(Target+"/"+file.getName().replace(new GetFileExtension().getExtension(Path),Extension)));
} catch (IOException e) {
e.printStackTrace();
}
}else if(Extension.equalsIgnoreCase(".html")){
try{
IT.ConvertImgToHtml(Path, Target);
}catch(Exception e){}
}else if(Extension.equalsIgnoreCase(".ico")){
try {
IT.ConvertToIco(Path, Target);
} catch (IOException e) {
e.printStackTrace();
}
}else if(Extension.equalsIgnoreCase(".svg")){
}else if(Extension.equalsIgnoreCase(".pdf")){
IT.ConvertImgToPdfFile(Path, Target);
}
}
public void InisilizeBox(Vector<String> format,String Extension){
format.removeAllElements();
for(int i =0;i<SupportedFormat.length;i++){
format.addElement(SupportedFormat[i]);}
}
}