Thanks guys. I'm just trying to simulate the pseudo-perspective effect that the overworld map has in Final Fantasy 3/6. Nostalgia goggles help me overlook the fact that it looks quite horrid.
Some quick googling turned up
this implementation in C. I ported it to Java (it's all of maybe 20 lines), although I'm having a tough time figuring out the optimal values for the parameters for the look I want.
In my first-pass Java version, I pass it an input BufferedImage (the background, painted normally) and an output BufferedImage. I'm currently basically doing this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| static int[] inRGB = new int[w * h]; static int[] outRGB = new int[w * h];
public static void getMode7(BufferedImage in, BufferedImage out, ...) {
in.getRGB(0,0, w,h, inRGB,0, w);
for (int y=0; y<h; y++) { ... stuff ... for (int x=0; x<w; x++) { ... stuff ... } }
out.setRGB(0, 0, w,h, outRGB,0, w); out.flush();
} |
Unfortunately, this is unusably slow, taking about ~0.05 seconds per call to getMode7() for a 512x512 image. My naive timing of sections of this method seem to show that the getRGB() and setRGB() calls are the bottleneck. Not to mention that there's no chance of my "out" image being accelerated. Is there a better way do do this sort of thing?