我有一副bmp图像,怎么在vc++ 6.0下显示出来? 10
5个回答
展开全部
我只知道 MFC 下加载位图
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我这有现成的例子你要是要可以发一份给你,在MFC框架下的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把位图当作资源插入,然后关联对象,再贴图
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
OnDraw()函数中:
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDc);
dcCompatible.selectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
pDc->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
OnDraw()函数中:
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDc);
dcCompatible.selectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
pDc->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
// BMPViewerView.cpp : implementation of the CBMPViewerView class
//
#include "stdafx.h"
#include "BMPViewer.h"
#include "BMPViewerDoc.h"
#include "BMPViewerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView
IMPLEMENT_DYNCREATE(CBMPViewerView, CView)
BEGIN_MESSAGE_MAP(CBMPViewerView, CView)
//{{AFX_MSG_MAP(CBMPViewerView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView construction/destruction
CBMPViewerView::CBMPViewerView()
{
// TODO: add construction code here
}
CBMPViewerView::~CBMPViewerView()
{
}
BOOL CBMPViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView drawing
void CBMPViewerView::OnDraw(CDC* pDC)
{
CBMPViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView diagnostics
#ifdef _DEBUG
void CBMPViewerView::AssertValid() const
{
CView::AssertValid();
}
void CBMPViewerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CBMPViewerDoc* CBMPViewerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBMPViewerDoc)));
return (CBMPViewerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView message handlers
void CBMPViewerView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//得到文档指针
CBMPViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//是否已打开某个BMP文件
if(pDoc->flag==1)
{
//指定是显示的颜色
SetDIBitsToDevice(dc.m_hDC,0,0,pDoc->pbi->bmiHeader.biWidth,
pDoc->pbi->bmiHeader.biHeight,0,0,0,
pDoc->pbi->bmiHeader.biHeight,pDoc->lpshowbuf,
pDoc->pbi,DIB_RGB_COLORS);
}
// Do not call CView::OnPaint() for painting messages
}
//
#include "stdafx.h"
#include "BMPViewer.h"
#include "BMPViewerDoc.h"
#include "BMPViewerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView
IMPLEMENT_DYNCREATE(CBMPViewerView, CView)
BEGIN_MESSAGE_MAP(CBMPViewerView, CView)
//{{AFX_MSG_MAP(CBMPViewerView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView construction/destruction
CBMPViewerView::CBMPViewerView()
{
// TODO: add construction code here
}
CBMPViewerView::~CBMPViewerView()
{
}
BOOL CBMPViewerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView drawing
void CBMPViewerView::OnDraw(CDC* pDC)
{
CBMPViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView diagnostics
#ifdef _DEBUG
void CBMPViewerView::AssertValid() const
{
CView::AssertValid();
}
void CBMPViewerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CBMPViewerDoc* CBMPViewerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBMPViewerDoc)));
return (CBMPViewerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBMPViewerView message handlers
void CBMPViewerView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//得到文档指针
CBMPViewerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//是否已打开某个BMP文件
if(pDoc->flag==1)
{
//指定是显示的颜色
SetDIBitsToDevice(dc.m_hDC,0,0,pDoc->pbi->bmiHeader.biWidth,
pDoc->pbi->bmiHeader.biHeight,0,0,0,
pDoc->pbi->bmiHeader.biHeight,pDoc->lpshowbuf,
pDoc->pbi,DIB_RGB_COLORS);
}
// Do not call CView::OnPaint() for painting messages
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询