To Antonio center image

To Antonio center image

Postby Silvio.Falconi » Thu Jun 18, 2015 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Antonio center image

Postby Antonio Linares » Fri Jun 19, 2015 8:59 am

Silvio,

Please provide a small and self contained example, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: To Antonio center image

Postby Silvio.Falconi » Fri Jun 19, 2015 9:46 am

Antonio,
the small sample run ok

Code: Select all  Expand view

# 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

Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Antonio center image

Postby Antonio Linares » Fri Jun 19, 2015 9:54 am

You can use oImage:SetPos( nRow, nCol )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: To Antonio center image

Postby cnavarro » Fri Jun 19, 2015 9: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
User avatar
cnavarro
 
Posts: 6515
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: To Antonio center image

Postby Silvio.Falconi » Fri Jun 19, 2015 1: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Antonio center image

Postby cnavarro » Fri Jun 19, 2015 1:56 pm

Silvio.Falconi wrote:Antonio,
the small sample run ok

Code: Select all  Expand view

# 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

Image

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: Select all  Expand view

# 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
User avatar
cnavarro
 
Posts: 6515
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: To Antonio center image

Postby Silvio.Falconi » Fri Jun 19, 2015 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Antonio center image

Postby cnavarro » Fri Jun 19, 2015 9: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: Select all  Expand view

# 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
User avatar
cnavarro
 
Posts: 6515
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: To Antonio center image

Postby Silvio.Falconi » Sat Jun 20, 2015 7: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 135 guests