Hey guys!
If you are active in the dbc challenge thread, you may need this, because you are not allowed to include any media such as images.
Anyway, I attached an exe, and here is the code:
Rem * Author : TheComet
rem setup program
always active on
set window on
set window title "Image extractor v1.00 - by TheComet"
rem setup arrays
for t=1 to 25
dim col(t)
next t
rem get info from user
print
print
input "Please enter the file name>",file$
input "Please enter the width to crop>",width$
input "Please enter the height to crop>",height$
print
print
print "processing image..."
print "estimated time required:"+str$((val(width$)*val(height$))/15)+" seconds"
input "Press Enter to start...",j$
rem load the bitmap
load bitmap file$,1
rem delete file if already existing
if file exist("imageout.DBA")=1 then delete file "imageout.DBA"
rem open a file to write into
open to write 1,"imageout.DBA"
rem info
write string 1,"`Image extractor v1.00 - by TheComet"
write string 1,"`Copy and paste this into your program"
rem define label at start of program
write string 1,"image:"
rem write width and height
write string 1,"data "+str$(val(width$))+","+str$(val(height$))
rem extract colors and write them to file
g=0
for x=1 to val(width$)
for y=1 to val(height$)
inc g
col(g)=point(x,y)
if g=25
string1$=str$(col(1))+","+str$(col(2))+","+str$(col(3))+","+str$(col(4))+","+str$(col(5))
string2$=","+str$(col(6))+","+str$(col(7))+","+str$(col(8))+","+str$(col(9))+","+str$(col(10)) string3$=","+str$(col(11))+","+str$(col(12))+","+str$(col(13))+","+str$(col(14))+","+str$(col(15))
string4$=","+str$(col(16))+","+str$(col(17))+","+str$(col(18))+","+str$(col(19))+","+str$(col(20))
string5$=","+str$(col(21))+","+str$(col(22))+","+str$(col(23))+","+str$(col(24))+","+str$(col(25))
write string 1,"data "+string1$+string2$+string3$+string4$+string5$
g=0
endif
next y
next x
rem finish arrays off
if g<>0 and g<25
string1$="data "+str$(col(1))
if g>1
for t=2 to g
string1$=string1$+","+str$(col(g))
next t
endif
write string 1,string1$
endif
close file 1
delete bitmap 1
print
print
input "Finished! Press Enter to exit...",j$
end
How to use:
execute the program.
it will ask you for a file to load. That file HAS to be in the same directory as the program. Type in the name of the image file and the extension (.bmp/.jpg/.png)
Then it will ask for the width and the height. It must not exceed the bitmap size.
Once that is done, you will get an estimated time, how long it will take (64*64 is about 3 minutes, because the stupid "point()" command is too slow, so don`t make your image too big). Press Enter to start.
While this is processing, you can minimize the program, and it will still run, meaning, you can carry on with your code.
It will save the image to a file in the same directory called "imageout.dba"
When finished, you can simply copy the code inside that file, and paste it at the bottom of your program.
Now, to load your image, use this code:
rem generate image
restore image
read tx
read ty
create bitmap 1,tx,ty
for x=1 to tx
for y=1 to ty
read col
r=rgbr(col)
g=rgbg(col)
b=rgbb(col)
ink rgb(r,g,b),rgb(r,g,b)
dot x,y
next y
next x
get image 1,0,0,tx,ty
delete bitmap 1
I would greatly appreciate some better, more developed code to speed this process up.
Hope it helps!
TheComet
Oooooops!!! I accidentally formated drive c.