Page 1 of 1
resize a position with fw_drawimage
Posted: Tue May 14, 2019 9:10 am
by Silvio.Falconi
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
Re: resize a position with fw_drawimage
Posted: Wed May 15, 2019 10:55 am
by Silvio.Falconi
any solution please ?
Re: resize a position with fw_drawimage
Posted: Wed May 15, 2019 1:43 pm
by ukoenig
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
Re: resize a position with fw_drawimage
Posted: Wed May 15, 2019 4:47 pm
by Silvio.Falconi
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
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 10:07 am
by ukoenig
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
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
regards
Uwe
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 10:20 am
by Silvio.Falconi
CAn run ok also with btnbmp control ?
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 10:28 am
by ukoenig
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
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 11:38 am
by Silvio.Falconi
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
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 12:39 pm
by ukoenig
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
Re: resize a position with fw_drawimage
Posted: Thu May 16, 2019 5:45 pm
by ukoenig
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
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
Re: resize a position with fw_drawimage
Posted: Sun May 19, 2019 6:27 pm
by ukoenig
Silvio,
zooming buttons works
but there is a problem ;
images are not adjusted to the new burttonsize
borders and spaces are working
regards
Uwe
Re: resize a position with fw_drawimage
Posted: Mon May 20, 2019 8:10 am
by Silvio.Falconi
How I can have the width and the Height of a btnbmp ?
Re: resize a position with fw_drawimage
Posted: Mon May 20, 2019 9:14 am
by ukoenig
//------------- 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