Код:
import javax.imageio.*;
import java.awt.image.*;
import java.io.*;
public class timedimageread
{
public static void main(String[] args)
{
BufferedImage img;
long startTime;
long endTime;
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.jpg"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("jpg: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.bmp"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("bmp: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.gif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("gif: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.png"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("png: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.tif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("tif: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.jpg"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("jpg: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.bmp"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("bmp: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.gif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("gif: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.png"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("png: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.tif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("tif: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.jpg"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("jpg: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.bmp"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("bmp: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.gif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("gif: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.png"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("png: " + (endTime - startTime));
startTime = System.currentTimeMillis();
try
{
img = ImageIO.read(new File("blackandwhite.tif"));
}
catch(IOException e){}
endTime = System.currentTimeMillis();
System.out.println("tif: " + (endTime - startTime));
}
}
выход: JPG: 156 ВМР: 0 GIF: 16 PNG: 16 TIF: 0 JPG: 31 ВМР: 0 GIF: 16 PNG: 0 TIF: 15 JPG: 16 ВМР: 0 GIF: 0 PNG: 16 TIF: 0
Вы можете расширить код или использовать увеличенное изображение, чтобы получить лучшие результаты, но мое предположение заключается в том, что .bmp (я использовал 256 цветов, но вы могли бы уменьшить это), процессы быстро становятся наиболее надежными.
Это не Java, а вопрос программирования – ControlAltDel