Fig.1 - your standard tilemap

Fig .2 - tilemap with perspective

Hey, I got a pretty simple question and I'm sure openGL is needed.
But does anyone know how to give their tilemaps perspective by just using the camera and scaling?
if (floor != null) {
for (int y = (int) horizon; y < height; y++) {
float distance = (camera.z * scale.y) / (y - horizon);
float ratio = distance / scale.x;
double dx = -sin * ratio;
double dy = cos * ratio;
double sx = camera.x + distance * cos - width / 2 * dx;
double sy = camera.y + distance * sin - width / 2 * dy;
for (int x = 0; x < width; x++) {
int cx = (int) Math.abs(sx % floor.getWidth());
int cy = (int) Math.abs(sy % floor.getHeight());
int color = floor.getPixel(cx, cy);
setColor(color);
drawPixel(x, y);
sx += dx;
sy += dy;
}
}
}
This was from an old example I had laying around, tried converting it into ruby and without success :(
I'm using TileD to make my maps if that means anything.
And to make this easy to understand, the effect I'm trying to recreate is Snes's Mode7 effect.
Thanks