FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour To Antonio center image
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
To Antonio center image
Posted: Thu Jun 18, 2015 08:32 PM

Can I use center method of Bitmaps to center an image into image area control ?
and how ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 08:59 AM

Silvio,

Please provide a small and self contained example, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 09:46 AM
Antonio,
the small sample run ok

Code (fw): Select all Collapse
# include "fivewin.ch"

function test()
local odlg,oImage
local oSay[7]
local obtn[1]

DEFINE DIALOG oDlg ;   //OF oParent
   TITLE "test"    ;
   SIZE  600, 600

 @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg

activate dialog odlg ;
on init  GetImage( oImage )

retur nil


 STATIC FUNCTION GetImage( oImage )

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )
      oImage:LoadBmp( gcFile )
       oImage:center()
   endif
return nil




when I use the same command on my app not run

Antonio, Remember the listview test ?
When I drop a file I insert an image on a control Image , it is on the top of the listview control

as you can see here



if I use oImage:center() it move the" Image area" into center of dialog

but I wish move only the jpg of the file I dropped into center of "image area "
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 09:54 AM

You can use oImage:SetPos( nRow, nCol )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 09:56 AM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 01:43 PM

cNavarro,

I use a dialog and I try to use

oAllegati:bResized := {|| nLTop := INT( ( ( oAllegati:nHeight ) / 2 ) - ( oImage:nHeight / 2 ) ), ;
nLLeft := INT( ( ( oAllegati:nWidth - 18 ) / 2 ) - ( oImage:nWidth / 2 ) ), ;
oImage:Move( nLTop, nLLeft, , , .T. ), ;
Rinfresca_oDlgallegati(oList,oAllegati ) }

but not run ok
the function I add Rinfresca_oDlgallegati(oList,oAllegati ) refresh some says and btns

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 01:56 PM
Silvio.Falconi wrote:Antonio,
the small sample run ok

Code (fw): Select all Collapse
# include "fivewin.ch"

function test()
local odlg,oImage
local oSay[7]
local obtn[1]

DEFINE DIALOG oDlg ;   //OF oParent
   TITLE "test"    ;
   SIZE  600, 600

 @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg

activate dialog odlg ;
on init  GetImage( oImage )

retur nil


 STATIC FUNCTION GetImage( oImage )

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )
      oImage:LoadBmp( gcFile )
       oImage:center()
   endif
return nil




when I use the same command on my app not run

Antonio, Remember the listview test ?
When I drop a file I insert an image on a control Image , it is on the top of the listview control

as you can see here



if I use oImage:center() it move the" Image area" into center of dialog

but I wish move only the jpg of the file I dropped into center of "image area "


Silvio, try

Code (fw): Select all Collapse
# include "fivewin.ch"

static nLTop
static nLLeft

function test()
local odlg,oImage
local oSay[7]
local obtn[1]

DEFINE DIALOG oDlg ;   //OF oParent
   TITLE "test"    ;
   SIZE  600, 600

 @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg

/*
// oAllegati -> oDlg
oAllegati:bResized := {|| nLTop := INT( ( ( oAllegati:nHeight ) / 2 ) - ( oImage:nHeight / 2 ) ), ;
nLLeft := INT( ( ( oAllegati:nWidth - 18 ) / 2 ) - ( oImage:nWidth / 2 ) ), ;
oImage:Move( nLTop, nLLeft, , , .T. ), ;
Rinfresca_oDlgallegati(oList,oAllegati ) }
*/
activate dialog odlg ;
on init  GetImage( oImage, oDlg )

retur nil


 STATIC FUNCTION GetImage( oImage, oDlg )

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )
      oImage:LoadBmp( gcFile )
      nLTop  := INT( ( ( oDlg:nHeight ) / 2 ) - ( oImage:nHeight / 2 ) )
      nLLeft := INT( ( ( oDlg:nWidth - 18 ) / 2 ) - ( oImage:nWidth / 2 ) )
     oImage:Move( nLTop, nLLeft, , , .T. )

//       oImage:center()
   endif
return nil
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 05:17 PM

cNavarro
it run bad
but perhaps I undestood how make it

I tried to insert a Panel and on it the image and now is on the center

but I have prpblems with zoom

now I wish insert a scrollpanel instead of Panel because I need it if I zoom the image I must change the size of panel

but I have problems to use scrollpanel class into a dialog

please see the new topic at viewtopic.php?f=3&t=30932

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: To Antonio center image
Posted: Fri Jun 19, 2015 09:26 PM
Silvio,

The problem is that oImage resized according to the width and height of the image (file) to load.
To get what you want must "anchor" the oImage on another control
I think you can also have the effect you need

Code (fw): Select all Collapse
# include "fivewin.ch"

function test()
local odlg,oImage
local oSay[7]
local obtn[1]
Local oPnel

DEFINE DIALOG oDlg ;   //OF oParent
   TITLE "test"    ;
   SIZE  600, 600

 @ 2, 2 PANEL oPnel  SIZE 152, 152 OF oDlg 
 @ 1, 1 IMAGE oImage SIZE 150, 150 OF oPnel PIXEL //NOBORDER
// @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg

activate dialog odlg ;
on init  GetImage( oImage, oPnel )

retur nil


 STATIC FUNCTION GetImage( oImage, oPnel )
Local nLTop
Local nLLeft
   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )
      oImage:LoadBmp( gcFile )
/*
// So it works well
      nLTop  := INT( ( ( oPnel:nHeight )/ 2 ) - ( nBmpHeight( oImage:hBitmap ) / 2 ) )
      nLLeft := INT( ( ( oPnel:nWidth ) / 2 ) - ( nBmpWidth( oImage:hBitmap ) / 2 ) )
     oImage:Move( nLTop, nLLeft, , , .T. )
*/
      oImage:center()
   endif
return nil
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: To Antonio center image
Posted: Sat Jun 20, 2015 07:02 AM

yes of course I allready thinked it ( use tpanel class)

but your sample make error
Error description: Warning BASE/1004 Message not found: TPANEL:DEFCONTROL
you must create the panel with ON INIT

When I use Zoom effect dor the image I have problem because I must zoom also the tpanel

to make zoom also to tpanel we must use scrollpanel class

but scrollpanel panel has errors into dialog (it run good only on window)

I made a post to resolve this problem at viewtopic.php?f=3&t=30932

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion