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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Qbasic WinXP AND Print Screen 1

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
US
I just noticed that print screen does not work on my pc (WinXP Home) when in QB...

I know it used to work on my old Win98 machine...

Code:
-----------------
*Notes:
  WinXP
  QB 4.5
  Compiled EXE
  Screen 13
  Custom Palette
-----------------

Is this the same for everyone else???

Or is it just My PC???

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
I'm guessing that stupid microsoft took that out deliberatly because it wants to get rid of as much DOS complatibility as it can. My school has XP so I'll go test it out there and see if it works though. :)
 
I tested it on my lil brothers 98, and it worked perfectly, so I'm guessing that is the case...

It probably has something to do with the fact that it runs in 16 bit mode... And XP is based on NT so it is 32 bit, where 98 was still based on 16 bit dos with 32 bit support...

I'm suprised that QB still runs on XP machines... nothing else seems to... (such as DJGPP)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
If you want to make a screenshot I could give you a little code to add to your program. It will make a bitmap out of the screen, but I only know how to do it for 4 and 8 bit screen modes, and the code is different for each one, which SCREEN are you using?
 
Yeah...

(Screen 13)

You can use BSAVE with DEF SEG = &HA000 to save the image to your hard drive...
Then Translate it with Paint Shop Pro or write a program to output a gif or bitmap...

But I was just suprised when I pressed PrntScrn in my program then opened up Paint and it did not give me an option to paste...

lol... I guess microsoft is serious about doing away with Dos... ;-)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
OK...

IF YOU HAVE PAINT SHOP PRO (I used version 7)

You can use this code in your program to dump the screen and palette to your hard drive...

*Note: This is for Screen 13 ONLY

Code:
'*********** Save Image ***********
DEF SEG = &HA000
BSAVE "zzz.raw", 0, 64000

'********** Save Palette **********
OPEN "zzz.pal" FOR OUTPUT AS #1
PRINT #1, "JASC-PAL" 'Jasc Palette Format
PRINT #1, "0100"     '8 bit
PRINT #1, "256"      '256 colors
OUT &H3C7, 0
FOR i = 0 TO 255
  r = (INP(&H3C9) * 255) \ 63   'Convert Octal Red Value to Hex
  g = (INP(&H3C9) * 255) \ 63   'Convert Octal Green Value to Hex
  b = (INP(&H3C9) * 255) \ 63   'Convert Octal Blue Value to Hex
  PRINT #1, LTRIM$(STR$(r) + STR$(g) + STR$(b))
NEXT
CLOSE

Now you should have 2 files...
zzz.raw <--- The Image File
zzz.pal <--- The Palette File

Now open Jasc Paint Shop Pro 7 (or whatever version you have)

Drag/Drop the RAW file into the PSP7 window (Or click File/Open... Select RAW file type)

Now you should get a Dialog Box, Set the options like this:
Image Size:
Width: 320
Height: 200

Color Channels:
Single Channel(greyscale) (Default)

File structure:
Header Size: 7
Interleaved (RGB RGB...) (Default)
Order RGB (Default)

Then press OK

Now you should see a greyscale image of your drawing...
And you probably want to add a little COLOR...

Select the menu: Colors/Load Palette...

If a Warning dialog box appears, click Yes...

Select Maintain indexes

Open zzz.pal and you are done...

OK... Now that you have it in PSP7, you can edit it, put it in an animation, and/or save it as any file format you want...

This has to be the EASIEST WAY to make GIFs & BMPs in Qbasic...

Minimum Code Required ;-)

Hope you enjoyed my little tutorial :)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Hello. I´m not in my case. In my PC the text in qb is normal(but I have wXP profesional). I also have noticed that many dos programs under Windows WP prints the text big
 
Here is a sub that saves the SCREEN 13 screen or any portion of it.


SUB SaveBMP (FileName$, MinX, MinY, MaxX, MaxY)

WidthInPixels = (MaxX - MinX) + 1: LengthInPixels = (MaxY - MinY) + 1: a& = 1

