gwbasic311

BMP files 2 bas














Home | QBASIC in XP | random number generater for codeing blogs | 3.11 & 3.23 | e-mail text | code pictures | ser ## | contact us | 98 & random files | random acess | print bmp files to screen in basic | BLOG





the following prog will read a bmp file and (kind of)recreate it on the screen.For the prog to work the bmp file must be width*.75=hight
 
10 CLS:FILES"*.*":INPUT"FILE FOR INPUT";I$
20 INPUT "E 2 to 15";E:KEY OFF:IF E<2 THEN E=9
30 OPEN "R",#1,I$,1:IF LOF(1)<1 THEN CLOSE:KILL I$:GOTO 10
40 FIELD #1,1 AS A$:A=LOF(1)
50 R=A:W=SQR((R-54)/4)/.75
60 T=W*3:U=640/T:IF W*.75<350 THEN V=1:GOTO 80
70 V=350/(W*.75)
80 Y=1:SCREEN 9
90 FOR N=A TO 54 STEP-1:GET #1,N:C=ASC(A$)
100 X=X+1:IF X=T+1 THEN X=1:Y=Y+1
110 X1=T-X:PSET(X1*U,Y*V),C/E:NEXT N
120 LOCATE 24,2:PRINT I$;" e= ";E;:INPUT " new E";E:IF E<2 THEN CLOSE:END
130 CLS:GOTO 80
by changeing the "E" the picture will change color tone
 
the next prog will put any file on the screen
 
10 KEY OFF:CLS:SHELL"DIR/P"'screen any file
20 LOCATE 25,1:INPUT"FILE FOR INPUT";I$
30 LOCATE 25,30:INPUT "E 2 to 15";E:IF E<2 THEN E=9
40 OPEN "R",#1,I$,1:IF LOF(1)<1 THEN CLOSE:KILL I$:GOTO 20
50 FIELD #1,1 AS A$:A=LOF(1):
60 Y=1:SCREEN 9:B=1
70 FOR N=B TO A:GET #1,N:C=ASC(A$)
80 X=X+1:IF X=641 THEN X=1:Y=Y+1
90 IF Y=351 THEN Y=1:LOCATE 24,1:INPUT "exit=1 or next page=2";N:IF N=2 THEN GOT
O 100 ELSE END
100 PSET(X,Y),C/E:NEXT N
110 LOCATE 24,2:PRINT I$;" e= ";E;:INPUT " new E";E:IF E<2 THEN CLOSE:END
120 CLS:GOTO 70

here agane change the "E" to change sceem.the real  test here is to make a random file that looks like some pattern
 















The following program takes a bmp pic file and converts it to a picture in gwbasic.It changes the

Colors to a basic format,and the colors can be changed by entering a new “M”.You must know the width

And hight of the picture in pixels.When using the prog the first input Will be the name of the pic

File name.bmp.Next is the width then the hight.The next input is to move the image or save it,just “enter”

If you don’t wish to save it yet or move it.Next you will be asked to enter a number (.1 to 1.5) to

Change the colors or exit without saveing it.

      After a pictur has been saved the name will be “NEWBMP.BMP”.You can go to windows paint to see it.

The file “NEWBMP.BMP” IS REUSED every time the prog is run.

 

 

 

 

10 'BASBMP.TXT

20 CLS : FILES "*.BMP": INPUT "FILE FOR INPUT"; I$' SAVEDOUB.TXT saves immage

25 INPUT "width";W:INPUT "hight";U

30 OPEN "R", #1, I$, 3: IF LOF(1) < 1 THEN CLOSE : KILL I$: GOTO 20

40 FIELD #1, 3 AS A$: R = LOF(1) - 54: A = R / 3'3 byts per pixel(a$)

60 OPEN "O", #2, "BMP.TES"'MAKE FILE TO STORE IMAGE IN

70 FOR N = A TO 54 STEP -1: GET #1, N

80 B = 0: FOR K = 1 TO 3: B = B + ASC(MID$(A$, K, 1)): NEXT K'add 3 asci numbers

90 B = B / 3: B = SQR(B): B$ = CHR$(B)'get sqr of average (b)

100 PRINT #2, B$; 'send to storage file

110 NEXT N

120 CLOSE

140 L=1: M=1:MV = 20'm is m to change graphics(.1 to 1),mv=kentucky windage

150 OPEN "R", #3, "BMP.TES", 1: SCREEN 9: KEY OFF

160 FIELD #3, 1 AS C$

170 FOR Y = 0 TO 350

180 FOR X = W - 1 TO 0 STEP -1: GET #3'get picture and set width of scan check end

190 IF X - MV < -50 OR X - MV > 750 THEN GOTO 210'no scan off screen

200 PSET (X - MV, Y), ASC(C$) * M'm changes asc number (ie .15, .32, .95)

210 NEXT X

220 NEXT Y

230 IF G = 5 THEN GOTO 370

240 BEEP: LOCATE 25, 1: INPUT "up=1,down=2,rite=3,lft=4 or save=5"; G: IF G = 0 THEN 310

