2
Answers

How the code works

Photo of Ramco Ramco

Ramco Ramco

Mar 21
2.5k
1

Hi

  In the below code how the below 2 line works

BitBlt Picture2.hDC, 0&, 0&, lNewWidth, lNewHeight, Picture1.hDC, lSourceX, lSourceY, SRCCOPY

    Picture2.PaintPicture Picture1.Picture, 0, 0, lNewWidth, lNewHeight, lSourceX, lSourceY

    lOldWidth = Picture1.ScaleWidth \ Screen.TwipsPerPixelX
    lOldHeight = Picture1.ScaleHeight \ Screen.TwipsPerPixelY
    ' -=[ Calculate 70% of Width and Height ]=-
    lNewWidth = lOldWidth * 0.7
    lNewHeight = lOldHeight * 0.7
    ' -=[ Calculate Top Left of centered image ]=-
    lSourceX = (lOldWidth - lNewWidth) \ 2
    lSourceY = (lOldHeight - lNewHeight) \ 2

  ' -=[ Resize Destination Picture ]=-
    Picture2.Width = Picture2.Width - Picture2.ScaleWidth + (lNewWidth * Screen.TwipsPerPixelX)
    Picture2.Height = Picture2.Height - Picture2.ScaleHeight + (lNewHeight * Screen.TwipsPerPixelY)

  ' -=[ Crop Image ]=-
    BitBlt Picture2.hDC, 0&, 0&, lNewWidth, lNewHeight, Picture1.hDC, lSourceX, lSourceY, SRCCOPY

    Picture2.PaintPicture Picture1.Picture, 0, 0, lNewWidth, lNewHeight, lSourceX, lSourceY

Thanks

Answers (2)