check if a bmp or jpg image is valid

check if a bmp or jpg image is valid

Postby gss200610 » Tue Dec 06, 2011 8: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.
gss200610
 
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

Re: check if a bmp or jpg image is valid

Postby Enrico Maria Giordano » Tue Dec 06, 2011 10:31 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: check if a bmp or jpg image is valid

Postby gss200610 » 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
gss200610
 
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil


Re: check if a bmp or jpg image is valid

Postby gss200610 » Wed Dec 07, 2011 9: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
gss200610
 
Posts: 36
Joined: Sat Jun 19, 2010 10:09 am
Location: Goiania - Goias - Brasil

Re: check if a bmp or jpg image is valid

Postby Enrico Maria Giordano » 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: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], karinha, Silvio.Falconi and 38 guests