43 lines
1.1 KiB
Java
43 lines
1.1 KiB
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.io.*;
|
|
import java.io.File;
|
|
|
|
public class Image
|
|
{
|
|
public static String remove_quote(String line)
|
|
{
|
|
return line.substring(1,line.length()-2);
|
|
}
|
|
public static void main(String[] args)
|
|
{
|
|
/*if(args.length == 0)
|
|
{
|
|
System.err.println("Need image path");
|
|
System.exit(1);
|
|
}*/
|
|
try
|
|
{
|
|
BufferedReader img_file = new BufferedReader(new FileReader("./image.xpm"));
|
|
String line = null;
|
|
int width, height, number_of_colors, pixel_size;
|
|
//Read metaData
|
|
while((line= img_file.readLine())!=null)
|
|
{
|
|
if(line.charAt(0) != '"'){
|
|
continue;
|
|
}
|
|
String[] metadatas = remove_quote(line).split(" ");
|
|
width = Integer.parseInt(metadatas[0]);
|
|
height = Integer.parseInt(metadatas[1]);
|
|
number_of_colors = Integer.parseInt(metadatas[2]);
|
|
pixel_size = Integer.parseInt(metadatas[3]);
|
|
System.out.println(width+""+height+""+number_of_colors+""+pixel_size);
|
|
break;
|
|
}
|
|
}catch(IOException | NumberFormatException e){
|
|
System.err.println(e.getMessage());
|
|
System.exit(1);
|
|
}
|
|
}
|
|
} |