I was kind of expecting this, but the repaint()ing makes the image flicker, and my method doesn't seem to be working as it just gives the magnifier a black image :/
Here's my code:
private GreenfootImage getWorldImage()
{
getImage().clear();
getWorld().repaint();
JPanel panel = WorldHandler.getInstance().getWorldCanvas();
BufferedImage buff = new BufferedImage(panel.getWidth(),
panel.getHeight(),
BufferedImage.TYPE_INT_RGB);
//Note: buff.getWidth() - 2 == getWorld().getWidth()
// (and the same for height)
// (I assume this is the 1 pixel thick border around the perimeter of the world)
GreenfootImage img = new GreenfootImage(buff.getWidth() - 2, buff.getHeight() - 2);
for(int x = 0; x < img.getWidth(); x++)
{
for(int y = 0; y < img.getHeight(); y++)
{
Color colour = new Color(buff.getRGB(x + 1, y + 1));
img.setColorAt(x, y, colour);
}
}
return img;
}
I'm assuming its a problem with the line Color colour = new Color(etc) line...
Although that'd be amazing, it includes the magnify image itself (I might be wrong here, but I think that'd mean it'd be zoomed whatever the normal zoom is squared)...
Actually I might have thought of a way round that.
BRB :p
(Major props if it works! - although it doesn't slow down the scenario at all on my computer - which only has a 3ghz processor - I'd noticed on slower computers it did)
That last update was a bug fix for rotated actor's support - before it was appearing to be cutting off the edges of rotated actors when they were magnified.
I like the effect, however I'm not going to switch from my Magnify scenario because I looked in the source code for this and there's code in like all the classes, rather than just one self-contained class, and there doesn't seem to be much abstraction :/ I might look into re-creating the effect myself if I have the time :) Not going to take the code from this scenario 'cause if I did it'd be no fun :p
Oh and also you might want to add support for actors - at the moment if you add an actor to the world it just acts like the actor isn't there. Hopefully you update this because like I said I think the fish-eye like effect is really good.
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/23
Magnify
2012/1/22
Magnifiying Lens II