OPEN FileName$ FOR BINARY AS #1
IF LOF(1) <> 0 THEN
CLOSE #1
KILL FileName$
OPEN FileName$ FOR BINARY AS #1
END IF

ValidBMP$ = &quot;BM&quot;: Empty$ = MKL$(0): PictureDataOffset$ = MKL$(1078)

PUT #1, , ValidBMP$ '/* Valid BMP's have 'BM' as the first two char's'
PUT #1, , Empty$ '/* Reserved until file size is calculated'
PUT #1, , Empty$ '/* Used to make the bytes in the file empty'
PUT #1, , PictureDataOffset$ '/* Offset of the Picture Data'

'/* Header Variables */'
WinOrOS2$ = MKL$(40): WidthInPixels$ = MKL$(WidthInPixels)
LengthInPixels$ = MKL$(LengthInPixels): NoOfPlanes$ = MKI$(1)
NoOfBits$ = MKI$(8): NoCompression$ = MKL$(0): AllColors$ = MKL$(0)

IF (4 - (WidthInPixels MOD 4)) = 4 THEN
SizeOfImageInBytes$ = MKL$((WidthInPixels * LengthInPixels))
ELSE
SizeOfImageInBytes$ = MKL$(((WidthInPixels + (4 - (WidthInPixels MOD 4))) * LengthInPixels))
END IF

PUT #1, , WinOrOS2$ '/* Defining if this is a Windows or OS/2 BMP'
PUT #1, , WidthInPixels$ '/* The Width of the Image in Pixels'
PUT #1, , LengthInPixels$ '/* The Length of the Image in Pixels'
PUT #1, , NoOfPlanes$ '/* Number of Planes. Shoule be 1'
PUT #1, , NoOfBits$ '/* Number of Bits. Should be 8'
PUT #1, , NoCompression$ '/* There is No Compression'
PUT #1, , SizeOfImageInBytes$ '/* Size of the picture data in bytes'
PUT #1, , Empty$ '/* Using this variable to keep the place blank in file'
PUT #1, , Empty$ '/* Using this variable to keep the place blank in file'
PUT #1, , AllColors$ '/* Number of Colors Used
PUT #1, , AllColors$ '/* Important Colors

'/* Palette Info */'
Empty$ = SPACE$(1)

FOR Colors = 0 TO 255
'/* Extracts the Palette of each of the 256 colors into a red, green and */'
'/* blue sections and places them into their corresponding variables */'
OUT &H3C6, &HFF
OUT &H3C7, Colors
Red$ = CHR$(INP(&H3C9) * 4): Green$ = CHR$(INP(&H3C9) * 4): Blue$ = CHR$(INP(&H3C9) * 4)
'/* Places the extracted colors into the given file */'
PUT #1, , Blue$
PUT #1, , Green$
PUT #1, , Red$
PUT #1, , Empty$
NEXT Colors

SCREEN 13
'/* Saves the screen portion into BSAVE format */'
DIM Image%(1 TO 32767)
GET (MinX, MinY)-(MaxX, MaxY), Image%
ImageVarSeg = VARSEG(Image%(1))
ImageVarOffset = VARPTR(Image%(1))
DEF SEG = ImageVarSeg
BSAVE &quot;temp.fil&quot;, ImageOffset, WidthInPixels * LengthInPixels

LineOfBytes$ = SPACE$(WidthInPixels): Padding$ = SPACE$(0)
IF (4 - (WidthInPixels MOD 4)) <> 4 THEN Padding$ = SPACE$((4 - (WidthInPixels MOD 4)))

Empty$ = SPACE$(11)
OPEN &quot;temp.fil&quot; FOR BINARY AS #2
'/* Extracts the unnecessary BSAVE format info */'
GET #2, , Empty$

