FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour check if a bmp or jpg image is valid
Posts: 36
Joined: Sat Jun 19, 2010 10:09 AM
check if a bmp or jpg image is valid
Posted: Tue Dec 06, 2011 08:45 PM

is there any way to check if a bmp or jpg file is valid in FiveWin / xHarbour, since I have my application in a folder of pictures of products show on the screen as the sale goes through.
more is happening to stop the application and find that you have some images that the program can not open and lock.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: check if a bmp or jpg image is valid
Posted: Tue Dec 06, 2011 10:31 PM

Just try to open the image inside a TRY/CATCH/END structure and trap the error.

EMG

Posts: 36
Joined: Sat Jun 19, 2010 10:09 AM
Re: check if a bmp or jpg image is valid
Posted: Tue Dec 06, 2011 10:39 PM

There is no way to test via Windows API or whatever, because with try catch
entering the try block and catch the app was already, and that they want to avoid

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: check if a bmp or jpg image is valid
Posted: Tue Dec 06, 2011 10:50 PM

Sorry, I don't understand.

EMG

Posts: 36
Joined: Sat Jun 19, 2010 10:09 AM
Re: check if a bmp or jpg image is valid
Posted: Wed Dec 07, 2011 09:35 AM

I say this, I wanted to see if the photo or image file is valid.
example:

if checkimg ("teste.jpg")
obmp: loadbmp ("teste.jpg")
endif

something like this. Why try to catch suppose it to have it established in the block between the try and catch the app as it is happening.

has no function of the Windows API function to check or some of the FreeImage?

sorry my bad inglish i used google, rsrsrsrs

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: check if a bmp or jpg image is valid
Posted: Wed Dec 07, 2011 11:28 AM
gss200610 wrote:I say this, I wanted to see if the photo or image file is valid.
example:

if checkimg ("teste.jpg")
obmp: loadbmp ("teste.jpg")
endif

something like this.


Yes, and I already answered: use a TRY/CATCH/END structure:

Code (fw): Select all Collapse
FUNCTION CHECKIMG( cImg )

    LOCAL lOk := .F.

    TRY
        // try to load cImg
        lOk = .T.
    CATCH
    END

    RETURN lOk


gss200610 wrote:has no function of the Windows API function to check or some of the FreeImage?


I don't know, sorry.

EMG

Continue the discussion