writing numbers to file

new topic     » topic index » view thread      » older message » newer message

Hello again,

Thanks, Irv, for your help. Using your suggestions I have gotten a little
further but I am still having problems. Here is my troubled code:

include image.e
include graphics.e

integer fn, n

sequence bitmap, data
bitmap = {}
data = {}

n = graphics_mode(257)

--The bitmap is a 5 x 5 white square
bitmap = read_bitmap("c:\\windows\\desktop\\test.bmp")
all_palette(bitmap[1] / 4)
display_image({0,0}, bitmap[2])

--This file holds the color numbers of the bitmap...
fn = open("bitmap.dat", "w")

--Scans the colors from {0,0} to {5,5} and writes them to bitmap.dat...
for y  0 to 4 do
        data = get_pixel({0,y,5})
            print(fn, data)
end for

close(fn)

--Here is where I attempt to redraw the bitmap using the data in bitmap.dat:
clear_screen()

fn = open("bitmap.dat", "r")

for v = 0 to 4 do
            data = get(fn)
                if data[1] = GET_SUCCESS then
                    data = data[2]
                else
                    abort(0)
                end if
            pixel(data,{0,v})
end for

close(fn)

If you run it you will see my problems. The data is saved as a sequence for
each line of the bitmap and I can't seem to read it back properly. Any
suggestions? My real hope is that I will be able to use this program to
convert bitmaps into something that QB can read and display. I thought that
it would be simple but is turning into a real headache (isn't that always
the way with programming?;) ).

Thank you all,
David S.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu