FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Jpg Height and Width?
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Jpg Height and Width?
Posted: Sat Jan 14, 2006 05:43 PM

Hi fw's,
is possible to know the dimensions (Height and Width) of an Jpg with Fwh?

Ciao, best regards,

Ugo
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Jpg Height and Width?
Posted: Sat Jan 14, 2006 06:59 PM

Load it in a TImage control and then use nHeight() and nWidth() methods.

EMG

Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 10:09 AM
EnricoMaria wrote:Load it in a TImage control and then use nHeight() and nWidth() methods.


Enrico,
is possible to load only in memory?
(not in an object/resource?)
I want use this info only for know if the image is horizontal or vertical.

thank you.
Ciao, best regards,

Ugo
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 11:00 AM
EnricoMaria wrote:Load it in a TImage control and then use nHeight() and nWidth() methods.

Enrico,
I test this code:
oImg     := TImage():Define( , cImage, oDlg )
nHorDim  := oImg:nWidth() 
nVerDim  := oImg:nHeight()
oImg     := Nil     // is correct for release the lib?
MsgInfo( "Altezza " + cValToChar( nVerDim ) + CRLF +;
              "Larghezza " + cValToChar( nHorDim ), "" )

but the return is height 0 and width 0
in cImage there is a correct path and jpg file name,
use the standard nviewlib;
where is my error?

and
oImg := Nil

is correct to release the lib?

Thank you.
Ciao, best regards,

Ugo
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 12:40 PM
This is a working sample:

#include "Fivewin.ch"


STATIC hLib


FUNCTION MAIN()

    LOCAL oDlg, oImg

    DEFINE DIALOG oDlg

    @ 0,  1 BUTTON "Sizes" ACTION SHOWSIZES( oDlg )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION SHOWSIZES( oDlg )

    LOCAL oImg := TImage():Define( , "SFONDO.JPG", oDlg )

    ? oImg:nWidth(), oImg:nHeight()

    oImg:End()

    RETURN NIL


EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 12:41 PM
Ugo wrote:
oImg := Nil

is correct to release the lib?


No, you need oImg:End() or RELEASE IMAGE oImg.

EMG
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 01:41 PM
EnricoMaria wrote:This is a working sample:
...


Enrico,
work but in any case return 0 and 0
it is correct?
Ciao, best regards,

Ugo
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 01:43 PM
EnricoMaria wrote:No, you need oImg:End() or RELEASE IMAGE oImg.


:-)
Thank you.
Ciao, best regards,

Ugo
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 02:10 PM
Ugo wrote:
EnricoMaria wrote:This is a working sample:
...


Enrico,
work but in any case return 0 and 0
it is correct?


Which cases? Can I reproduce the problem? How?

EMG
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM
Re: Jpg Height and Width?
Posted: Sun Jan 15, 2006 03:47 PM
EnricoMaria wrote:Which cases? Can I reproduce the problem? How?


Yes, the case is the jpg create from my camera! :-)

Can I send to your mail?
Ciao, best regards,

Ugo
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Continue the discussion