View Single Post
 
Old 02-13-2018, 10:13 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,031
Default

You probably should have posted an example of the code you're using so we could see it, and possibly identify a problem or suggest an alternative.
Given that you want to use a picture in a picture approach, here is a test case I tried.
I just added this to the example code I gave in the other post regarding color remapping, which is why it is using picturebox 3 and 4, rather than 1 and 2.
I stripped out the other code that dealt with the colormapping when posting here.
I just added a picturebox (picturebox3) and a much larger picturebox (picturebox4) to the form, and then tested with the following code.
Code:
    Private Sub Form1_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown

        'Create a bitmap and have picturebox4 reference it
        'Put picturebox4 in picturebox3 (locate at 0,0 to start)
        'Fill the picturebox4 bitmap with ellipses so we have something to see when we drag the picturebox around
        PictureBox4.Image = New Bitmap(PictureBox4.Width, PictureBox4.Height)
        PictureBox4.Parent = PictureBox3
        PictureBox4.Location = New Point(0, 0)
        Dim rand As New Random
        Dim w As Integer = PictureBox4.Width
        Dim h As Integer = PictureBox4.Height
        Using g As Graphics = Graphics.FromImage(PictureBox4.Image)
            For i As Integer = 1 To 100
                Using br As New SolidBrush(Color.FromArgb(255, rand.Next(255), rand.Next(255), rand.Next(255)))
                    g.FillEllipse(br, New Rectangle(rand.Next(w \ 2), rand.Next(h \ 2), rand.Next(10 + w \ 2), rand.Next(10 + h \ 2)))
                End Using
            Next
        End Using
    End Sub

    Private Sub PictureBox4_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseMove
        'Code to drag picturebox4 around using the left mouse button (have to click inside picturebox4)
        Static lpos As Point
        If e.Button = Windows.Forms.MouseButtons.Left Then
            PictureBox4.Location += New Size(e.X - lpos.X, e.Y - lpos.Y)
        Else
            lpos = e.Location
        End If
    End Sub
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote