![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
12 years old
Join Date: Nov 2007
Posts: 94
Rep Power: 1
![]() |
[win32][gdi32] Copying HDC to another?
I've tried to do CreateCompatibleDC(source_device) but it contains a result the same height and size as source_device but every pixel as black. Any help?
const int SCREEN_WIDTH = GetSystemMetrics(SM_CXSCREEN) - 1;
const int SCREEN_HEIGHT = GetSystemMetrics(SM_CXSCREEN) - 1;
...
int x;
HDC screen_device = GetDC(NULL);
HDC copy = CreateCompatibleDC(screen_device);
for (x = 0; x <= SCREEN_WIDTH; ++x) {
for (int y = 0; y <= SCREEN_HEIGHT; ++y) {
SetPixel(screen_device, x, y, GetPixel(copy, SCREEN_WIDTH - x, y));
}
}
...EDIT: I see I have to use BitBlt? If so, may I have an example? I have an inefficiency in understanding win32 argument names. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
Re: [win32][gdi32] Copying HDC to another?
You code seems to be setting the pixels in the screen device from the copy, I think it should be the other way around.
|
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: [win32][gdi32] Copying HDC to another?
In your second line, you use
SM_CXSCREEN when it should be SM_CYSCREEN. I think The Dark found your main problem though. |
|
|
|
|
|
#4 |
|
12 years old
Join Date: Nov 2007
Posts: 94
Rep Power: 1
![]() |
Re: [win32][gdi32] Copying HDC to another?
|
|
|
|
|
|
#5 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: [win32][gdi32] Copying HDC to another?
From the CreateCompatibleDC page:
Quote:
|
|
|
|
|
|
|
#6 |
|
12 years old
Join Date: Nov 2007
Posts: 94
Rep Power: 1
![]() |
Re: [win32][gdi32] Copying HDC to another?
your link points to GetDC
edit: how would i set the newly created HBITMAP's pixels? |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: [win32][gdi32] Copying HDC to another?
Sorry. Here's the real link.
I believe you can do as you were doing after you call CreateCompatibleBitmap. Don't forget that you have to call it on screen_device and then call SelectObject. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| more problems with copying from classes | cwl157 | Java | 0 | Sep 19th, 2007 4:17 PM |
| copying files | rwm | C++ | 8 | Apr 26th, 2007 2:39 AM |
| String to Morse Code - Copying from string to string | Xenon | C | 29 | Nov 10th, 2005 2:30 PM |
| Copying memory address values | rsnd | C++ | 4 | Jun 19th, 2005 7:41 AM |
| copying files first before deleting them | harjit | Visual Basic | 1 | May 15th, 2005 7:05 AM |