Re: Converting .BMP to a data file without a header.

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

>         I think what I want someone has already done, but I don't know who and
> where:
>
>         In my game, all the bitmap files have the same palette. I was trying t
o do
> routines to write and read a data file containing only the size of the
> image and each pixels' palette color index. So then I would have my own
> image format, much smaller since it wouldn't contain the color table,
> bitcount, etc...
>         Does someone here have this kind of code ?

        That's easy, just use my Euphoria Data Object Manager...
        This loads your image like you would normally, and then saves it
with compression without the pallete info:

include edom.e                                                         
        -- edo_save(), edo_load()
include image.e                                                        
        -- load_bmp () or something

sequence my_pic_data                                                   
        -- A sequence to store it
my_pic_data = load_bmp("my_pic.bmp")                    -- Look up the
        routine...
my_pic_data = my_pic_data[2]                                    --
        Getting rid of pallete
if not edo_save("my_pic.edo" , my_pic_data)                     --
        Saving the file
puts(1,"File could not be saved\n")                     -- Oops,
                write error!
        else
puts(1,"File is saved!\n")                                     
                -- File is saved!!!
        end if

If you would want to load the grafix in your program, type this:

        include edom.e

        sequence my_pic_data_again

        my_pic_data_again = edo_load("my_pic.edo")
        if my_pic_data_again = {} then
                puts (1,"Oops, file is not valid")
        end if

You could even save multiple grafix in one file and stuff like that,
the routine just save the sequence data and it's structure
compressed!!

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

Search



Quick Links

User menu

Not signed in.

Misc Menu