Results 1 to 4 of 4

Thread: Picture Box Portions

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Picture Box Portions

    Is there a way to take only a portion of a picture thats in a picture box. like you only want (100,100)-(250,250) and then insert it into a different picture box.
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    You can use BitBlt to do this:
    Code:
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
    ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight _
    As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
    ByVal dwRop As Long) As Long
    
    Public Sub CutPic()
    BitBlt Picture2.hDC, 0, 0, 150, 150, Picture1.hDC, 100, 100, vbSrcCopy
    End Sub
    That is just a simple example
    Last edited by MidgetsBro; Jun 12th, 2002 at 01:08 AM.
    <removed by admin>

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Thanks

    Doesn't work right with my program but...I got the idea and I am getting something just not what I want/need. Thanks a lot though hopefully I will get it soon =)
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  4. #4

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Maybe...

    Maybe I got this all wrong...but there seems to be something wrong...

    I have to picture boxes pic1, pic2. Pic1 has the picture in it and it has a grid that has 240,240 squares.

    VB Code:
    1. Option Explicit
    2. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    3.  
    4.  
    5. Private Sub Form_Load()
    6. Dim a As Integer
    7. Do Until a > pic.Height
    8. pic.Line (0, a)-(pic.Width, a), vbBlack
    9. a = a + 240
    10. Loop
    11.  
    12. a = 0
    13. Do Until a > pic.Width
    14. pic.Line (a, 0)-(a, pic.Height), vbBlack
    15. a = a + 240
    16. Loop
    17. End Sub
    18.  
    19. '''above should all make sense(just drawing the grid)
    20.  
    21.  
    22. Private Sub pic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    23. pic1.Cls
    24. Dim a As Long
    25. Dim b As Long
    26. a = (X \ 240) * 240
    27. b = (Y \ 240) * 240
    28. BitBlt pic1.hDC, 0, 0, 240, 240, pic.hDC, a, b, vbSrcCopy
    29. Me.Caption = a & "   " & b
    30. End Sub
    31.  
    32. Private Sub pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    33. Me.Caption = X & "   " & Y
    34. End Sub

    now the me.captions are in there just to see what the cordinates are.... a and b are both working properly giving me the top left corner of the current grid spot the mouse is in therefor the pictures right side should be a + 240 and the pictures bottom should be b + 240. But when i use that code the picture that shows in pic1 is 3600, 3600 and is all over the place never in the correct spot. I just wanted to show the picture in the top left corner of pic1 hence the (BitBlt pic1.hDC, 0, 0, 240, 240) and then get it from pic and start at cordinates a, b hence the (pic.hDC, a, b)....am I completly off on what I am suppose to do?
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

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