Results 1 to 3 of 3

Thread: Picturebox ReSize or Cut

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11

    Unhappy Picturebox ReSize or Cut

    I have a problem with my picturebox. I draw alot of lines and data in it and everything works fine.

    From the beginning the size of the picturebox is 600x600 and it has to be. When I have finished drawin in it, I need to "Cut" the picture down to 600x300, In other words cut the bottom half out. I do this because sometimes it's no data there, and when I save the picture with the SavePicture function, the picture will be half the size if I cut it down to 600x300 instead of 600x600.

    Here is the problem: When I change the height of the picture to 300 and then save it, it will still be the same size(600x600) with the same unnecessary space in the picture.



    In short : I want to "Cut off" the bottom half of a picture in a picturebox....how do I do this .. ??

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    This one has sample code of cropping ...
    http://www.exhedra.com/upload/ftp/Ad...6403262002.zip

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Here you go, I've rewritten it in Engliish or you could say I've cropped the code for you
    To see this in action, create a new app & shove 2 pictureboxes & 1 command button on a form.
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim XUpperLeft As Long
    4.     Dim YUpperLeft As Long
    5.     Dim XLowerRight As Long
    6.     Dim YLowerRight As Long
    7.  
    8.     XUpperLeft = Picture1.Left
    9.     YUpperLeft = Picture1.Top
    10.     XLowerRight = 2000
    11.     YLowerRight = 2000
    12.  
    13.     With picture2
    14.         .Picture = LoadPicture()
    15.         .Cls
    16.         DoEvents
    17.    
    18.         .PaintPicture Picture1.Picture, 0, 0, (XLowerRight - XUpperLeft), _
    19.         (YLowerRight - YUpperLeft), XUpperLeft, YUpperLeft, _
    20.         (XLowerRight - XUpperLeft), (YLowerRight - YUpperLeft)
    21.        
    22.         DoEvents
    23.     End With
    24.  
    25. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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