Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks,
I've just started programming using MFC and still not familiar with its classes!
I have loaded a multispectral images using GDAL library. I want to add zooming function into my program.
First, I display my image into client area using this code:
VB
::SetDIBitsToDevice(pDC->GetSafeHdc(), 0, 0,
        nXSize, nYSize,
        0, 0,
        0, nYSize,
        m_DispImage,
        &btminf,
        DIB_RGB_COLORS);

The image is larger than the client area. I want the user to push the zoomtofit button and the image would be fitted to the client area. I calculated the size of the image in new format and use this code to do the task:
HDC hdcMem=CreateCompatibleDC(pDC->GetSafeHdc());
	::StretchBlt (hdcMem,
		0, 0,
		XSize, YSize,
		pDC->GetSafeHdc(),
		0, 0,
		nXSize, nYSize,
		SRCCOPY ); 

But nothing is shown in the client area. Do you know what is the problem?
Posted

1 solution

When you create a memory device context with CreateCompatibleDC you have to select a memory bitmap into it to give it a canvas to draw onto. By default a memory DC will have a single pixel black and white bitmap.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900