Hello Community,
I was wondering if there is a way to get only the visible section of the image from picturebox1 and place it in picturebox2.

So what I have is picturebox1 set to a certain size, and the image size mode is set to center. Picturebox2 is also set to a certain size but the size mode is set to sketch. In the example I've attached the dash line represents the border of picturebox1. So what is on the inside is what I want moved to the second picturebox. Note all the images in going in picturebox1, most of them won't be the same size.

Recommended Answers

All 3 Replies

Maybe this is what you want?

Dim x As Integer = PictureBox1.Width
        Dim y As Integer = PictureBox1.Height
        Dim bm As New Bitmap(x, y)

        PictureBox1.DrawToBitmap(bm, New Rectangle(0, 0, x, y))

        PictureBox2.Image = bm

Thanks both or you have given me code that does what I want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.