how can i make screenshots from my fullscreen game?
normally i can make screenshots just by pressing the print key and then copy them into photoshop or paint... today i wanted to send a pic of my work to a friend but all i get after the printkeypress+pastetophotoshop is the normal windows desktop that is _behind_ my dxwindow why? and how can i make screenshots of my game? at the current state it doesnt matter because there is not much to see but that doesnt matter... sooner or later i''ll need screenshots!
thx BiGF00T
Thats tight, but now i hafta ask (because frankly i was wanting to do the same thing) what you think the best way of storing the last number screenshot, in an ini? somehow searching the folder and finding the highest number? (another thing im curious about, how do u know whats in a folder without knowing the file names of everything? )
-Dan
-Dan
maybe u could make a screenshot folder and simply count the files in there.. or the ini file thing.. or something else but these 2 seem to be not too hard to make
I wrote an article and had a complete screen shot system setup with watermarking, video, low res screen shots, hi-res screen shots, and it supported DirectX and OpenGL (It didn''t use glGetPixels() or GetFrontBuffer()), but they never posted it!?!
Anyway, I created a "Screen Shot Manager" that handled all of that. It''s something simple, but can be tricky.
Here''s the code of how I did it:
Function to see if a certain screen shot exsists:
Function to strip the directory off:
Functions to strip the extension off:
And the heart of the whole thing:
Then to use just call it like this:
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
Anyway, I created a "Screen Shot Manager" that handled all of that. It''s something simple, but can be tricky.
Here''s the code of how I did it:
Function to see if a certain screen shot exsists:
//------------------------------------------------------------------------------------------------//--//--ScreenShotExists(*)//--Version: 1.0//--//------------------------------------------------------------------------------------------------bool SCREENSHOTSYSTEM::ScreenShotExists(const char* Filename){ WIN32_FIND_DATA FindData;// //--Make sure a valid filename is passed in if(Filename == NULL) { //--Not valid, return false return false; }// //--Try to find the file HANDLE FileHandle = FindFirstFile(Filename, &FindData);// //--If the file handle turned out to be INVALID_HANDLE_VALUE, //--then the screen shot does not exist bool Exists = (FileHandle != INVALID_HANDLE_VALUE ? true : false);// //--Close the file FindClose(FileHandle);// //--Return the result return Exists;}
Function to strip the directory off:
//------------------------------------------------------------------------------------------------//--//--StripDirectoryFromFilename(*)//--Version: 1.0//--//------------------------------------------------------------------------------------------------void SCREENSHOTSYSTEM::StripDirectoryFromFilename(char* Filename){ char Buffer[256];// //--Make sure a valid filename is passed in if(Filename == NULL) { return; } else { //--Copy the filename to the buffer sprintf(Buffer, "%s", Filename); }// //--See if the filename contains a directory separator char* InString = strrchr(Buffer, ''\\'');// //--It does if(InString) { //--Copy the file title to the filename strcpy(Filename, (InString + 1)); return; }// //--See if the filename contains this kind of directory seperator InString = strrchr(Buffer, ''/'');// //--It does if(InString) { //--Copy the file title to the filename strcpy(Filename, (InString + 1)); }}
Functions to strip the extension off:
//------------------------------------------------------------------------------------------------//--//--StripExtensionFromFilename(*)//--Version: 1.0//--//------------------------------------------------------------------------------------------------void SCREENSHOTSYSTEM::StripExtensionFromFilename(char* Filename){ int Position = 0; char Extension[5]; char Buffer[256];// //--If the filename is valid and it length is >= 4 if(Filename && strlen(Filename) >= 4) { //--Copy the last 4 characters the the extension strcpy(Extension, &Filename[strlen(Filename) - 4]);// //--Add the null terminator Extension[strlen(Extension)] = ''\0''; } else { //--Not valid, return return; }// //--If it has a valid extension on it if(Extension[0] == ''.'') { //--Loop through every character except the extension for(unsigned int ID = 0; ID < strlen(Filename) - 4; ID++) { //--Copy the current character to the buffer Buffer[Position] = Filename[ID];// //--Accumulate the buffer position Position++; }// //--Add the null terminator Buffer[Position] = ''\0'';// //--Copy the modified character array to the filename strcpy(Filename, Buffer); }}
And the heart of the whole thing:
//------------------------------------------------------------------------------------------------//--//--GetValidFilename(*)//--Version: 1.0//--//------------------------------------------------------------------------------------------------void SCREENSHOTSYSTEM::GetValidFilename(char* ValidFilename, char* Filename, bool InMovieMode){ int NewIndex = 1;// //--Make sure the filenames are valid if(ValidFilename == NULL || Filename == NULL) { return; }// if(InMovieMode == true) { //--Try this filename to see if it exists sprintf(ValidFilename, "Screen Shots\\%s.avi", Filename); } else { //--Try this filename to see if it exists sprintf(ValidFilename, "Screen Shots\\%s.bmp", Filename); }// //--See if this screen shot already exists if(ScreenShotExists(ValidFilename) == true) { //--Keep looping until we get a valid filename while(ScreenShotExists(ValidFilename) == true) { if(InMovieMode == true) { //--Create the new filename as discussed in the article _[###] sprintf(ValidFilename, "Screen Shots\\%s_%0003d.avi", Filename, NewIndex); } else { //--Create the new filename as discussed in the article _[###] sprintf(ValidFilename, "Screen Shots\\%s_%0003d.bmp", Filename, NewIndex); }// //--Accumulate the index NewIndex++; } }}
Then to use just call it like this:
void SCREENSHOTSYSTEM::SnapScreenShot(char* Filename, SCREENSHOTRESOLUTION& Resolution, int ResolutionID, bool UseTransparentColor, WATERMARKTRANSPARENTCOLOR& TransparentColor){char* ValidFilename = new char[1024];char* TempFilename = new char[1024];// //--Validate the filenames if(Filename == NULL || ValidFilename == NULL || TempFilename == NULL) { return; }// //--Copy the filename strcpy(TempFilename, Filename);// //--Strip the directory off of the filename if one exists StripDirectoryFromFilename(TempFilename);// //--Strip the file extension off of the filename if one is on there StripExtensionFromFilename(TempFilename);// //--Get a valid filename to save the screen shot to GetValidFilename(ValidFilename, TempFilename);// //--Snap the screen shot and save it using the //--ValidFilename. This will rename the files like: //--SShot001.bmp, SShot002.bmp, SShot003.bmp, etc. in //--a directory called "Screen Shots"
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
BTW, heres a few examples of what it will do:
If you type:
SnapScreenShot("SomeFolder\\SomeFolder2\\SShot.bmp");
And you save 4 screen shots you will end up with:
Screen Shots\SShot.bmp
Screen Shots\SShot_001.bmp
Screen Shots\SShot_002.bmp
Screen Shots\SShot_003.bmp
:OR:
If you type:
SnapScreenShot("SShot.bmp"); and your in movie mode, you'll get:
Screen Shots\SShot.avi
Screen Shots\SShot_001.avi
Screen Shots\SShot_002.avi
Screen Shots\SShot_003.avi
It's not the best, but it works pretty good. When you actually publish the game the users wont choose the directory to save them so thats why I defaulted them to the "Screen Shots" directory.
EDIT
Forgot the '_' Ooops
Best of luck,
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on February 29, 2004 10:07:56 PM]
If you type:
SnapScreenShot("SomeFolder\\SomeFolder2\\SShot.bmp");
And you save 4 screen shots you will end up with:
Screen Shots\SShot.bmp
Screen Shots\SShot_001.bmp
Screen Shots\SShot_002.bmp
Screen Shots\SShot_003.bmp
:OR:
If you type:
SnapScreenShot("SShot.bmp"); and your in movie mode, you'll get:
Screen Shots\SShot.avi
Screen Shots\SShot_001.avi
Screen Shots\SShot_002.avi
Screen Shots\SShot_003.avi
It's not the best, but it works pretty good. When you actually publish the game the users wont choose the directory to save them so thats why I defaulted them to the "Screen Shots" directory.
EDIT
Forgot the '_' Ooops
Best of luck,
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on February 29, 2004 10:07:56 PM]
You''re Welcome
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
-UltimaX-
Ariel Productions
"You wished for a white christmas... Now go shovel your wishes!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement