Is there a way to zoom an image incrementally ? The following code zoom the image too big:
- Code: Select all Expand view
- WITH OBJECT oImg
if :lStretch
:lStretch := .f.
:Zoom( 1 )
...
Thank you very much !
WITH OBJECT oImg
if :lStretch
:lStretch := .f.
:Zoom( 1 )
...
STATIC oFld, oPlan
// -------------
// cImage = Imagename
REDEFINE FOLDEREX oFld ID 120 PROMPT "&Patient", "&Ka./ Pfl.", "&Arzt / Re.-an / Bem.", "Plan";
BITMAPS c_Pfad1 + "Eingabe.bmp", c_Pfad1 + "Eingabe.bmp", c_Pfad1 + "Eingabe.bmp", c_Pfad1 + "Eingabe.bmp" ;
DIALOGS "Patient1", "Patient2", "Patient3", "Patient4" ROUND 5 ;
ON CHANGE ( nPage := oFld:nOption, ;
IIF( nPage = 4, ( IMG_PADJ( oPlan, c_Path, TRIM(cImage) ), oPlan:Refresh() ), NIL ), ;
oFld:aDialogs[ nPage ]:Update() )
// ----Folderpage 4 ( Image ) --------
REDEFINE IMAGE oPlan ID 110 FILENAME c_Path + TRIM(cImage) OF oFld:aDialogs[ 4 ] PIXEL BORDER
oPlan:LoadImage( , c_Path + TRIM(cImage) )
// ------------------- IMAGE ADJUSTMENT ( keep aspect ratio ) PREVIEW ------------
FUNCTION IMG_PADJ( oDrawImg, cPath, cImage )
LOCAL nImgWidth, nImgHeight, nPWidth, nWFactor, nHFactor
LOCAL aRect := GETCLIENTRECT( oDrawImg:hWnd ) // Get RESOURCE-size !!!
oDrawImg:LOADIMAGE( , cPath + cImage ) // Image
nPWidth := aRect[4] // Default Resource-Image-Width
nPHeight := aRect[3] // Default Resource-Image-Height
nImgWidth := oDrawImg:nWidth // Image-Width
nImgHeight := oDrawImg:nHeight // Image-Height
nWFactor := aRect[4] / nImgWidth // Width / Image-Width
nHFactor := aRect[3] / nImgHeight // Height / Image-Height
IF nWFactor > 1 .and. nHFactor > 1 // Dlg-Width > ImageWidth und Dlg-Height > Image-Height
IF nWFactor < nHFactor // Width-factor > Height-factor
nPHeight := nImgHeight * nWFactor
ELSE // Width-factor < Height-factor
nPWidth := nImgWidth * nHFactor
ENDIF
ELSEIF nWFactor < 1 .and. nHFactor < 1 // Dlg-Width < Image-Width und Dlg-Height < Image-Height
IF nWFactor < nHFactor // Width-factor > Height-factor
nPHeight := nImgHeight * nWFactor
ELSE // Width-factor < Height-factor
nPWidth := nImgWidth * nHFactor
ENDIF
ELSEIF nWFactor < 1 .and. nHFactor > 1 // Dlg-Width < Image-Width und Dlg-Height > Image-Height
nPHeight := nImgHeight * nWFactor
ELSEIF nWFactor > 1 .and. nHFactor < 1 // Dlg-Width > Image-Width und Dlg-Height < Image-Height
nPWidth := nImgWidth * nHFactor
ENDIF
hResizeImg := ResizeImg( oDrawImg:hBitmap, nPWidth, nPHeight ) // Resize Image
oDrawImg:hBitmap := hResizeImg
oDrawImg:Refresh()
oDlg:Refresh()
RETURN( NIL )
// ------------------
FUNCTION P_DRUCK( oDlg, nTyp )
IF nTyp = 1
MSGMETER( { | oMeter, oText, oDlg, lEnd | ;
P_REPORT1( oMeter, oText, oDlg, @lEnd ) }, "Fortschritt...", ;
"Erzeuge Leistungsliste ..." )
ENDIF
RETURN( NIL )
// -------------
FUNCTION P_REPORT1( oMeter, oText, oDlg )
LOCAL nGesamt := 0, aDatP[55], oImage, aPoint, nImgSize := 1300
LOCAL oPRINT, oFont1, oFont2, oPen1, oPen2, nRechngNr
LOCAL nLinI, nColI, nLinF, nColF, aDValue[30], nLstgSumme := 0, I := 1
LOCAL nMargin, nIWidth, nIHeight, nColWidth, aText[ 2 ], nImgLeft := 1
LOCAL nWFactor, nHFactor, nPWidth, nPHeight, nRow, nCol
DBSELECTAREA( "PATIENT" )
( "PATIENT" )->(DBGOTOP())
//oMeter:nTotal = nMenge
PRINTER oPRINT ; // FROM USER ;
PREVIEW MODAL ;
NAME "Patientenliste drucken"
IF EMPTY( oPRINT:hDC )
MsgStop ( "Drucker nicht bereit !" )
RETURN(.f.)
ENDIF
IF aVal[180] = 2 //fix for report thumbnails
TPreview():lListViewHide := .T.
ENDIF
DEFINE FONT oFont1 NAME "Arial" SIZE 0, -10 OF oPRINT
DEFINE FONT oFont2 NAME "Arial" SIZE 0, -12 OF oPRINT
DEFINE FONT oFont3 NAME "Arial" SIZE 0, -14 BOLD OF oPRINT
DEFINE PEN oPen1 WIDTH aVal[201] * 4 OF oPRINT
DEFINE PEN oPen2 WIDTH aVal[202] * 4 OF oPRINT
oPRINT:SetPage(9) // A4
oPRINT:SetPortrait() // Vertical
nMargin := Int( 0.12 * oPRINT:nHorzRes() )
nWidth := 8.2 * nMargin
nColWidth := Int( ( nWidth - ( nMargin / 2 ) ) )
nImgLeft := nMargin
nSeite := 0
DO WHILE !EOF()
aDatP[31] := ("PATIENT")->DMERKER // selected record
IF aDatP[31] = "X" // record selected
aDatP[47] := TRIM( ("PATIENT")->ORTSPLAN ) // Image-name
PAGE
....
....
// ------------- SECTION IMAGE PRINT -----------------
// position and zoom related to defined left margin
// aVal[177] := ("SYSTEM")->IMAGE_TOP // Default factor = 1, nTop = 1150
// aVal[178] := ("SYSTEM")->IMAGE_LEFT // Default factor = 1, nMargin
// aVal[179] := ("SYSTEM")->IMAGe_ZOOM // Default factor = 1, can be used for small images
IF aVal[178] > 0
nImgLeft := nMargin * aVal[178]
IF nImgLeft > nMargin
nImgSize := nImgSize - ( nImgLeft - nMargin )
ENDIF
ENDIF
// nDlgWidth, nDlgHeight, Path, Image
aImgSize := PRINT_IMG( nImgSize, 1000, c_Pfad5, aDatP[47] )
IF aVal[179] > 0
aImgSize[1] := aImgSize[1] * aVal[179]
aImgSize[2] := aImgSize[2] * aVal[179]
ENDIF
// PrintImage( nRow, nCol, uImage, image-name, nWidth, nHeight, lStretch, nAlpha, lTransp, lGray )
oPRINT:PrintImage( 1150 * aVal[177], nImgLeft, c_Pfad5 + aDatP[47], aImgSize[1], aImgSize[2], .T.)
/ -------------
nSeite++
oPRINT:cmSay( 28.2, 17.5, "Page : " + LTRIM(STR(nSeite)), oFont2,,CLR_BLACK,,PAD_LEFT )
ENDPAGE
ENDIF
("PATIENT")->(DBSKIP(+1))
ENDDO
ENDPRINT
oFont1:End()
oFont2:End()
oFont3:End()
oPen1:End()
oPen2:End()
DBSELECTAREA( "PATIENT" )
("PATIENT")->(DBGOTOP())
RETURN( NIL )
// ------------------- IMAGE - ADJUSTMENT ( keep asprct ration ) PRINTING -----
FUNCTION PRINT_IMG( nDlgWidth, nDlgHeight, cPath, cImage )
LOCAL nIWidth, nIHeight, nPWidth, oDrawImg, aImgSize[2]
DEFINE IMAGE oDrawImg FILE cPath + cImage
nIWidth := oDrawImg:nWidth
nIHeight := oDrawImg:nHeight
nWFactor := nDlgWidth / nIWidth // Width / Image-Width
nHFactor := nDlgHeight / nIHeight // Höhe / Image-Height
nPWidth := nDlgWidth
nPHeight := nDlgHeight
IF nWFactor > 1 .and. nHFactor > 1 // Dlg-Width > Image-Width und Dlg-Height > Image-Height
IF nWFactor < nHFactor // Width-factor > Height-factor
nPHeight := nIHeight * nWFactor
ELSE // Width-factor < Height-factor
nPWidth := nIWidth * nHFactor
ENDIF
ELSEIF nWFactor < 1 .and. nHFactor < 1 // Dlg-Width < Image-Width und Dlg-Height < Image-Height
IF nWFactor < nHFactor // Width-factor > Height-factor
nPHeight := nIHeight * nWFactor
ELSE // Width-factor < Height-factor
nPWidth := nIWidth * nHFactor
ENDIF
ELSEIF nWFactor < 1 .and. nHFactor > 1 // Dlg-Width < Image-Width und Dlg-Height > Image-Height
nPHeight := nIHeight * nWFactor
ELSEIF nWFactor > 1 .and. nHFactor < 1 // Dlg-Width > Image-Width und Dlg-Height < Image-Height
nPWidth := nIWidth * nHFactor
ENDIF
oDrawImg:End()
aImgSize[1] := nPWidth
aImgSize[2] := nPHeight
RETURN( aImgSize )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 84 guests