250 IF G = 2 AND L < 10 THEN GOTO 350

260 IF G = 3 AND MV = 20 THEN GOTO 360

270 IF G = 1 THEN L = L + 150: L1 = L * W: GOTO 310'up X 150 lines

280 IF G = 2 THEN L = L - 150: L1 = L * W: GOTO 310'down X 150

290 IF G = 3 THEN MV = MV - 200: L1 = L: GOTO 310'move right

300 IF G = 4 THEN MV = MV + 200: L1 = L: GOTO 310'move left

310 LOCATE 25,1:PRINT "                M= "; M; :INPUT"new M or exit = 100"; M:IF M=100 THEN CLOSE:END

320 IF M = 0 THEN PRINT "NEED NUMBER": GOTO 310

330 IF L1 = 0 THEN L1 = 1

340 CLS:GET #3, L1: GOTO 170'set start of read

350 L = 1: PRINT "can't go down": GOTO 240

360 MV = 20: PRINT "can't go right": GOTO 240

370 OPEN "R",#1,"PRTSCR.TXT",1'temp file to store screen scan

380 FIELD #1,1 AS A$

390 FOR Y=1 TO 350

400 FOR X=640 TO 1 STEP -1'reverse scan for bmp file

410 P=POINT(X,Y):P=P+1:LSET A$=CHR$(P):PUT #1'send scan to temp file

420 NEXT X

430 NEXT Y

440 CLOSE

450 'lines 5000-5080 make H$;the header for a 640X350 bmp file

5000 H$=H$+CHR$(66):H$=H$+CHR$(77):H$=H$+CHR$(54):H$=H$+CHR$(65):H$=H$+CHR$(10)

5010 H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(54)

5020 H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(40):H$=H$+CHR$(0):H$=H$+CHR$(0)

5030 H$=H$+CHR$(0):H$=H$+CHR$(128):H$=H$+CHR$(2):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(94)

5040 H$=H$+CHR$(1):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(1):H$=H$+CHR$(0):H$=H$+CHR$(24)

5050 H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0)

5060 H$=H$+CHR$(65):H$=H$+CHR$(10):H$=H$+CHR$(0):H$=H$+CHR$(196):H$=H$+CHR$(14):H$=H$+CHR$(0)

5070 H$=H$+CHR$(0):H$=H$+CHR$(196):H$=H$+CHR$(14):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0)

5080 H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0):H$=H$+CHR$(0)

5090 DIM C$(20)

5100 C$(0)=CHR$(0)+CHR$(0)+CHR$(0):C$(1)=CHR$(255)+CHR$(0)+CHR$(0):C$(2)=CHR$(0)+CHR$(255)+CHR$(0)

5110 C$(3)=CHR$(255)+CHR$(255)+CHR$(0):C$(4)=CHR$(0)+CHR$(0)+CHR$(255):C$(5)=CHR$(128)+CHR$(0)+CHR$(128)

5120 C$(6)=CHR$(0)+CHR$(64)+CHR$(128):C$(7)=CHR$(128)+CHR$(128)+CHR$(128):C$(8)=CHR$(192)+CHR$(192)+CHR$(192)

5130 C$(9)=CHR$(255)+CHR$(0)+CHR$(64):C$(10)=CHR$(128)+CHR$(255)+CHR$(0):C$(11)=CHR$(255)+CHR$(255)+CHR$(0)

5140 CHR$(12)=CHR$(0)+CHR$(0)+CHR$(255):C$(13)=CHR$(255)+CHR$(0)+CHR$(255):C$(14)=CHR$(128)+CHR$(255)+CHR$(255)

5145 C$(15)=CHR$(255)+CHR$(255)+CHR$(255)

5150 OPEN "R",#1,"PRTSCR.TXT",1'final send to temp file

5160 FIELD #1,1 AS A$

5170 FOR Y=1 TO 350

5180 FOR X=640 TO 1 STEP -1

5190 P=POINT(X,Y):P=P+1

5200 LSET A$=CHR$(P):PUT #1

5220 NEXT X

5230 NEXT Y

5240 CLOSE

5250 OPEN "O" ,#1,"NEWBMP.BMP"

5260 PRINT #1,H$:CLOSE

5270 OPEN "R" ,#1 ,"PRTSCR.TXT",1'SCR FILE read scan file

5280 FIELD #1 ,1 AS A$:L=LOF(1)

5290 OPEN "R" ,#2 ,"NEWBMP.BMP",3'bmp file of scan

5300 FIELD #2, 3 AS B$:E=18

5310 FOR B=L TO 1 STEP -1

5320 GET #1,B:C=ASC(A$):IF C=0 THEN GOTO 5340

5330 C=C-1

5340 LSET B$=C$(C):E=E+1

5350 PUT #2,E

5360 NEXT B

5370 BEEP:BEEP

5380 CLOSE:END
















in the above prog three lines must be changed to work,there can't be any wrap.
they are lines 5120,5130 and 5140
 e-mail any questions




Enter secondary content here


Enter secondary content here