« Return to Thread: Please reply urgent help need it in Taking screenshot in battle.

Re: Please reply urgent help need it in Taking screenshot in battle.

by flemmingnlarsen-2 :: Rate this Message:

Reply to Author | View in Thread

You could use:

manager.getWindowManager().getRobocodeFrame().getBattleView().paint(Graphics)

That is, you e.g. create a BufferedImage with the size of the
BattleView.getBounds(), and call getGraphics() on your BufferedImage,
which you supply as input parameter to the paint(Graphics) above.

Now you have your screen-shot. ;-)

Best regards,
- Flemming

--- In Robocode@..., "asherbaig" <devilvsevil@...> wrote:

>
> Hi,
> I have done it by working very hard working on MenuBar.java under
> robocode.dialog.
>
> And i am able to take snapshot using key crtl-p also.
>
> Now the problem is it takes picture of active window of Robocode game
> but now
> i want to take picture of only battleview.Is it possible.Because i
> just close to it.Here is the code
>
> public void battlePrintActionPerformed() {
> IBattleManager battleManager = manager.getBattleManager();
>
> try {
> battleManager.pauseBattle();
> String path = battleManager.getBattleFilename();
> Rectangle screenRect = new Rectangle(robocodeFrame.getBounds());
> //get the position of frame
> BufferedImage capture = new Robot().createScreenCapture(screenRect);
> if (path == null) {
> path = saveScreenshotBattleDialog(battleManager.getBattlePath());
>
> }
> if (path != null) {
>
> ImageIO.write(capture, "png", new File(path));
> }
>
> }
> catch(Exception ex)
> {
> }
> finally {
> battleManager.resumeBattle();
> }
> }
>
> public void battleSaveAsActionPerformed() {
> IBattleManager battleManager = manager.getBattleManager();
>
> try {
> battleManager.pauseBattle();
> String path = saveBattleDialog(battleManager.getBattlePath());
>
> if (path != null) {
> battleManager.setBattleFilename(path);
> battleManager.saveBattleProperties();
> }
> } finally {
> battleManager.resumeBattle();
> }
> }
>
>
>
>
> --- In Robocode@..., "flemmingnlarsen"
> <flemming.n.larsen@> wrote:
> >
> > This question cannot be answered or handled quickly.
> >
> > You could add it as a feature request for Robocode. Then we (Robocode
> > developers) will spend some time on it and perhaps include this
> > feature in a comming version of Robocode. :-)
> >
> > You can add feature requests for Robocode here:
> >
> > https://sourceforge.net/tracker2/?group_id=37202&atid=419489
> >
> > It will be faster for us to implement this feature than to explain how
> > to do it, as it requires a great deal of inside knowledge of how
> > Robocode is built up etc. And in order to explain how to do it, we
> > must know exactly what do to it, i.e. actually try to implement it for
> > real, and then write the documentation about how to do it. All this
> > takes a great amount of effort. Hence, it's faster for us just to
> > implement the feature.
> >
> > However, we have to prioritize our limited time between all the
> > incoming feature requests etc. beside the changes we want to put into
> > the game ourselves, e.g. restructuring/refactorings to ease
> > maintenance and make it possible to implement more features in the
> future.
> >
> > Best regards,
> > - Flemming N. Larsen
> >
> >
> > --- In Robocode@..., "asherbaig" <devilvsevil@> wrote:
> > >
> > > Hi, Developers.
> > >
> > > Please i need your help in urgent.I want to take the screenshot
during
> > > the battle using the key "CRTL P".
> > > I need suggestion from you ppl.How to do it and where can i put
it.And
> > > what are code i need to implement it.
> > >
> > > Please help !
> > >
> >
>


 « Return to Thread: Please reply urgent help need it in Taking screenshot in battle.