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;
- public class PrzetwarzanieObrazu extends Thread{
- private int x;
- private int y;
- private int x_end;
- private int y_end;
- BufferedImage image;
- Color bw_color;
- public void run() {
- long start=System.currentTimeMillis();
- for (int i=x; i<x_end; i++){
- for (int j=0; j<image.getHeight(); j++){
- Color color = new Color(image.getRGB(i,j));
- int red = color.getRed();
- int green = color.getGreen();
- int blue = color.getBlue();
- double bw_red = red*0.3;
- double bw_green = green*0.59;
- double bw_blue = blue*0.11;
- bw_color = new Color((int)bw_red, (int)bw_green, (int)bw_blue);
- App.setObraz(i, j, bw_color);
- }
- }
- // endtime
- long stop=System.currentTimeMillis();
- System.out.println("Processing from x: " + x + " do x: " + x_end + " Time: " + (stop-start) + "ms");
- }
- PrzetwarzanieObrazu(BufferedImage image, int x, int x_end)
- {
- this.x = x;
- this.x_end = x_end;
- this.image = image;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement