hdc

copy hdc contents to bitmap

How could you copy the contents of an HDC to a bitmap? ...

how to set GDI HDC's drawable region?

I want to draw a HBITMAP onto HDC, I used StretchDIBits. It works fine. ::StretchDIBits. however, I only want a window to watch the drawing result, beside the window, I wish the stretchDIBits do not take any effect(It can not draw on other area), how can I do this? ...

Why can't I stretchBlt a dc onto another dc?

Why can't the following code draw the content of graphics onto finalDC? It just draw black rectangle; Bitmap* bitmapCanvasCore = new Bitmap(width, height ,PixelFormat24bppRGB); xxxxxx // operation on bitmapCanvasCore... Graphics * canvasGraphics = new Graphics(bitmapCanvasCore); HDC tempdc = m_UnSelectedGraphics->GetHDC(); ::SetStretchB...

How to Convert a gdi+ Bitmap-like struct into an HDC?

How to Convert a Bitmap-like struct into an HDC? I am now writting image processing program in c++, gdi. If I got a HDC. I can draw whatever I like on the HDC in gdi by the following code. // HDC is handy. HDC dc; dc.DrawXXX // I can draw using gdi method. Graphics gr(dc); // now I can also draw on the dc using gdi+ method. My...

Drawing transparent/alpha images using CxImage

I am trying to draw a transparent (alpha) PNG image using CxImage, but it seems I'm missing some obvious step... The code so far is: CxImage image(m_pImage, m_lSize, CXIMAGE_FORMAT_UNKNOWN); CRect rcOut = rc; rcOut.left = (rc.Width()/2) - (image.GetWidth()/2); rcOut.right = rcOut.left + image.GetWidth(); rcOut.top = (rc.Height()/2) - (...

Given an HDC, how can I determine what the name of the application is?

I have an HDC object and I'd like to use it to get the name of the program that created it (such as Notepad or Firefox). Is there a way to do this? If not, how can I do this? ...

Searching Graphics Device Context For Pixels of Specific Color

I'm working on writing some automation code and I'm running into a problem finding an efficient way to examine the pixels that presently exist on the display. I've familiarized myself with the GetPixel function that exists in the gdi32 library, but it's too slow (in fact it takes about 10 seconds just to scan a line of about 1900 pixel...

Does HDC use alpha channel?

Hello. Is there a way I can determine if an HDC uses alpha channel? I read Question 333559 and Question 685684, but their questions are about BITMAP. Apparently, some HDC has alpha channel (though they may not use it. Call this "Type 1") while others do not ("Type 2"). I know this by doing the following: Given a HDC, Create a compatib...

Sharing HDC between different processes

Hi, I am writing some kind of IPC functionality and need to pass certain resources from one process to another. This works well for Pipe handles etc. which can be duplicated via DuplicateHandle. Now I need to pass a HDC from one process to the other. Is this even possible? If yes: how? Sub-Question: I am assuming passing window handles...

Problem with colors

I was coding a snake game, and i got an apple image to use in the game, so i created a DC and then loaded the apple to this DC, when the game is running, it should copy the apple to the buffer and then the buffer to the screen, but the apple ends black and white in the screen, any1 has idea why? here is some of my code, might help... ...

C++: Unhandled exception at 0x0b9ec715 (XX.dll) in XY.exe: 0xC0000005: Access violation reading location 0x00000004.

How do I debug the above error? I'm using C++ with Microsoft Visual Studio. Below is part of the code: HDC dc =*mMemDC; X->SelectPalette(dc); When I debug the code, it crashes on the line X->selectPallete(dc); ...

Printing PDF to HDC (MFC device context)

Hi, I'm modifying a C++ application and I'd like to add the ability to print and existing PDF using the MFC printing logic (OnPrint...) Is there any method to print a PDF into the MFC? Now I'm converting the PDF to a BMP but sometimes the quality is not so great. ...