PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Saving a surface to a file as a .bmp or something...

Okay so I want to make a game where players enter their name, as I dont have a clue how to bring up the keyboard or anything in the game to get user input, i think I will opt for the way that Everquest on ppc does it, let you "sign ur name" an d then it just saves that signature as a file of osmesort...

my question is how best to accompilsh this, on the create character screen let an area of the screen record mouse movements and plot the pixels for every drag of the mouse (similar to a paintrpogram) thusly letting someone sign their name in that area, and then save that area (that part of the surface) to a .bmp file somehow, is that the way one would do it? how does one copy a surface to a file as such?

thanks for any nfo-help
-Shane
Why don't you use the JoJoSip keyboard to let users enter their name?
(see http://jojosoft.gapidraw.com/

(hopefully the JoJoSoft developers don't also decide to change their licence terms overnight... :cry: )
Codejoy · 22 Sep 2003, 20:08 UTC — thanks
hey this seems to be what im looking for, ill delve more into it and hopefully find it easy to use and implement, thank you for your time! :)

-Shane
AFAICT, there is a CGapiSurface function called SaveSurface that saves the surface to a file, either as BMP or PNG.

I tried it and it works OK. However, it seems to dither my PNG file, so it isn't exactly what I see on screen.

Is there any control over this?
Interesting that you get dithering. All of our screenshots are generated via the GD screenshot functionality, and there's no dithering at all...
OK I will take another look at it. Maybe it is just being dithered in the viewer I am viewing it in or something.

Still, it's nice to be able to take snapshots as the game is running, bang bang bang. Fill up your directory fast. If only I had buttons autorepeat. :-)

Seriously, I added some code to save up to 99 screenshots, is that enough? You can always move them out of the directory to save more.
I simply added a counter that appends to the file name for unique screenshot names each run. Rather than a button, I allocate a 10x10 pixel area in the lower right corner to activate the screenshot code - of course I only implement screenshots in my beta builds as a debug/promotional tool, not in the production builds. Letting the general user create screenshots is risky since they will always fill up their file system with them by accident.
I have a hardware button do the screenshot. It just copies the back buffer into a file, so you get whatever was on the screen, exactly. I also use a counter for the file name, but maybe a little differently. I keep trying files from "screenshot 1" to "screenshot 99" until I find an unused name. I haven't yet tested if this is horribly slow when there are already some screenshots; if so, I will fix it. I will consider limiting it to 10, or maybe adding a warning if there are lots of screenshots taken.
Keep track of the next screenshot number in the registry. You can load it at startup time, and save it at exit. During gameplay, just increment the value you read in at startup.
Yeah I'll probably want to do something like that eventually.
InexorableTash · 21 Oct 2003, 18:02 UTC
The user is unlikely to hit the screenshot button more than 10 times a second; hitting the registry (vs. just enumerating the files) probably isn't worth it, and has more potential for bugs.
You only hit the registry twice, once at startup to read in the last used screenshot number, and once at shutdown to write it back out.
I wouldn't hit the registry anyways, I'd store my own settings in a file.
I took another look at my screenshots, in a different program, and they ARE NOT dithered as it had seemed. For some reason, the other program I was using shows them as dithered. Weird.