resize a position with fw_drawimage

resize a position with fw_drawimage

Postby Silvio.Falconi » Tue May 14, 2019 9:10 am

I use for bpainted a image (first) on another image( second) this function

FW_DrawImage( hDC, "BTN_PNG_DAY", { 0, -3, 20, 20 } )

If the first Image is resize (more big or more small) how I can recalculate the position of the second image ?

I 'mtrying...
Local arrayBtn:= GetClientRect (oBtn)
FW_DrawImage( hDC, "BTN_PNG_NOTE", { ;
arrayBtn[1]+35,;
arrayBtn[2]+30,;
arrayBtn[3]+50,;
arrayBtn[4]+50 } )

but not work ok
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby Silvio.Falconi » Wed May 15, 2019 10:55 am

any solution please ?
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby ukoenig » Wed May 15, 2019 1:43 pm

SIlvio,

there are different possible situations :
resizing inside a group or just 2 images next each other ( see inside circle )
using a fixed space or calculated in relation to the zoom-factor

I prefer using GDIPLUS because of possible exact calculations ( works great ). :!:
Now I can zoom any control like shown / tested with the get :wink:

Image

regards
Uwe :?:
Last edited by ukoenig on Sun May 19, 2019 4:53 pm, edited 2 times in total.
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: resize a position with fw_drawimage

Postby Silvio.Falconi » Wed May 15, 2019 4:47 pm

Uwe,
I need another situation

Uwe I have a btnbmp with a Png and up this some symbols also png

when I resize the dialog the btnbmp are resized and the symbol are moved on another position

for a sample look this image

Image

I need to insert :
1. the number on a orange box
2. the symbol you see at left
3. and the 3 symbols you see on right ( sun, receipt and note)

when I resize the dialog these symbols are not on the same position but are moved to another position

to draw the sun I use ( the orange circle you see at right)

FW_DrawImage( hDC, "BTN_PNG_DAY", { 0, -3, 20, 20 } )

when I resize the dialog this position { 0, -3, 20, 20 } is not good and the sun is draw to another position

as you can see here

Image

How I can resolve it ?

I thinked to calculate the rect of btnbmp with

Local arrayBtn:= GetClientRect (oBtn)

but then I not Know how change the exactly position for that symbol

I hope U understand now
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby ukoenig » Thu May 16, 2019 10:07 am

I think the wanted solution
3 embedded images inside the main-image
everything zoomed and unzoomed keeping the exact positions.
The same logic like used for windows but a dialog

Image

Only a few lines of code :!:

Code: Select all  Expand view

FUNCTION ZOOM_ADJ( oDlg, nImgRow, nImgCol, nImgSpace, nFactorW, nFactorH )
LOCAL oGraphics := Graphics():New( oDlg:hDC )
LOCAL oImage := GDIBmp():New( c_path1 + "Olga.jpg" ), oImg[3]
LOCAL nTop, nLeft, nFactor := 1
LOCAL nWidth := oImage:GetWidth(), nHeight := oImage:GetHeight(), nSpace := 1

oImg[1] := GDIBmp():New( c_path1 + "Paint.bmp" )
oImg[2] := GDIBmp():New( c_path1 + "Paint.bmp" )
oImg[3] := GDIBmp():New( c_path1 + "Paint.bmp" )

IF nFactorW <> 1 // width resized
    nFactor := nFactorW
ELSE
    nFactor := nFactorH
ENDIF

nTop    := nImgRow * nFactor        // start-position top
nLeft   := nImgCol * nFactor        // start-position left
nOrgLeft    := nImgCol * nFactor        // reset to left on new row

nSpace  := nImgSpace * nFactor      // zoomed space between images

I := 1
X := 0
FOR I := 1 TO 8 // 2 rows with 8 images
    X++
    oGraphics:DrawImage( oImage, nTop, nLeft, ;     // image draw
                                        nWidth * nFactor, nHeight * nFactor )
    // 1. sub- image  
    oGraphics:DrawImage( oImg[1], nTop + ( 10 * nFactor ), nLeft + ( 55  * nFactor ), ; 
                                        30 * nFactor, 30 * nFactor )
    // 2. sub- image  
    oGraphics:DrawImage( oImg[1], nTop + ( 45 * nFactor ), nLeft + ( 55  * nFactor ), ; 
                                        30 * nFactor, 30 * nFactor )
    // 3. sub- image  
    oGraphics:DrawImage( oImg[1], nTop + ( 80 * nFactor ), nLeft + ( 55  * nFactor ), ; 
                                        30 * nFactor, 30 * nFactor )

    nImgCol := oImage:GetWidth() + nSpace       // new col-pos each image horizontal
    nLeft   += nSpace + ( nWidth * nFactor )        // next image left position
    oGraphics:destroy()
        oGraphics := Graphics():New( oDlg:hDC )
    IF X = 4                                    // break after 4 images each row
                nTop    += nHeight * nFactor + nSpace   // next row-position
        nLeft   := nOrgLeft
        X := 0
    ENDIF