FOR Loops = LengthInPixels - 1 TO 0 STEP -1
'/* Extracts the bytes from the BSAVE file and places it into the BMP file */'
GET #2, 12 + (WidthInPixels * Loops), LineOfBytes$
PUT #1, , LineOfBytes$
LINE (MinX, Loops)-(MaxX, Loops), 0
'/* Puts extra padding into BMP if any is needed */'
PUT #1, , Padding$
NEXT Loops
CLOSE #2: KILL &quot;temp.fil&quot;

'/* Places the size of the file into the file */'
SizeOfFile$ = MKL$(LOC(1))
PUT #1, 3, SizeOfFile$

END SUB
 
This saves any part of the SCREEN 12 screen into a 4bit bitmap.

DECLARE SUB SAVE4BIT (FileName$, MinX, MinY, MaxX, MaxY)
TYPE BMPHeader
ValidID AS STRING * 2
SizeOfFile AS LONG
Reserved AS LONG
OffsetOfBitMap AS LONG
END TYPE
TYPE WindowsBMPInfoHeader
SizeOfHeader AS LONG
Widthz AS LONG
Heightz AS LONG
Planes AS INTEGER
BitsPerPixel AS INTEGER
CompressMethod AS LONG
ImageSizeInBytes AS LONG
HorizontalResol AS LONG
VerticalResol AS LONG
ColorsUsed AS LONG
ImportantColors AS LONG
END TYPE
CALL SAVE4BIT(&quot;4bit.bmp&quot;, 0, 0, 639, 479)

DEFINT A-Z
SUB SAVE4BIT (FileName$, MinX, MinY, MaxX, MaxY)
OPEN FileName$ FOR BINARY AS #255
IF LOF(255) <> 0 THEN
CLOSE
KILL FileName$
OPEN FileName$ FOR BINARY AS #255
END IF
ImageWidth = (MaxX - MinX) + 1: ImageHeight = (MaxY - MinY) + 1
DIM BMPHeader AS BMPHeader
DIM WindowsBMPInfoHeader AS WindowsBMPInfoHeader
WindowsBMPInfoHeader.SizeOfHeader = 40
WindowsBMPInfoHeader.Widthz = ImageWidth
WindowsBMPInfoHeader.Heightz = ImageHeight
WindowsBMPInfoHeader.Planes = 1
WindowsBMPInfoHeader.BitsPerPixel = 4
WindowsBMPInfoHeader.CompressMethod = 0
WindowsBMPInfoHeader.ColorsUsed = 16
WindowsBMPInfoHeader.ImportantColors = 16
PUT #255, 15, WindowsBMPInfoHeader
Empty$ = SPACE$(1)
SCREEN 12
FOR Colors = 0 TO 15
OUT &H3C6, &HFF
OUT &H3C7, Colors
Red$ = CHR$(INP(&H3C9) * 4): Green$ = CHR$(INP(&H3C9) * 4)
Blue$ = CHR$(INP(&H3C9) * 4): AllColorz$ = Blue$ + Green$ + Red$ + Empty$
PUT #255, , AllColorz$
NEXT Colors
Padding$ = SPACE$(0)
IF (4 - ((BMPInfoHeader.Widthz MOD 8) / 2)) <> 4 THEN
Padding$ = SPACE$((4 - ((BMPInfoHeader.Widthz MOD 8) / 2)))
END IF
FOR Loops = MaxY TO MinY STEP -1
FOR Lips = MinX TO MaxX STEP 2
Byte = POINT(Lips, Loops) * 16
IF Lips + 1 <= MaxX THEN
Byte = (Byte OR POINT(Lips + 1, Loops))
END IF
Bytez$ = Bytez$ + CHR$(Byte)
Byte = 0
NEXT Lips
LINE (MinX, Loops)-(MaxX, Loops), 0
PUT #255, , Bytez$
PUT #255, , Padding$
Bytez$ = &quot;&quot;
NEXT Loops
BMPHeader.ValidID = &quot;BM&quot;
BMPHeader.SizeOfFile = LOF(255)
BMPHeader.OffsetOfBitMap = 118
PUT #255, 1, BMPHeader
CLOSE
END SUB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top