Results 1 to 2 of 2

Thread: [RESOLVED] How do you crop a pic from the center of the pic.

  1. #1

    Thread Starter
    Fanatic Member newprogram's Avatar
    Join Date
    Apr 2006
    Location
    in your basement
    Posts
    769

    Resolved [RESOLVED] How do you crop a pic from the center of the pic.

    I need to load a bitmap in a Picture1 and crop to 125 x 43 form the center of the bitmap .
    Live life to the fullest!!

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How do you crop a pic from the center of the pic.

    You can do something like this (I used two pictureboxes):
    Code:
    Private Sub Command1_Click()
    Dim centerX%, centerY%
    Dim iWidth%, iHeight%
    
        centerX = Picture1.ScaleWidth / 2
        centerY = Picture1.ScaleHeight / 2
        
        iWidth = 1000
        iHeight = 500
    
        With Picture2
            .AutoRedraw = True
            .AutoSize = True
            .Width = iWidth
            .Height = iHeight
            
            .PaintPicture Picture1.Picture, 0, 0, _
                          iWidth, iHeight, _
                          centerX - iWidth / 2, centerY - iHeight / 2, _
                          iWidth, iHeight
            
            Set .Picture = .Image
            .Cls
        End With
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width