Guest User

Untitled

a guest
Nov 25th, 2021
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. import csteutils.*;
  2. import csteutils.myro.*;
  3. import java.awt.Color;
  4. import java.lang.Math;
  5.  
  6. class Main
  7. {
  8.   public static void main(String[] args)
  9.   {
  10. String image = "images/400x4002.jpeg";
  11.     int height = 400;
  12.     int width = 400;
  13.    
  14.     MyroColorImage originalImage = new MyroColorImage();
  15.    
  16.  
  17.     originalImage.loadImage(image);
  18.     originalImage.resize(width, height);
  19.     originalImage.show();
  20.  
  21.     MyroColorImage newImage = new MyroColorImage();
  22.     newImage.resize(width,height);
  23.  
  24.     for (int y = 0; y < height; y++)
  25.        {
  26.     for(int x = 0; x < width; x++)
  27.            {
  28.     Color c = originalImage.getPixel(x,y).getColor();
  29.     int red = c.getRed();
  30.     int green = c.getGreen();
  31.     int blue = c.getBlue();
  32.     red = (int) Math.min(255, (red * .393) + (green * .769) + (blue * .189));
  33.     green = (int) Math.min(255, (red * .349) + (green *.686) + (blue * .168));
  34.     blue = (int) Math.min(255, (red * .272) + (green *.534) + (blue * .131));
  35.    
  36.  newImage.getPixel(x,y).setColor(new Color(red, green, blue)); }
  37.       }
  38.     newImage.show();
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment