Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void setLampColorizer()
- {
- BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
- int a = 256, r = 0, g = 0, b = 0, x = 0, y = 0;
- for (; r < 256; r++)
- {
- img.setRGB(x, y, asARGB(a, r, b, g));
- if (x == 255)
- {
- y++;
- x = 0;
- }
- else x++;
- }
- for (; g < 256; g++)
- {
- img.setRGB(x, y, asARGB(a, r, b, g));
- if (x == 255)
- {
- y++;
- x = 0;
- }
- else x++;
- }
- for (; b < 256; b++)
- {
- img.setRGB(x, y, asARGB(a, r, b, g));
- if (x == 255)
- {
- y++;
- x = 0;
- }
- else x++;
- }
- try {
- File outputFile = new File("colorizer.png");
- System.out.println(outputFile.getCanonicalPath());
- ImageIO.write(img, "png", outputFile);
- } catch (IOException e) {
- System.out.println("File not Found: colorizer.png");
- }
- }
- public static int asARGB(int a, int r, int g, int b) {
- return (((((a << 8) + r) << 8) + g) << 8) + b;
- }
Advertisement
Add Comment
Please, Sign In to add comment