Build CSS art easily with this converter.
Here's an example:
http://cca-software.com/css_skull.htm
`filename$ = "C:\apollo_logo.bmp"
filename$ = "C:\skull.bmp"
load image filename$, 1, 1
make memblock from image 1, 1
delete image 1
rem size of each pixel
size = 4
width = memblock dword(1,0)
height = memblock dword(1,4)
pixel_count = width*height
type ColorBlock
red as integer
green as integer
blue as integer
endtype
dim colors(0) as ColorBlock
rem create the palette
trans as dword
trans = rgb(255,255,255)
color as dword
for i = 0 to pixel_count-1
pos = i*4 + 12
color = memblock dword(1, pos)
if color <> trans then addKey(color)
next i
rem begin file creation
open to write 1, "c:\css_skull.htm"
write string 1, "<html>"
write string 1, "<head>"
write string 1, "<style type="+chr$(34)+"text/css"+chr$(34)+">"
write string 1, ".base{"
write string 1, chr$(9)+"position: absolute;"
write string 1, chr$(9)+"width: "+str$(size)+"px;"
write string 1, chr$(9)+"height: "+str$(size)+"px;"
write string 1, chr$(9)+"text-align: center;"
write string 1, "}"
rem build the css
for i = 1 to array count(colors())
r = colors(i).red
g = colors(i).green
b = colors(i).blue
write string 1, ".base.pix"+str$(i)+"{"
write string 1, chr$(9)+"background-color: rgb("+str$(r)+","+str$(g)+","+str$(b)+");"
write string 1, "}"
next i
write string 1, "</style>"
write string 1, "</head>"
write string 1, "<body>"
rem draw the image
for y = 0 to height-1
for x = 0 to width-1
pos = (y*width+x)*4+12
color = memblock dword(1, pos)
if color <> trans
k = getKey(color)
style$ = "top:"+str$(y*size)+"px; left:"+str$(x*size)+"px;"
write string 1, "<div class="+chr$(34)+"base pix"+str$(k)+chr$(34)+" style="+chr$(34)+style$+chr$(34)+"></div>"
endif
next x
write string 1, "<!-- Row "+str$(y+1)+" -->"
next y
wait key
write string 1, "</body>"
write string 1, "</html>"
close file 1
delete memblock 1
end
function addKey(color as dword)
for t = 1 to array count(colors())
r = colors(t).red
g = colors(t).green
b = colors(t).blue
if r = rgbr(color) and g = rgbg(color) and b = rgbb(color) then exitfunction
next t
array insert at bottom colors()
index = array count(colors())
colors(index).red = rgbr(color)
colors(index).green = rgbg(color)
colors(index).blue = rgbb(color)
endfunction
function getKey(color as dword)
for t = 1 to array count(colors())
r = colors(t).red
g = colors(t).green
b = colors(t).blue
if r = rgbr(color) and g = rgbg(color) and b = rgbb(color) then exitfunction t
next t
endfunction 0