| Код | 'в hCanvas - Form или PictureBox Public Function CheckPictureSize(ByRef hCanvas As Object, ByVal lMaxWidth As Long, ByVal lMaxHeight As Long) As Boolean Dim sngAspectRatio As Single Dim lW As Long, lH As Long Dim lW2 As Long, lH2 As Long Dim hTemp As StdPicture lW = hCanvas.ScaleWidth lH = hCanvas.ScaleHeight If lW > lMaxWidth Or lH > lMaxHeight Then If lW > lH Then sngAspectRatio = lW / lH lW2 = lMaxWidth lH2 = lMaxWidth / sngAspectRatio Else sngAspectRatio = lH / lW lW2 = lMaxHeight / sngAspectRatio lH2 = lMaxHeight End If Set hTemp = hCanvas.Picture Set hCanvas.Picture = Nothing Call SetStretchBltMode(hCanvas.hdc, STRETCH_HALFTONE) hCanvas.PaintPicture hTemp, 0, 0, lW2, lH2 Set hCanvas.Picture = hCanvas.Image CheckPictureSize = True Else CheckPictureSize = False End If End Function
|
|