We help IT Professionals succeed at work.
Get Started

How to save a bmp from a control?

340 Views
Last Modified: 2013-11-26
Hello everybody!

I have the following issue,
I need to take a picture from a control and save it as BMP.
As you can see in the image attached, you can see that I have a windows form with some sort of controls. I need to take the picture from the chart.
Then, the picture I took must be shown in the upper right panel.

In advance, many thanks :D

PS: As you can see, I'm not being able to capture the exact area.
PS2: Attaching Code :D
Private Function CapturarPintura() As Bitmap

        Dim bm As Bitmap
        Dim gr As Graphics = Me.CreateGraphics
        Dim fSize As Size = Me.GB_Grafico.Size

        bm = New Bitmap(Me.GB_Grafico.Width, Me.GB_Grafico.Height, gr)
        Dim gr2 As Graphics = Graphics.FromImage(bm)
        Dim pt As New System.Drawing.Point
        pt = Me.GB_Grafico.Location

        gr2.CopyFromScreen(Me.Location.X + pt.X, Me.Location.Y + pt.Y, 0, 0, fSize)

        Return bm
    End Function

Open in new window

form.png
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE