TGC Codebase Backup



NBI (non binary image) by Three Score

11th Nov 2004 21:21
Summary

a good little thing for making images with this u can make an image from notepad



Description

a very compressable format although too make a pixel precise it could take over 200kb for a 200x200 it is all acurate and perfect and can be compressed down to 2kb someitmes in a normal zip file use it as u like please put somerthing in your credits if u use it
look at the exanmple file to see wut i mean and just open it in notepad once extracted(notice that is a 2kb zip file and the file inside is 200kb)
(i will put a commented oje here soon)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem global width#
rem global height#
global ver#
rem global comp#
global valid
global q
global num#
global temp#
global colorr#,colorg#,colorb#, color#
q=34
ver#=1.6
sync off
sync rate 200
remstart
cll$=cl$()
if file exist(cll$)=1
a=1
else
end
endif
remend
open to read 1,"test4.txt"
global valid
start1:
inumb=1
read_header(inumb)
if valid=0
goto endd
endif
rem read_text(inumb)
rem lines()
rem circles()
rem boxs()
draw(inum)


endd:
suspend for key








rem declare all the functions
function read_header(inum)
read string inum,head$
if head$="nbi"
valid=1
else
valid=0
print "sorry but this is an updated or invalid image"
exitfunction
endif
read string inum,head$
temp#=val(head$)
wait 1000
if temp#>ver#
print "this is an outdated version of the interpreter please update"
print "goto http://free-space.myftp.org for updates"
valid=0
exitfunction
else
valid=1
endif
rem read string 1,temp$
rem comp#=val(temp$)
rem read string 1,temp$
rem width#=val(temp$)
read string 1,temp$
colr#=val(temp$)
read string 1,temp$
colg#=val(temp$)
read string 1,temp$
colb#=val(temp$)
color=rgb(colr#,colg#,colb#)
ink color#,color#
cls color

rem read string 1,height
rem read string 1,temp$
rem width#=val(temp$)
endfunction

function draw(inum)
sync off
cpix=1
cpiy=460
rem create bitmap 1,width,height
rem set current bitmap 1
do
read string 1,temp$
num#=val(temp$)
read string 1,temp$
colorr#=val(temp$)
read string 1,temp$
colorg#=val(temp$)
read string 1,temp$
colorb#=val(temp$)
color#=rgb(colorr#,colorg#,colorb#)
ink color#,color#
rem for i=1 to comp#
for i=1 to num#*2
read string 1,temp$
x#=val(temp$)
read string 1,temp$
y#=val(temp$)
dot x#,y#
if file end(1)=1 then exitfunction
if cpix=width#
cpiy=cpiy-1
cpix=1
endif
cpix=cpix+1
next i
loop


endfunction


function read_text(inum)
read string 1,num$
num#=val(num$)
if num#<>1
num#=num#-1
num#=num#*2
else
num#=num#*2-1
endif
if num#=0 then exitfunction
for i=1 to num#
read string 1,text$
read string 1,temp$
x#=val(temp$)
read string 1,temp$
y#=val(temp$)
text x#,y#,text$
next i
endfunction


function lines()
read string 1,temp$
num#=val(temp$)
for i=1 to num#
read string 1,red$
red#=val(red$)
read string 1,green$
green#=val(green$)
read string 1,blue$
blue#=val(blue$)
color#=rgb(red#,green#,blue#)
ink color#,color#
read string 1,temp$
x=val(temp$)
read string 1,temp$
y=val(temp$)
read string 1,temp$
x2=val(temp$)
read string 1,temp$
y2=val(temp$)
line x,y,x2,y2
next i
endfunction

function circles()
read string 1,temp$
num#=val(temp$)
for i=1 to num#
read string 1,red$
red#=val(red$)
read string 1,green$
green#=val(green$)
read string 1,blue$
blue#=val(blue$)
color#=rgb(red#,green#,blue#)
ink color#,color#
read string 1,temp$
x=val(temp$)
read string 1,temp$
y=val(temp$)
read string 1,temp$
x2=val(temp$)
read string 1,temp$
y2=val(temp$)
ellipse x,y,x2,y2
next i
endfunction

remstart
function boxs()
read string 1,temp$
num#=val(temp$)
for i=1 to num#
read string 1,red$
red#=val(red$)
read string 1,green$
green#=val(green$)
read string 1,blue$
blue#=val(blue$)
color#=rgb(red#,green#,blue#)
ink color#,
read string 1,temp$
x=val(temp$)
read string 1,temp$
y=val(temp$)
read string 1,temp$
x2=val(temp$)
read string 1,temp$
y2=val(temp$)
box x,y,x2,y2
next i
endfunction
remend