resize a position with fw_drawimage
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
resize a position with fw_drawimage
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
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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: resize a position with fw_drawimage
any solution please ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: resize a position with fw_drawimage
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
regards
Uwe
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
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: resize a position with fw_drawimage
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
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
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
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
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
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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: resize a position with fw_drawimage
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
Only a few lines of code
regards
Uwe
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
Only a few lines of code
Code: Select all
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
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: resize a position with fw_drawimage
CAn run ok also with btnbmp control ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: resize a position with fw_drawimage
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
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
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: resize a position with fw_drawimage
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
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 http://forums.fivetechsupport.com/viewt ... lit=BTNBMP
from NagesRao
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: resize a position with fw_drawimage
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
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
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: resize a position with fw_drawimage
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.
regards
Uwe
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
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 ) }
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: resize a position with fw_drawimage
Silvio,
zooming buttons works
but there is a problem ;
images are not adjusted to the new burttonsize
borders and spaces are working
regards
Uwe
zooming buttons works
but there is a problem ;
images are not adjusted to the new burttonsize
borders and spaces are working
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: resize a position with fw_drawimage
How I can have the width and the Height of a btnbmp ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: resize a position with fw_drawimage
//------------- 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
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
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.
i work with FW.
If you have any questions about special functions, maybe i can help.