1. PCX loader fix

Hi all,

I've just fixed my PCX loader routine to be able to load files which
use a non-standard method of indicating the color depth.
To make this message smaller, I've only included the procedure
read_pcx_header(). Just substitute it for the one that's already in
pic_load.e.
Thanks to Jean Hendrickx for pointing this out.

Regards,
               Michael Bolin

----------------------------------------------
procedure read_pcx_header()
    if bytes_left()<128 then
        exit_flag=PCX_UNEXPECTED_EOF
        return
    end if
    junk=getc(file_num)
    palette_at_end=0
    if getc(file_num)=5 then
        palette_at_end=1
    end if
    if getc(file_num)!=1 then
        exit_flag=PCX_UNSUPPORTED_FORMAT
        return
    end if
    bits_per_pixel=getc(file_num)
    if bits_per_pixel!=1 and bits_per_pixel!=8 then
        exit_flag=PCX_UNSUPPORTED_FORMAT
        return
    end if
    if bits_per_pixel=1 then
        palette_at_end=0
    end if
    x_min=getc(file_num)+getc(file_num)*256
    y_min=getc(file_num)+getc(file_num)*256
    x_max=getc(file_num)+getc(file_num)*256
    y_max=getc(file_num)+getc(file_num)*256
    x_size=x_max-x_min+1
    y_size=y_max-y_min+1
    junk=read_byte(4)
    the_palette={}
    if palette_at_end then
        junk=read_byte(48)
    else
        for c=1 to 16 do
            the_palette=append(the_palette,read_byte(3))
        end for
    end if
    if exit_flag then
        return
    end if
    if getc(file_num) then
        exit_flag=PCX_UNSUPPORTED_FORMAT
        return
    end if
    n_planes=getc(file_num)
    bytes_per_line=getc(file_num)+getc(file_num)*256
    junk=read_byte(6)
    for x=1 to 54 do
        junk=getc(file_num)
        if junk=-1 then
            exit_flag=PCX_UNEXPECTED_EOF
            return
        elsif junk then
            exit_flag=PCX_UNSUPPORTED_FORMAT
            return
        end if
    end for
end procedure
------------------------------------

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu