package me.hugmanrique.pokedata.graphics;

/**
 * @author Hugmanrique
 * @since 29/05/2017
 */
public class ROMImage {
}

@@ -40,82 +40,1672 @@
 s;%0A%0A
-/**%0A * @author Hugmanrique%0A * @since 29/05/2017%0A */%0Apublic class ROMImage %7B
+import lombok.AllArgsConstructor;%0Aimport lombok.Getter;%0A%0Aimport java.awt.*;%0Aimport java.awt.image.BufferedImage;%0A%0A/**%0A * @author Hugmanrique%0A * @since 29/05/2017%0A */%0A@Getter%0A@AllArgsConstructor%0Apublic class ROMImage %7B%0A    private Palette palette;%0A    private int%5B%5D data;%0A    private Point size;%0A%0A    public static ROMImage fromImage(Image img, Palette palette) %7B%0A        BufferedImage image = (BufferedImage) img;%0A        int dims = image.getWidth() * image.getHeight();%0A%0A        int x = -1;%0A        int y = 0;%0A        int blockX = 0;%0A        int blockY = 0;%0A%0A        int%5B%5D data = new int%5Bdims / 2%5D;%0A%0A        for (int i = 0; i %3C dims; i++) %7B%0A            x++;%0A%0A            if (x %3E= 8) %7B%0A                x = 0;%0A                y++;%0A            %7D%0A%0A            if (y %3E= 8) %7B%0A                y = 0;%0A                blockX++;%0A            %7D%0A%0A            if (blockX %3E (image.getWidth() / 8) - 1) %7B%0A                blockX = 0;%0A                blockY++;%0A            %7D%0A%0A            int rgb = image.getRGB(blockX * 8 + x, blockY * 8 + y);%0A            Color color = new Color(rgb, true);%0A            int pal = 0;%0A%0A            for (int j = 0; j %3C 16; j++) %7B%0A                Color col = palette.getColor(j);%0A%0A                if (col.equals(color)) %7B%0A                    pal = j;%0A                %7D%0A            %7D%0A%0A            int write = data%5Bi / 2%5D;%0A%0A            if ((i & 1) == 0) %7B%0A                write %7C= (pal & 0xF);%0A            %7D else %7B%0A                write %7C= ((pal %3C%3C 4) & 0xF0);%0A            %7D%0A%0A            data%5Bi / 2%5D = write;%0A        %7D%0A%0A        Point size = new Point(image.getWidth(null), image.getHeight(null));%0A%0A        return new ROMImage(palette, data, size);%0A    %7D%0A
 %0A%7D%0A

Load ROMImage from Image in blocks