Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Check BMP is valid and not compressed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check BMP is valid and not compressed

    use the exist() function to your liking from the better way to check if file exists? thread.

    Code:
    ' some windows versions seem to have trouble reading rle compressed bmp's.
    ' this code returns true, only if the bmp is not compressed.
    ' i think this code is from code abc at [url="http://www.basicguru.com"]www.basicguru.com[/url] 
    ' peter scheutz 2001.
    
    
    function bmpisvalidandnotcompressed(fname as string) as long
       local f as long
       local bmpheader as asciiz*54
       local comptype as dword ptr
    
    
       if isfalse exist(fname) then function=%false :exit function
       f=freefile
    
       open fname for binary as f
            if lof(f)>=54 then
                get$ f,54,bmpheader
                close f
            else
                close f
                info fname & " is not a valid bmp file"
                function=%false :exit function
            end if
    
            if ucase$(left$(bmpheader,2))<>"bm" then
                info fname & " is not a valid bmp file"
                function=%false :exit function
            end if
    
            comptype=varptr(bmpheader)+30
            if @comptype<>0 then
                info fname & " can't be read because it's compressed"
                function=%false :exit function
            end if
    
    
       function=%true
    
    end function

    ------------------


    [this message has been edited by peter scheutz (edited february 01, 2001).]
    Best Regards
    Peter Scheutz
Working...
X