Page 1 of 1

Taking screenshots in game

PostPosted: Thu Jan 03, 2008 9:28 pm
by Taretia
Hi!

Could anyone help me, please?
I'd like to know, if it's possible to take screenshots/photos in a game, I create with AM.
I want to use it, as this: the player would be able to take pictures and then see them in game. My gameidea involves taking pictures of other characters ingame and then using them for other things, so they should become a part of an album or something, where the player can click on them, see them and act on them.
Is this possible? I hope I explained well... :lol:
Thanks,
Taretia

PostPosted: Fri Jan 04, 2008 2:20 am
by GM-Support
Hi,

Yes, this is possible.

1) Create a PictureBox. To do so, use this code:
Code: Select all
LoadControl PictureBoxObject(1)
PictureBoxObject(1).Width = 640 * 15
PictureBoxObject(1).Height = 480 * 15



2) Capture the current frame and display the captured frame inside the PictureBox created before. To do so, use this code:
Code: Select all
Action.CaptureFrame PictureBoxObject(1)



3) Do what you want with the captured frame.

For example, you can save the picture with the following code (use the "GetPath" function to save it to the game folder, read here for more info):
Code: Select all
PictureBoxObject(1).Picture = PictureBoxObject(1).Image
Action.SaveAPicture PictureBoxObject(1), "c:\temp.bmp"


You can display the PictureBox with the following code:
Code: Select all
PictureBoxObject(1).Left = 0 * 15
PictureBoxObject(1).Top = 0 * 15
PictureBoxObject(1).Visible = True


Etc.

4) To remove the PictureBox, use this code:
Code: Select all
UnloadControl PictureBoxObject(1)



Be sure to read the VBScript section of the online Help Document to better understand the code above.

Regards,
GM-Support

PostPosted: Fri Jan 04, 2008 9:46 am
by Taretia
Great! Thanks a lot! :D

PostPosted: Sat Jan 05, 2008 11:39 pm
by Softstar
I don't believe the SavePicture function works, because I keep receiving an error from the scripting engine when I have it in there, about the SavePicture command.

Would it be possible to implement the SavePicture command in an upcoming version of Adventure Maker? I made up a program with visual basic that prints any file that is specified in the arguments when it starts, so I had a BAT file that launched that exe with the command. What I was going to do is have the player be able to print out a certificate at the end of the game, by having the certificate.bmp be saved to the External folder, where the EXE and bat file were.

Anyway, it would be very much appreciated. Maybe even just making a function for Adventure Maker that you can execute in VBScript that prints what is on the screen, would be easier.

PostPosted: Sun Jan 06, 2008 2:43 am
by Mystery
Have you already tried with

Action.SaveAPicture CONTROLNAME,"FILENAME"

(that is with an "a" between save and picture?)

PostPosted: Sun Jan 06, 2008 7:13 am
by Softstar
I tried that...

My code looks like:

Code: Select all
LoadControl PictureBoxObject(1)
PictureBoxObject(1).Width = 640
PictureBoxObject(1).Height = 480
Action.CaptureFrame PictureBoxObject(1)
PictureBoxObject(1).Picture = PictureBoxObject(1).Image
Action.SaveAPicture PictureBoxObject(1).Picture, GetPath(2) + "image.bmp"


And returns a message like this at runtime:
Image

So does this mean it is without a chance impossible in this version of AM? Because if it is possible somehow, I'm willing to try.

PostPosted: Sun Jan 13, 2008 8:17 pm
by GM-Support
Thanks Mystery, you are right.

My first post contained several errors (I have fixed them on the first post itself, so that the new people who come to this topic are not misled).

What I changed was:
- Instead of "SavePicture", use "Action.SaveAPicture", as Mystery said.
- Multiply the pixel coordinates (position and size) by 15 because the value is in "twips", not in pixels. So, instead of "640", it should be "640 x 15", and instead of "480", it should be "480 x 15".


I have just tried the following code and it works fine on my computer (it saves the picture onto the "External" sub-folder of the project folder):

Code: Select all
LoadControl PictureBoxObject(1)
PictureBoxObject(1).Width = 640 * 15
PictureBoxObject(1).Height = 480 * 15
Action.CaptureFrame PictureBoxObject(1)
PictureBoxObject(1).Picture = PictureBoxObject(1).Image
Action.SaveAPicture PictureBoxObject(1), GetPath(2) + "image.bmp"



Regards,
GM-Support

PostPosted: Sat Oct 04, 2008 11:37 pm
by chickens1127
Sorry for necroposting, but just hit PrntScrn and paste it in Paint and save.

PostPosted: Sun Oct 05, 2008 3:33 am
by mercedes
Hi chickens...This method here i beleive is so u don't even have to leave AM to do it..It captures the frame and puts it in the External folder --and loads it in a Pictureboxobject..for you and you see it in Runtime..:)--I'm really happy to see this here..I have been wanting to know how to do this for a looong time..:D Good stuff!..:)

Peace

PostPosted: Sun Oct 12, 2008 8:40 pm
by chickens1127
yea, just how i do it

PostPosted: Sun Oct 12, 2008 8:56 pm
by mercedes
Hi Chickens...its done like the code u see further up here..only make sure u have the picture in your External Folder and put this code into the Advanced of the Frame u wish to show it in. Also make sure its the right size.

Code: Select all
LoadControl PictureBoxObject(1)
PictureBoxObject(1).Width = 640 * 15
PictureBoxObject(1).Height = 480 * 15
Action.CaptureFrame PictureBoxObject(1)
PictureBoxObject(1).Picture = PictureBoxObject(1).Image
Action.SaveAPicture PictureBoxObject(1), GetPath(2) + "image.bmp"


Replacing "Image.bmp" with the image of your choice..:)

Let me know if this works for u...it should..

Peace

PostPosted: Mon Oct 13, 2008 12:53 pm
by chickens1127
no, i don't need it

just was saying how i do it

PostPosted: Sat Jun 27, 2009 3:14 pm
by Lyberodoggy
Can I move the pictureboxobject? I mean can I modify its Left and Top coordinates? Because it seems like I can't

PostPosted: Sat Jun 27, 2009 3:43 pm
by cpkspikyhair
Can't you just use this code?

Code: Select all
PictureBoxObject(1).Move LEFT*15,TOP*15,WIDTH*15,HEIGHT*15

PostPosted: Sat Jun 27, 2009 3:54 pm
by Lyberodoggy
No. If you use this you still get the same result. I tried to take a screenshot of the contents of a hotspot (move the hotspot where I want, then move the picturebox on the hotspot's coordinates and take the screenshot), but It kept taking screenshots with the width and height specified, but starting from 0,0

PostPosted: Sun Jun 28, 2009 7:15 pm
by mercedes
I don't know what it is u are trying to do...I didn't bother putting in left or top..just coordinates..would this work for what u are doing....? I gather that is what u have attempted and it's not working ..What is it u are trying to do again..This moves it..but sounds like u want something else..?

LoadControl PictureBoxObject(1)
PictureBoxObject(1).move 357 * 15, 2 * 15, 423 * 15, 351 * 15
PictureBoxObject(1).Visible = True
Action.CaptureFrame PictureBoxObject(1)
PictureBoxObject(1).Picture = PictureBoxObject(1).Image
Action.SaveAPicture PictureBoxObject(1), GetPath(4) + "Picture.jpg"

PostPosted: Mon Jun 29, 2009 10:05 am
by Lyberodoggy
The code you posted won't move the picture box to 357,2. It 'll leave it in 0,0

PostPosted: Tue Jun 30, 2009 4:31 am
by mercedes
Ok, What am i not getting here.. lol..I'm not sure I understand..I see it move to those coordinates..[I make a hotspot first]--to judge where i want it to go...Que passa..? :P

PostPosted: Tue Jun 30, 2009 10:50 am
by Lyberodoggy
Try to capture a screenshot inside those coordinates. It WON'T be captured there, it will capture the area ranging from the start of the screen to the height and width you specified.

That's really wierd because a picturebox can be moved normally in VB 6