tterrag1098

Untitled

Nov 10th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. public static void setLampColorizer()
  2.     {
  3.         BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
  4.        
  5.         int a = 256, r = 0, g = 0, b = 0, x = 0, y = 0;
  6.        
  7.         for (; r < 256; r++)
  8.         {
  9.             img.setRGB(x, y, asARGB(a, r, b, g));
  10.             if (x == 255)
  11.             {
  12.                 y++;
  13.                 x = 0;
  14.             }
  15.             else x++;
  16.         }
  17.         for (; g < 256; g++)
  18.         {
  19.             img.setRGB(x, y, asARGB(a, r, b, g));
  20.             if (x == 255)
  21.             {
  22.                 y++;
  23.                 x = 0;
  24.             }
  25.             else x++;
  26.         }
  27.         for (; b < 256; b++)
  28.         {
  29.             img.setRGB(x, y, asARGB(a, r, b, g));
  30.             if (x == 255)
  31.             {
  32.                 y++;
  33.                 x = 0;
  34.             }
  35.             else x++;
  36.         }
  37.        
  38.         try {
  39.             File outputFile = new File("colorizer.png");
  40.             System.out.println(outputFile.getCanonicalPath());
  41.             ImageIO.write(img, "png", outputFile);
  42.         } catch (IOException e) {
  43.             System.out.println("File not Found: colorizer.png");
  44.         }
  45.     }
  46.  
  47.     public static int asARGB(int a, int r, int g, int b) {
  48.         return (((((a << 8) + r) << 8) + g) << 8) + b;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment