This if function that will save a small image to a text file in data statements.
The images have to be small otherwise you will run into "String overflow" errors :/ but it works for smaller images(i used it for my gui functions so didn't need to have the X and Maximize buttons as external media) although you have to load the image as a bitmap then copy that bitmap to db bitmap so it's in the right format(cuz i need 32 or 16 bit bitmap, most images arn't), then you just call the function with the text file name and the bitmap number and it saves it like this
Data Pixel1Color,Pixel2Color,Pixel3Color
Data Pixel4Color,Pixel5Color,Pixel6Color
and so on. then to use it you just paste it in a subroutine in you program and use dot and ink to draw it like so:
restore MyDataImage:
For Y = 0 to ImageHeight
For X = 0 to ImageWidth
Read Color
ink Color,0
Dot X,Y
Next x
next y
Works pretty good if you ask me.
Heres the function:
Function ConvertAndSave(File$, Bitmap)
Dim File$(769)
For X=255 to 1 : if Memblock exist(X) = 0 : Mem = X : Exit : Endif : Next x
For X=255 to 1 : if File open(X) = 0 : File = X : Exit : endif : next x
Make memblock from bitmap Mem,Bitmap
sync
For Y = 0 to Bitmap Height(Bitmap)-1
File$(Y) = "Data "
For X = 0 to Bitmap Width(Bitmap)-1
Pos = ((Y*Memblock dword(1,0))+X)*4 + 12
File$(Y) = File$(Y) + Str$(Memblock dword(1,Pos))
if X<Bitmap Width(Bitmap)-1
File$(Y) = File$(Y) + ","
endif
next x
next y
Open to Write File,File$
For Y = 0 to Bitmap Height(Bitmap)-1
Write string File,File$(Y)
next Y
Close file file : Delete memblock Mem
endfunction
New Site! Check it out \/