Advertisement
Guest User

Untitled

a guest
Jun 6th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. package image_convert.bmp;
  2.  
  3. import java.awt.Color;
  4. import java.awt.image.BufferedImage;
  5. import java.io.File;
  6. import java.io.IOException;
  7.  
  8. import javax.imageio.ImageIO;
  9. public class PrzetwarzanieObrazu extends Thread{
  10.    
  11.     private int x;
  12.     private int y;
  13.     private int x_end;
  14.     private int y_end;
  15.     BufferedImage image;
  16.     Color bw_color;
  17.  
  18.     public void run() {
  19.         long start=System.currentTimeMillis();
  20.        
  21.          for (int i=x; i<x_end; i++){
  22.                 for (int j=0; j<image.getHeight(); j++){
  23.            
  24.                     Color color = new Color(image.getRGB(i,j));
  25.                    
  26.                     int red = color.getRed();
  27.                     int green = color.getGreen();
  28.                     int blue = color.getBlue();
  29.                    
  30.                     double bw_red = red*0.3;
  31.                     double bw_green = green*0.59;
  32.                     double bw_blue = blue*0.11;
  33.                    
  34.                     bw_color = new Color((int)bw_red, (int)bw_green, (int)bw_blue);
  35.  
  36.                    
  37.                     App.setObraz(i, j, bw_color);
  38.            
  39.                 }
  40.             }
  41.             // endtime
  42.             long stop=System.currentTimeMillis();
  43.             System.out.println("Processing from x: " + x + "  do x: " + x_end + "  Time: " + (stop-start) + "ms");
  44.        
  45.        
  46.     }
  47.     PrzetwarzanieObrazu(BufferedImage image, int x, int x_end)
  48.     {
  49.         this.x = x;
  50.         this.x_end = x_end;
  51.         this.image = image;
  52.          
  53.        
  54.     }
  55.    
  56.    
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement