is needed.
Code: Select all | Expand
// Appl.-path
// c_path := cFilePath(GetModuleFileName( GetInstance() ) )
// Image-path
// c_path1 := c_path + "IMAGES\"
REDEFINE IMAGE oIMG1 OF oDlg FILENAME NIL ;
ID 110 PIXEL BORDER
oIMG1:cTooltip := "Image 1"
oIMG1:bPainted := { |hDC| ( cSize1 := DRAW_IMG(oIMG1, hDC, cImage0 ), ;
oSay1:Refresh(), oSay2:Refresh() ) }
// Image-name
//----------------
REDEFINE SAY oSay1 PROMPT cImage0 ID 120 OF oDlg UPDATE
oSay1:SetColor( 0 )
oSay1:SetFont( oFont1 )
//Size and Resize-factor information
// -----------------------------------------
REDEFINE SAY oSay2 PROMPT cSize1 ID 130 OF oDlg UPDATE
oSay2:SetColor( 128 )
oSay2:SetFont( oFont1 )
..
..
FUNCTION DRAW_IMG( oImage, hDC, cImage )
LOCAL oImg, oImg0, nFactor1, nFactor2, aRect, nWidth, nHeight
aRect := GETCLIENTRECT( oImage:hWnd )
// MsgAlert( aRect[4] ) // Resource Width
// MsgAlert( aRect[3] ) // Resource Height
IF FILE( c_path1 + cImage )
DEFINE IMAGE oImg FILENAME c_path1 + cImage
nFactor1 := aRect[4] / oImg:nWidth
nFactor2 := aRect[3] / oImg:nHeight
cSize := ALLTRIM(STR(oImg:nWidth)) + "x" + ALLTRIM(STR(oImg:nHeight)) + ;
" Resize-Factor : W = " + ALLTRIM(STR(nFactor1)) + " H = " + ALLTRIM(STR(nFactor2))
nWidth := oImg:nWidth
nHeight := oImg:nHeight
oImg0 := FILoadImg( c_path1 + cImage )
lAlpha := HasAlpha( oImg0 )
IF nFactor1 > 1 .and. nFactor2 > 1
IF lAlpha = .T.
ABPaint( hDC, 0, 0, oImg0, 255 )
DeleteObject( oImg0 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,oImg:nWidth, oImg:nHeight )
ENDIF
ENDIF
IF nFactor1 < 1 .and. nFactor2 < 1
IF nFactor1 < nFactor2 // Width-factor > Height-factor
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, aRect[4], nHeight * nFactor1 )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,aRect[4], oImg:nHeight * nFactor1 )
ENDIF
ELSE // Width-factor < Height-factor
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, oImg:nWidth * nFactor2, aRect[3] )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,oImg:nWidth * nFactor2, aRect[3] )
ENDIF
ENDIF
// MsgAlert( "True 2" )
ENDIF
IF nFactor1 < 1 .and. nFactor2 > 1
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, aRect[4], nHeight * nFactor1 )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,aRect[4], oImg:nHeight * nFactor1 )
ENDIF
ENDIF
IF nFactor1 > 1 .and. nFactor2 < 1
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, nWidth * nFactor2, aRect[3] )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, , oImg:nWidth * nFactor2, aRect[3] )
ENDIF
ENDIF
DeleteObject( oImg )
ELSE
MsgAlert( "File : " + cImage + CRLF + ;
"does not exist" + CRLF + ;
"to show Image !", "ATTENTION" )
ENDIF
RETURN( cSize )