02-24-2005, 05:59 AM
Code:
screen 18
type chopinteger field = 1
left as ushort
right as ushort
end type
type BMPFileInfo field = 1
BIid as short
BIfilesize as long
BIreserved as short
BIreserved2 as short
BIoffset as long
end type
type BMPHeaderInfo field = 1
BIheadersize as long
BIwidth as integer
BIheight as integer
BIplanes as short
BIbpp as short
BIcompressionfactor as long
BIimagesize as long
BIpelwidth as long
BIpelheight as long
BIcolorused as long
BIimportantcolors as long
end type
type RGBQuad field = 1
blue as ushort
green as ushort
red as ushort
end type
dim fileheader as BMPFileInfo
dim infoheader as BMPHeaderInfo
dim colors(255) as RGBQuad
dim pixelint as chopinteger
dim rgbbloc as chopinteger
dim grabpixels as ushort
dim rgbhold as uinteger
xdifferential = 0
ydifferential = 0
open command$ for binary as #1
get #1,, fileheader
get #1,, infoheader
dim picarray(4 + (infoheader.BIwidth * infoheader.BIheight)) as ushort
for grabcolors = 0 to 255
get #1,, rgbbloc.left
get #1,, rgbbloc.right
colors(grabcolors).red = (rgbbloc.left and 255) \ 4
colors(grabcolors).green = (rgbbloc.left shr 8) \ 4
colors(grabcolors).blue = (rgbbloc.right and 255) \ 4
palette grabcolors, rgb(colors(grabcolors).red, colors(grabcolors).green, colors(grabcolors).blue)
next
for y = (infoheader.BIheight) to 1 step -1
for x = 1 to ((infoheader.BIwidth) \ 2)
get #1,, grabpixels
pixelint.left = grabpixels and 255
pixelint.right = grabpixels shr 8
pset((x * 2) - 1 + xdifferential,(y - 1) + ydifferential), pixelint.left
pset((x * 2) + xdifferential,(y - 1) + ydifferential), pixelint.right
next
next
close #1
get (0,0)-(infoheader.BIwidth, infoheader.BIheight), picarray
'sleep
cls
put (0,0), picarray
open "hudsprite.spr" for binary as #1
put #1,, picarray()
for colorstash = 0 to 255
rgbhold = rgb(colors(colorstash).red, colors(colorstash).green, colors(colorstash).blue)
put #1,, rgbhold
next
close
sleep
crappy lil bmp load i made..
one of the biggest things i was having problems with is that when i did the foor loops from
0 to infoheader .BIwidth - 1
as opposed to
1 to infoheader .BIwidth
a always got incorrect output... the bmp leaned
anyone know why? :o