The study of Programming Windows with MFC--BitMap
来源:互联网 发布:虚无世界2java下载 编辑:程序博客网 时间:2024/05/08 12:10
1.DDB and CBitMap
CClientDC dcScreen(this);
CBitmap bitmap;
bitmap.CreateCompatibleBitMap(&dcScreen,m_nWidth,m_nHeight);
CDC dcMem;
dcMem.CreateCompatibleDC(&dcScreen);
CBitMap *pOldBitMap=dcMem.SelectObject(&bitmap);
CBrush brush(RGB(255,255,0);
dcMem.FillRect(CRect(0,0,100,100),&brush);
dcMem.SelectObject(pOldBitmap);
2.Blit Bitmap to Screen and Other Devices
void CMyBitMap::DrawBitmap(CDC *pDC, int x, int y)
{
BITMAP bm;
GetBitmap(&bm);
CSize size(bm.bmWidth, bm.bmHeight);
pDC->DPtoLP(&size);
CPoint Org(0,0);
pDC->DPtoLP(&Org);
CDC dcMem;
dcMem->CreateCompatibleDC(pDC);
CBitmap *pOldBitmap=dcMem.SelectObjec(this);
dcMem.SetMapMode(pDC->GetMapMode ());
pDC->BitBlit(x,y,size.x,size.y,pDC,Org.x,Org.y,SRCCOPY);
dcMem.SelectObject(pOldBitmap);
}
//When you pass CDC::DPtoLP the address of a CPoint object, the call goes straight through to the ::DPtoLP API function and the conversion is performed properly, even if one or more of the coordinates comes back negative. But when you pass CDC::DPtoLP the address of a CSize object, MFC performs the conversion itself and converts any negatives to positives.
3.LoadMap
//.rc
IDB_MYLOGO BITMAP Logo.bmp
CBitmap bitmap;
bitmap.LoadBitmap (IDB_MYLOGO); //bitmap.LoadMappedBitmap (IDB_BITMAP);
4.the structure of The BitmapDemo application
class CMainFrame:public CFrameWnd
{
public:
CMainFrame();
protected:
DECLARE_DYNAMIC(CMainWnd);
public:
virtual BOOL PreCreateWindow(CREATESTRUCT &cs)
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo);
virtual ~CMainWnd();
protected:
CStatusBar m_wndStatusBar;
CChildView m_wndView;
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg BOOL OnQueryNewPalette();
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
DECLARE_MESSAGE_MAP()
};
class CChildView : public CWnd
{
public:
CChildView();
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual ~CChildView();
protected:
void DoGradientFill (CDC* pDC, LPRECT pRect);
CPalette m_palette;
CMaskedBitmap m_bitmap;
BOOL m_bDrawOpaque;
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnOptionsDrawOpaque();
afx_msg void OnOptionsDrawTransparent();
afx_msg void OnUpdateOptionsDrawOpaque(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsDrawTransparent(CCmdUI* pCmdUI);
DECLARE_MESSAGE_MAP()
};
class CMaskedBitmap : public CBitmap
{
public:
void DrawTransparent (CDC* pDC, int x, int y,COLORREF clrTransparency);
void Draw (CDC* pDC, int x, int y);
};
- The study of Programming Windows with MFC--BitMap
- The study of Programming Windows with MFC
- The study of Programming Windows with MFC--print's example
- The study of Programming Windows with MFC-printing tips
- The study of Programming Windows with MFC-Palette
- The Study of Programming Windows with MFC--Bitmap2
- The study of Programming Windows with MFC--CRgn
- The study of Programming Windows with MFC--Common Control
- The Study of Programming Windows with MFC--Slider,Spin,ToolTip
- The Study of Programming Windows with MFC--Imagelist and ComboBoxEx
- The study of chapter 13 in programming windows with mfc-printing with document and views
- The Study of Programming Windows with MFC--Progress and Animate control
- The study of Programming Windows with MFC--Ip Address control and Date control
- the study of programmng windows with mfc--timer
- programming windows with MFC
- study of The C Programming Language
- Programming Windows with MFC - Chapter 12 Toolbars
- Tricks of the Windows game programming gurus
- sip trunk 問題
- C# 获取系统关联文件图标完整类
- C# 获取系统关联文件图标完整类
- 消费者应该如何回收处理电子垃圾?
- 相对路径
- The study of Programming Windows with MFC--BitMap
- CLI 日志查询
- 通用序列化类
- 你不是菜鸟(7):五年工作经验的笨蛋
- 打电话时查看log
- Android--将数据保存到SDCard中
- 关于3d圆球顶点数据算法
- 超牛JS
- XMLHttpRequest对象的属性和事件