|
-
Jun 12th, 2002, 12:59 AM
#1
Thread Starter
Hyperactive Member
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.
-
Jun 12th, 2002, 01:03 AM
#2
PowerPoster
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>
-
Jun 12th, 2002, 01:12 AM
#3
Thread Starter
Hyperactive Member
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 =)
-
Jun 12th, 2002, 01:24 AM
#4
Thread Starter
Hyperactive Member
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:
Option Explicit
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
Private Sub Form_Load()
Dim a As Integer
Do Until a > pic.Height
pic.Line (0, a)-(pic.Width, a), vbBlack
a = a + 240
Loop
a = 0
Do Until a > pic.Width
pic.Line (a, 0)-(a, pic.Height), vbBlack
a = a + 240
Loop
End Sub
'''above should all make sense(just drawing the grid)
Private Sub pic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic1.Cls
Dim a As Long
Dim b As Long
a = (X \ 240) * 240
b = (Y \ 240) * 240
BitBlt pic1.hDC, 0, 0, 240, 240, pic.hDC, a, b, vbSrcCopy
Me.Caption = a & " " & b
End Sub
Private Sub pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Caption = X & " " & Y
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|