Page 1 of 1

Jpg Height and Width?

Posted: Sat Jan 14, 2006 5:43 pm
by Ugo
Hi fw's,
is possible to know the dimensions (Height and Width) of an Jpg with Fwh?

Re: Jpg Height and Width?

Posted: Sat Jan 14, 2006 6:59 pm
by Enrico Maria Giordano
Load it in a TImage control and then use nHeight() and nWidth() methods.

EMG

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 10:09 am
by Ugo
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.

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 11:00 am
by Ugo
EnricoMaria wrote:Load it in a TImage control and then use nHeight() and nWidth() methods.
Enrico,
I test this code:

Code: Select all

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

Code: Select all

oImg := Nil

is correct to release the lib?

Thank you.

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 12:40 pm
by Enrico Maria Giordano
This is a working sample:

Code: Select all

#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

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 12:41 pm
by Enrico Maria Giordano
Ugo wrote:

Code: Select all

oImg := Nil

is correct to release the lib?
No, you need oImg:End() or RELEASE IMAGE oImg.

EMG

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 1:41 pm
by Ugo
EnricoMaria wrote:This is a working sample:
...
Enrico,
work but in any case return 0 and 0
it is correct?

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 1:43 pm
by Ugo
EnricoMaria wrote:No, you need oImg:End() or RELEASE IMAGE oImg.
:)
Thank you.

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 2:10 pm
by Enrico Maria Giordano
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

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 3:47 pm
by Ugo
EnricoMaria wrote:Which cases? Can I reproduce the problem? How?
Yes, the case is the jpg create from my camera! :wink:

Can I send to your mail?

Re: Jpg Height and Width?

Posted: Sun Jan 15, 2006 3:52 pm
by Enrico Maria Giordano
Yes.

EMG