主题:basic显示大话2was格式图片代码(正在完善中……速度慢些)
先说明,因此程序不支持汉字显示,自己做了个点阵字显示,朋友们可以直接将汉字显示处屏掉用英文代替。如有不清楚的地方和好的建议,欢迎密我哟,QQ:7552169.如有同好者请加入兴趣小组哟。。。
Graphics 800,600,16
Include "hanzi.bb"
filein = ReadFile("mydata.txt")
A1$ = ReadLine$( filein )
A2$ = ReadLine$( filein )
A3$ = ReadLine$( filein )
A4$ = ReadLine$( filein )
A5$ = ReadLine$( filein )
A6$ = ReadLine$( filein )
A7$ = ReadLine$( filein )
A8$ = ReadLine$( filein )
A9$ = ReadLine$( filein )
CloseFile( filein )
Global file = ReadFile( "p\1.was" )
SeekFile ( file, 0) ; Move to the found location
aa1 = ReadByte( file )
aa2 = ReadByte( file )
If Chr$(aa1)+Chr$(aa2) <>"SP" Then CloseFile( file ):End
filehead = ReadShort( file )
spritenum= ReadShort( file )
framenum= ReadShort( file )
npcWidth= ReadShort( file )
npcHeight= ReadShort( file )
npcx= ReadShort( file )
npcy= ReadShort( file )
viewhz a1$+": "+"SP",0,0
viewhz a2$+": "+filehead,0,20
viewhz a3$+": "+spritenum,0,40
viewhz a4$+": "+framenum,0,60
viewhz a5$+": "+npcWidth,0,80
viewhz a6$+": "+npcHeight,0,100
viewhz a7$+": "+npcx,0,120
viewhz a8$+": "+npcy,0,140
;Dim pal(256)
;SeekFile ( file, filehead+5)
;For i=0 To 255
; pal(i)= ReadShort(file)
;Next
pianyi=spritenum*framenum*4
bbb=filehead +pianyi+512
viewhz a9$+": "+a3$+"*"+a4$+"*pianyi+"+a2$+"+512="+bbb,0,160
SeekFile ( file, bbb)
i=ReadShort(file)
Locate 0,180
Print bbb+"=Hex:"+Hex$(bbb)+" "+i+"=Hex: "+Hex$(i)
SeekFile ( file, bbb+4)
picx = readp()
pixy = readp()
picw =readp()
pich =readp()
Global width=picw-1
Global height=pich-1
Dim lenwidth(height)
Dim alpha(width*height*4)
Dim index(width*height*4)
SeekFile ( file, bbb+20)
For i=0 To height
lenwidth(i)=readp()+532
Next
For y=0 To height-1
x=0
SeekFile ( file, lenwidth(y))
While x<=width
ddjjdd=ReadByte(file)
Select ddjjdd And %11000000
Case %00000000
If (ddjjdd And %00100000) >0 Then
alpha(y*width+x)=ddjjdd And %00011111
index(y*width+x)=ReadByte(file)
x=x+1
Else If ddjjdd<>0 Then
tmp=ddjjdd And %00011111
tmp2=ReadByte(file)
tmp3=tmp2 And %00011111
ddjjdd=ReadByte(file)
For i=0 To tmp-1
alpha(y*width+x)=tmp3
index(y*width+x)=ddjjdd
x=x+1
Next
Else
If x>width Then
x=width
EndIf
EndIf
Case %01000000
tmp=ddjjdd And %00111111
For i=0 To tmp-1
ddjjdd=ReadByte(file)
alpha(y*width+x)=%00111111
index(y*width+x)=ddjjdd
x=x+1
Next
Case %10000000
tmp=ddjjdd And %00111111
ddjjdd=ReadByte(file)
For i=0 To tmp-1
alpha(y*width+x)=%00011111
index(y*width+x)=ddjjdd
x=x+1
Next
Case %11000000
tmp=ddjjdd And %00111111
x=x+tmp
End Select
Wend
Next
c=pppp()
CloseFile( file )
WaitKey()
End
Function readp()
b=0
aaa1=ReadByte(file)
aaa2=ReadByte(file)
aaa3=ReadByte(file)
aaa4=ReadByte(file)
If aaa1>0 Then b=b+aaa1
If aaa4>0 Then b=b+(aaa4 Shl 32) ;aaa4*16777216
If aaa3>0 Then b=b+(aaa3 Shl 16) ;aaa3*65536
If aaa2>0 Then b=b+(aaa2 Shl 8) ;aaa2*256
Return b
End Function
Function pppp()
;rrgb=PeekByte (bnkTest,ccc)
; cccn=ccc*2
; rgb2=PeekByte (bnkTest,cccn)
; rgb1=PeekByte (bnkTest,cccn+1)
;565 rrrrrggg gggbbbbb
; r=(rgb2 And %11111000)
; g = (rgb1 And %11100000) + (rgb2 And %00000111)
; b = (rgb1 And %00011111)
;a555 arrrrrgg gggbbbbb
; r=(rgb2 And %01111100)
; g = (rgb1 And %11100000) + (rgb2 And %00000011)
; b = (rgb1 And %00011111)
For y=0 To height-1
For x=0 To width-1
Color 0,index(y*width+x),0
Plot x+200,y+100
Next
Next
End Function
Graphics 800,600,16
Include "hanzi.bb"
filein = ReadFile("mydata.txt")
A1$ = ReadLine$( filein )
A2$ = ReadLine$( filein )
A3$ = ReadLine$( filein )
A4$ = ReadLine$( filein )
A5$ = ReadLine$( filein )
A6$ = ReadLine$( filein )
A7$ = ReadLine$( filein )
A8$ = ReadLine$( filein )
A9$ = ReadLine$( filein )
CloseFile( filein )
Global file = ReadFile( "p\1.was" )
SeekFile ( file, 0) ; Move to the found location
aa1 = ReadByte( file )
aa2 = ReadByte( file )
If Chr$(aa1)+Chr$(aa2) <>"SP" Then CloseFile( file ):End
filehead = ReadShort( file )
spritenum= ReadShort( file )
framenum= ReadShort( file )
npcWidth= ReadShort( file )
npcHeight= ReadShort( file )
npcx= ReadShort( file )
npcy= ReadShort( file )
viewhz a1$+": "+"SP",0,0
viewhz a2$+": "+filehead,0,20
viewhz a3$+": "+spritenum,0,40
viewhz a4$+": "+framenum,0,60
viewhz a5$+": "+npcWidth,0,80
viewhz a6$+": "+npcHeight,0,100
viewhz a7$+": "+npcx,0,120
viewhz a8$+": "+npcy,0,140
;Dim pal(256)
;SeekFile ( file, filehead+5)
;For i=0 To 255
; pal(i)= ReadShort(file)
;Next
pianyi=spritenum*framenum*4
bbb=filehead +pianyi+512
viewhz a9$+": "+a3$+"*"+a4$+"*pianyi+"+a2$+"+512="+bbb,0,160
SeekFile ( file, bbb)
i=ReadShort(file)
Locate 0,180
Print bbb+"=Hex:"+Hex$(bbb)+" "+i+"=Hex: "+Hex$(i)
SeekFile ( file, bbb+4)
picx = readp()
pixy = readp()
picw =readp()
pich =readp()
Global width=picw-1
Global height=pich-1
Dim lenwidth(height)
Dim alpha(width*height*4)
Dim index(width*height*4)
SeekFile ( file, bbb+20)
For i=0 To height
lenwidth(i)=readp()+532
Next
For y=0 To height-1
x=0
SeekFile ( file, lenwidth(y))
While x<=width
ddjjdd=ReadByte(file)
Select ddjjdd And %11000000
Case %00000000
If (ddjjdd And %00100000) >0 Then
alpha(y*width+x)=ddjjdd And %00011111
index(y*width+x)=ReadByte(file)
x=x+1
Else If ddjjdd<>0 Then
tmp=ddjjdd And %00011111
tmp2=ReadByte(file)
tmp3=tmp2 And %00011111
ddjjdd=ReadByte(file)
For i=0 To tmp-1
alpha(y*width+x)=tmp3
index(y*width+x)=ddjjdd
x=x+1
Next
Else
If x>width Then
x=width
EndIf
EndIf
Case %01000000
tmp=ddjjdd And %00111111
For i=0 To tmp-1
ddjjdd=ReadByte(file)
alpha(y*width+x)=%00111111
index(y*width+x)=ddjjdd
x=x+1
Next
Case %10000000
tmp=ddjjdd And %00111111
ddjjdd=ReadByte(file)
For i=0 To tmp-1
alpha(y*width+x)=%00011111
index(y*width+x)=ddjjdd
x=x+1
Next
Case %11000000
tmp=ddjjdd And %00111111
x=x+tmp
End Select
Wend
Next
c=pppp()
CloseFile( file )
WaitKey()
End
Function readp()
b=0
aaa1=ReadByte(file)
aaa2=ReadByte(file)
aaa3=ReadByte(file)
aaa4=ReadByte(file)
If aaa1>0 Then b=b+aaa1
If aaa4>0 Then b=b+(aaa4 Shl 32) ;aaa4*16777216
If aaa3>0 Then b=b+(aaa3 Shl 16) ;aaa3*65536
If aaa2>0 Then b=b+(aaa2 Shl 8) ;aaa2*256
Return b
End Function
Function pppp()
;rrgb=PeekByte (bnkTest,ccc)
; cccn=ccc*2
; rgb2=PeekByte (bnkTest,cccn)
; rgb1=PeekByte (bnkTest,cccn+1)
;565 rrrrrggg gggbbbbb
; r=(rgb2 And %11111000)
; g = (rgb1 And %11100000) + (rgb2 And %00000111)
; b = (rgb1 And %00011111)
;a555 arrrrrgg gggbbbbb
; r=(rgb2 And %01111100)
; g = (rgb1 And %11100000) + (rgb2 And %00000011)
; b = (rgb1 And %00011111)
For y=0 To height-1
For x=0 To width-1
Color 0,index(y*width+x),0
Plot x+200,y+100
Next
Next
End Function