Click here to Skip to main content
15,889,659 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an application where I am storing images captured by camera in 320 * 480 format. But while loading this image I want to resize the image up to 32 * 32 OR 49 * 37. Can someone let me know how could we load the image or how could we store the images captured by camera in desired format / size.

EDIT
-----
Hi,
I am getting the error while exiting even if I use the release DC. PFB the code
I am trying to load big image and trying to resize it to smaller size.
C++
CImage img;
CImage sm_img;
HRESULT res = img.Load(_T("D:\\bbb.png"));

CDC *screenDC = GetDC();

int iNewWidth = 80;
int iNewHeight = 60;

sm_img.Create(iNewWidth, iNewHeight,32);

SetStretchBltMode(sm_img.GetDC(),COLORONCOLOR);
img.StretchBlt(sm_img.GetDC(),0, 0, iNewWidth, iNewHeight, SRCCOPY);
// The next two lines test the image on a picture control.
// The output has wrong color palette, like my initial version
HDC hdcpic = ::GetDC(hMyWindow);//hMyWindow --> of capCreateCaptureWindow

img.StretchBlt( hdcpic,0, 0, iNewWidth, iNewHeight, SRCCOPY);

sm_img.Save(_T("D:\\bbb1.png"));
sm_img.ReleaseDC(); // Here I release the DC but still
                        // this code is giving error while exiting
ReleaseDC(screenDC);

Please suggest me what could be the problem.

Thanks in advance.
Posted
Updated 11-Jul-13 3:21am
v3
Comments
nv3 11-Jul-13 9:23am    
That looks a lot better now than posting your amendments as a solution. I have added a pre-tag to mark the code block as such and that makes it even more readable.
nv3 11-Jul-13 10:22am    
What exactly is the error you are getting in the exit sequence? How did you conclude that it has to do with sm_img.ReleaseDC?
SNI 12-Jul-13 5:25am    
I have seen the solution 1 below mentioned, there it is saying the problem with sm_img.ReleaseDC. I am getting error while exiting is Assertion Failed expression m_hDC == 0.

1 solution

There is an already existing question with a solution that might fit your needs. Have a look at this please: How to use CImage class to resize a bitmap[^].

Regards,
— Manfred
 
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