NEXT
oGraphics:destroy()

RETURN NIL
 


regards
Uwe :?:
Last edited by ukoenig on Sun May 19, 2019 6:24 pm, edited 2 times in total.
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: resize a position with fw_drawimage

Postby Silvio.Falconi » Thu May 16, 2019 10:20 am

CAn run ok also with btnbmp control ?
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby ukoenig » Thu May 16, 2019 10:28 am

Silvio,

with Btnbmp it is not possible to place sub-images
on any position inside the button. :(

Maybe it is possible to add clicked like in TImage

METHOD New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder,;
oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
cMsg, lUpdate, bWhen, lPixel, bValid, lDesign, cVarName ) CLASS TImage

regards
Uwe :D
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: resize a position with fw_drawimage

Postby Silvio.Falconi » Thu May 16, 2019 11:38 am

ukoenig wrote:Silvio,

with Btnbmp it is not possible to place sub-images
on any position inside the button. :(

Maybe it is possible to add clicked like in TImage

METHOD New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder,;
oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
cMsg, lUpdate, bWhen, lPixel, bValid, lDesign, cVarName ) CLASS TImage

regards
Uwe :D



Uwe,
Sorry
on BTnBMP is possible to place sub-images inside on any position of the button

you must make obtn:bPainted

obtn:bPainted:= { |hDC,ps,oBtn| FW_DrawImage( hDC, "BTN_PNG_DAY", { 0, -3, 20, 20 } ) }

uwe, see viewtopic.php?f=3&t=35666&start=15&hilit=BTNBMP

from NagesRao
Image
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby ukoenig » Thu May 16, 2019 12:39 pm

Silvio,

I know with using FW_DrawImage is OK.
What I mean is : the calculations are done using GDIPLUS
I didn't test if it is possible to change from < FW_DrawImage > to < GDIPLUS >
I will have a look at it.

regards
Uwe :D
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: resize a position with fw_drawimage

Postby ukoenig » Thu May 16, 2019 5:45 pm

Silvio just as a information of the calculation logic.
I'm using a resize-factor for zoom / unzoom
First I have to detect if horizontal or vertical is resized
resize-factor < 1 > belongs to the basic dialog-size.

Code: Select all  Expand view

DEFINE DIALOG oDlg2 SIZE 600, 400 PIXEL TRUEPIXEL RESIZABLE FONT oFont TITLE "TESTS 9" OF oSystem

oDlg:bPainted  := { || ZOOM_ADJ( oDlg2, nImgRow, nImgCol, nImgSpace, nFactorW, nFactorH ) }
 
// 618 x 441 ( overall size ) = defined width + 18, hight + 41
// + 18 and + 41 are fixed values for dialog header and border
oDlg:bResized = { | nRow, nCol | ; // select factor from resized width or hight
nFactorW := 1, nFactorH := 1, ; // reset
IIF( oDlg2:nWidth() > 620 .or. oDlg2:nWidth() < 615, ;
     nFactorW := oDlg2:nWidth() / 618, NIL ),;
IIF( oDlg2:nHeight() > 445 .or. oDlg2:nHeight() < 438, ;
     nFactorH := oDlg2:nHeight() / 441 , NIL ) }

 


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: resize a position with fw_drawimage

Postby ukoenig » Sun May 19, 2019 6:27 pm

Silvio,

zooming buttons works
but there is a problem ;
images are not adjusted to the new burttonsize :?:
borders and spaces are working

Image

regards
Uwe
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: resize a position with fw_drawimage

Postby Silvio.Falconi » Mon May 20, 2019 8:10 am

How I can have the width and the Height of a btnbmp ?
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: 7054
Joined: Thu Oct 18, 2012 7:17 pm

Re: resize a position with fw_drawimage

Postby ukoenig » Mon May 20, 2019 9:14 am

//------------- BMP-Brush -----------

FUNCTION DRAW_BMP( hDC, oBitmap, aColors, nColorSel )
LOCAL oBMPBrush, aGrad
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )

IF nColorSel = 1
aGrad := { { .5, CLR_WHITE, aColors[2] }, { .5, aColors[2], CLR_BLACK } }
ELSE
aGrad := { { .5, CLR_WHITE, aColors[4] }, { .5, aColors[4], CLR_BLACK } }
ENDIF

DEFINE BRUSH oBMPBrush ;
COLOR GradientFill( hDC, 0, 0, aRect[3], aRect[4] , aGrad, .T. ) // .T: = Vertical
oBMPBrush:End()

RETURN( NIL )

regards
Uwe :D
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: Google [Bot] and 111 guests