1
Answer

Incorrect Image

Ramco Ramco

Ramco Ramco

2d
46
1

Hi

 I am getting error Incorrect Image on - .PaintPicture pctSource, 0, 0, w, h, X, Y, X + w, Y + h

CropAndSave Picture1, 500, 500, 1000, 1000, "C:\image.jpg"

Public Sub CropAndSave(pctSource As PictureBox, _
                       X As Integer, Y As Integer, _
                       h As Integer, w As Integer, _
                       sFile As String)
'=====================================================
Dim pct As PictureBox
 
    Set pct = Controls.Add("VB.Picturebox", "pctTemp")
    '---------------------------------------------------------------
    'TESTING ONLY
    'pct.Move pctSource.Left + pctSource.Width, pctSource.Top, w, h
    'pct.Visible = True
    '---------------------------------------------------------------
    With pct
        .Width = w
        .Height = h
        .AutoRedraw = True
        .AutoSize = True
        .PaintPicture pctSource, 0, 0, w, h, X, Y, X + w, Y + h
        .Refresh
        SavePicture pct.Image, sFile
    End With
    Controls.Remove "pctTemp"
    Set pct = Nothing
 
End Sub

Thanks

Answers (1)