Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package image_convert.bmp;
- import java.awt.Color;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- /**
- * Hello world!
- *
- */
- public class App
- {
- static int w_total = 0;
- static int h_total = 0;
- static BufferedImage image = null;
- static int totalTime = 0;
- public static void main( String[] args ) throws InterruptedException
- {
- try
- {
- image = ImageIO.read(new File("C:/Users/grzes/Desktop/testdata/2.jpg"));
- }
- catch (IOException e)
- {
- System.out.println("Brak pliku");
- }
- long start=System.currentTimeMillis();
- PrzetwarzanieObrazu obraz1 = new PrzetwarzanieObrazu(image, 0, 1000);
- PrzetwarzanieObrazu obraz2 = new PrzetwarzanieObrazu(image, 1000, 2000);
- PrzetwarzanieObrazu obraz3 = new PrzetwarzanieObrazu(image, 2000, 3000);
- PrzetwarzanieObrazu obraz4 = new PrzetwarzanieObrazu(image, 4000, 5000);
- PrzetwarzanieObrazu obraz5 = new PrzetwarzanieObrazu(image, 5000, image.getWidth());
- /* threads*/
- obraz1.start();
- obraz2.start();
- obraz3.start();
- obraz4.start();
- obraz5.start();
- obraz1.join();obraz2.join();obraz3.join();obraz4.join();obraz5.join();
- long stop=System.currentTimeMillis();
- try
- {
- ImageIO.write(image, "jpg", new File("C:/Users/grzes/Desktop/testdata/result.jpg"));
- System.out.println("End, saved");
- }
- catch (IOException e)
- {
- System.out.println("Error while saving");
- }
- System.out.println("Total time: " + (stop-start));
- }
- public static void setObraz(int i, int j, Color bw_color)
- {
- image.setRGB(i, j, bw_color.getRGB());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement