Please tell me how to create a bitmap. Draw on it and how to save that bitmap to a bmp file.
I done following : on a button click event.
Expand|Select|Wrap|Line Numbers
- CDC* pDC = GetDC();
- CDC memDC;
- CBitmap newbmp;
- CImage img;
- CBrush brush;
- brush.CreateSolidBrush(RGB(0, 0, 255));
- pDC->SelectObject(&brush);
- memDC.CreateCompatibleDC(pDC);
- btmap.CreateCompatibleBitmap(&memDC, 300, 300);
- pDC->Rectangle(10, 10, 80, 80);
- pDC->Ellipse(60,60,220,220);
- memDC.SelectObject(&newbmp);
- memDC.BitBlt(0,0,300,300,pDC,0,0,SRCCOPY);
- CString loc("C:\\atest.bmp");
- LPCTSTR bmp = (LPCTSTR)loc;
- img.Attach(newbmp);
- img.Save(bmp,Gdiplus::ImageFormatBMP);
- ReleaseDC(pDC);
Every thing we draw with pDC come on the screen. Such that is there any way to draw to CDC of bitmap (similar to CDC pDC = GetDC();). And when we save it then only what we draw on that CDC should be saved, nothing more.
Please reply immediatly ..
Thanks in advance
Aqeek