Solved

BitBlt of picturebox

Posted on 2011-03-14
5
980 Views
Last Modified: 2013-12-17
I have 2 pictures box.  One already got a bitmap loaded, and i would like to try to do a copy with BitBlt.  I know that there's probably already a function to do that, but i'm trying to test the performance of a bitblt in c# thru pinvoke vs c++.

How do i get the HDC of the picture boxes?

thanks
0
Comment
Question by:cdebel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 100 total points
ID: 35129235
Check this, I think this is what you're looking for.

http://www.eggheadcafe.com/software/aspnet/30688052/the-mighty-bitblt.aspx

Hope that helps.
0
 
LVL 12

Accepted Solution

by:
Mohamed Abowarda earned 350 total points
ID: 35129954
You need to use GetDC API to get the picturebox hDC:
http://msdn.microsoft.com/en-us/library/dd144871(v=vs.85).aspx

1. Add the line "using System.Runtime.InteropServices;" above the namespace
2. Add the following line to your form class:
    [DllImport("user32.dll")]
    public static extern IntPtr GetDC(IntPtr hWnd);

3. Use the following code to get the picturebox hDC
IntPtr hDC = GetDC(pictureBox1.Handle);

Open in new window

0
 
LVL 10

Author Comment

by:cdebel
ID: 35130582
Thanks a lot Medo, it work just fine!
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 50 total points
ID: 35130608
...be sure to use ReleaseDC() to prevent GDI leaks.
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35130659
You are very welcome :)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question