Finding out image size.

Finding out image size.

Postby HunterEC » Wed Jun 02, 2010 9:49 am

Guys:

Is there a way to know how many pixels a JPG is ? For example 278 pixels wide and 350 high. Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Finding out image size.

Postby ukoenig » Wed Jun 02, 2010 10:00 am

Imagesize and Display :

...
LOCAL oBMP1
// Get Window-Screen-Size
LOCAL nWidth := GetSysMetrics(0)
LOCAL nHeight := GetSysMetrics(1)
...
...
// Your Image :
DEFINE IMAGE oBMP1 FILENAME c_path + "\System\BACKGRD.JPG"
Msgalert( oBMP1:nWidth() )
Msgalert( oBMP1:nHeight() )

// Use and adjust Image to Window-Size ( Background )
...
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT ( DRAWBITMAP( hdc, oBMP1:hbitmap, 0, 0, nWidth, nHeight ) )

RETURN NIL

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Finding out image size.

Postby HunterEC » Wed Jun 02, 2010 6:37 pm

Uwe:

Thank you for your help. I really appreciate it. 8) I'm trying to make the oWnd window the exact size of the JPG. Here's the code:
Code: Select all  Expand view
  DEFINE WINDOW oWnd FROM 00,00 TO NO_OF_ROWS - INT(oBMP1:nHeight() / 15.18987341772151898 ), ;
      NO_OF_COLS - INT(oBMP1:nWidth() / 7.933884297520661157)

   // Use and adjust Image to Window-Size ( Background )

   ACTIVATE WINDOW oWnd NORMAL ;
   ON PAINT ( DRAWBITMAP( hdc, oBMP1:hbitmap, 0, 0, oBmp1:nWidth(), oBmp1:nHeight() ) )


The resulting window is not the exact image size, how can I do this ? Thanks in advance.

Gustavo
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Finding out image size.

Postby ukoenig » Wed Jun 02, 2010 7:35 pm

Hello Gustavo,

it is the other direction : Adjust Window to a given Image-Size :

Image

...
...
DEFINE WINDOW oWnd TITLE "SButton-Tools"

DEFINE IMAGE oBMP1 FILENAME c_path + "\System\Fantasy6.JPG"
...
...
ACTIVATE WINDOW oWnd ;
ON PAINT ( DRAWBITMAP( hdc, oBMP1:hbitmap, 0, 0 ) ,;
oWnd:Move( 50, 50, oBMP1:nWidth, oBMP1:nHeight, .T. ) )

// moves the Window to a given Position adjusted to the Image-Size

RETURN ( NIL )

Best regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft, Google [Bot] and 81 guests

cron