Solved

BitBlt of picturebox

Posted on 2011-03-14
5
946 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
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 85

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now