Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

screenshot?

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
Does anybody know how to get a screenshot using Qbasic 4.5 and Windows XP, Prt Scrn doesn't seem to work.
 
This might work with Windows XP ???
it works in the other Windows versions


SUB PrintScreen_Click ()

DIM y AS INTEGER, x AS INTEGER, Num AS INTEGER

DEF SEG = &HB800
LET Num = FREEFILE
OPEN "LPT1:" FOR OUTPUT AS #Num
WIDTH #Num, 255

FOR y = 1 TO 25 '-----50 or 25, depending on screen height
FOR x = 1 TO 80

SELECT CASE (PEEK(160 * (y - 1) + (x - 1) * 2))
CASE 7:
PRINT #Num, CHR$(42);
CASE ELSE
PRINT #Num, CHR$(PEEK(160 * (y - 1) + (x - 1) * 2));
END SELECT

NEXT x
PRINT #Num,
NEXT y
CLOSE #Num

DEF SEG

'----Un REM line below if you are using VBDOS 1.0
'----printer.ENDDOC


END SUB
MaxRace Software - Larry Meaux
ET_Analyst for DragRacers
Support Israel - Genesis 12:3
 
This would, of course, only work in text mode. If you want to make a graphics-mode screenshot, then you need to learn a bit about the way graphics is actually stored in memory, and also on disk. Some video editors (such as Jasc's Paint Shop Pro 6) can load "raw" files, so all you need to do is convert the pixel data to RGB component data to create such a RAW file. The following function will retrieve the RGB values for palette entries:
[tt]
SUB getPal(colourIdx%, redVal%, greenVal%, blueVal%)
OUT &H3C7, colourIdx%
redVal% = INP(&H3C9) * 255 \ 63
greenVal% = INP(&H3C9) * 255 \ 63
blueVal% = INP(&H3C9) * 255 \ 63
END SUB
[/tt]
Be aware that in EGA modes, such as SCREEN 7, the palette is actually 64 entries long, and the 16 colours you are allowed to use are mapped onto those 64 entries. This is the default mapping:
[tt]
Pixel Colour Index | Palette Colour Index
--------------------+----------------------
0 | 0
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
6 | 20
7 | 7
8 | 56
9 | 57
10 | 58
11 | 59
12 | 60
13 | 61
14 | 62
15 | 63
[/tt]
 
So I actually have to add code just to get a screenshot?

I don't have Paint Shop Pro, all I have is Microsoft Paint.
 
qbasicking - according to the people at
and


the Prt Scr function does work. They also suggest the F3 button.

It may be that you're trying to capture a text page in which case try posting to notepad.

I use Windows 2000 so haven't been able to check this out. The Prt Scr method works on this too though.

I also did a search of the MS Knowledge Base, but can't find a thing about using Prt Scr, Window capture, Screen capture, screen printing etc. in XP

Ray
 
But I can't get it to work. I have used Prt Scrn in the past, so I know it works, I beleive that I've even used it in XP, but for some reason now it doesn't.
Does it matter that I mixed up the palettes using OUT?

I'm trying to get a graphical shot, not text
 
Try using Alt-PrintScreen. If that doesn't work, then you may actually have to write some code. Aren't you a programmer?
 
Yeah, but I don't want to change my code, I just need a sreenshot to email to somebody
 
qbasicking:

Try running your program in a window instead of full screen. You should then be able to use ALT-PrtScrn to capture it.

THEN: right click > create new bitmap right on the desktop (if you don't have one already opened). Don't bother with a name right now, just open it up and try pasting it (don't forget to click yes to increase margins..if it shows up). If successful, just save it on the desktop and terminate your proggy and then re-name it.


Other suggestions:

(I have ME) check your shortcut's properties and confirm that you are not disabling ALT+PrtScrn for use by Windows (it should be in the MISC tab and have a checkmark in it).

May want to disable AV software until you have the screen done.


Otherwise, I don't know what else to offer. Good Luck --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
I can't get my program to go into a window. It works into a window until it hits SCREEN 12, how do I get it to stay in a window?
Also, I couldn't find that checkbox that you talked about, not in the Properties nor anywhere in the control panel.
 
If I were you, I would email Microsoft and ask them. I tried a few free utilities to get screenshots and none of them work in XP for DOS full-screen applications. I also searched for settings, like those checkboxes, but I could not find any (the checkboxes have been removed/moved in Windows XP).

Note to other people who attempt to find a solution: You probably must have Windows XP. Windows XP is not based on DOS, making it different from 95/98/ME (it must emulate a DOS environment for QBasic using the Command Prompt - start, run, "cmd"). Perhaps Windows NT/Windows 2000 users might know, as those versions also are not based on DOS.
 
Like I said, Alt-PrintScreen *should* work (but if it doesn't, I wouldn't be all that surprised). If all else fails, you could always use a routine like this:
[tt]
SUB dump24bitBMP (fileName$)
DIM palRed%(15), palGreen%(15), palBlue%(15)

FOR i% = 0 TO 15
OUT &H3C7, i%
palRed%(i%) = INP(&H3C9) * 255 \ 63
palGreen%(i%) = INP(&H3C9) * 255 \ 63
palBlue%(i%) = INP(&H3C9) * 255 \ 63
NEXT i%

ff% = FREEFILE
OPEN
fileName$ FOR OUTPUT AS #ff%
CLOSE #ff%
OPEN fileName$ FOR BINARY AS #ff%
header$ = "BM6" + CHR$(16) + CHR$(14) + STRING$(5, 0) + MKL$(54)
header$ = header$ + MKL$(40) + MKL$(640) + MKL$(480) + MKI$(1) + MKL$(24)
header$ = header$ + STRING$(3, 0) + CHR$(16) + CHR$(14) + CHR$(0)
header$ = header$ + MKL$(2834) + MKL$(2834) + STRING$(8, 0)
PUT #ff%, , header$

oneRow$ = SPACE$(3 * 640)
FOR y% = 479 TO 0 STEP -1
FOR x% = 0 TO 639
p% = POINT(x%, y%)
MID$(oneRow$, x% * 3 + 1, 3) = CHR$(palBlue%(p%)) + CHR$(palGreen%(p%)) + CHR$(palRed%(p%))
NEXT x%
PUT #ff%, , oneRow$
NEXT y%

CLOSE #ff%
END SUB
[/tt]
This only works in [tt]SCREEN 12[/tt], of course. For once, I actually tested my code ^_^
 
If you still have the source code add an input line (a bogus input will do) after the screen 12. At that point change it to a window with ALT+Enter type in anything to clear the input and (hopefully) that should do it.

(Example:)
Screen 12

‘ here’s where you have a chance to change
‘to window instead of full screen.


print “Here’s a chance to change to window”
print “press ALT + ENTER now and then ”
input “press ENTER to continue.”; dummy$
cls

… code continues …
(end example)

Where do you click on/activate QB45 from? IE? START menu? Explorer's file manager? Shortcut(aka link) on Desktop?

Do you even have a shortcut icon? --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
Alt-Enter for DOS boxes in graphics mode does not work under any of the Windows NT family (including XP). The application is automatically minimized. Sorry :)
 
Using Windows 2000 which is NT I've found that QBasic graphics screens aren't minimised but become windowed but frozen.

I can still use Prt Scr and Alt + Prt Scr to grab images of the Qbasic output.

This is how the series of GIFs to make up the animation for XHair (Using screen 12) on my page at were obtained.

On Windows 2000 at least, the checkboxes that MiggyD described can be found in the Misc section of the properties of QBasic.exe or the Qbasic DOS shortcut.

I've done more searches about Prt Scr and any special reported problems with Windows XP but still can't anything, except that it should work, which it obviously isn't for qbasicking.

In the past I've found problems with taking screenshots of some older DOS based games, where I've gotten either blank screens or an image "streaked" from left to right. I always put this down to the game writing directly to video memory, but I may be wrong in thinking this.

Ray
 
The only conclusion is then that it is videocard-specific. My videocard's driver certainly can't window-ize any DOS video modes (I have tested). As for the streaky video with your driver, it is because your videocard's driver is not correctly interpreting in exactly what video mode the adapter is, and thus is misinterpreting the pixel data that goes with it.
 
logicrd:
your code ran fine and saves the picture fine, but i think you have the format wrong.
I tried to open "scrnshot.bmp" in Paint and the following error showed up:

A:\SCRNSHOT.BMP
Paint cannot read this file.
This is not a valid bitmap file, or it's format is not currently supported.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top