📄 exampl~3.cpp
字号:
// Example001View.cpp : CExample001View 类的实现
//
#include "stdafx.h"
#include "Example001.h"
#include "Example001Doc.h"
#include "Example001View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CExample001View
IMPLEMENT_DYNCREATE(CExample001View, CView)
BEGIN_MESSAGE_MAP(CExample001View, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CExample001View 构造/销毁
CExample001View::CExample001View()
{
// TODO: 在此处添加构造代码
}
CExample001View::~CExample001View()
{
}
BOOL CExample001View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// CExample001View 绘制
void CExample001View::OnDraw(CDC* pDC)
{
CExample001Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
using namespace Gdiplus;
Graphics graphics(pDC->m_hDC);
Image image(L"Test.bmp");
UINT width = image.GetWidth();
UINT height = image.GetHeight();
// Draw the image with no shrinking or stretching.
graphics.DrawImage( &image, Rect(10, 10, width, height),
0, 0, width, height, UnitPixel);
// Shrink the image using low-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);
graphics.DrawImage( &image,Rect(10, 220, 0.6*width, 0.6*height),
0, 0,width, height,UnitPixel);
// Shrink the image using medium-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeHighQualityBilinear);
graphics.DrawImage( &image,Rect(150, 220, 0.6 * width, 0.6 * height),
0, 0, width,height, UnitPixel);
// Shrink the image using high-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
graphics.DrawImage( &image,Rect(290, 220, 0.6 * width, 0.6 * height),
0, 0, width, height, UnitPixel);
}
// CExample001View 诊断
#ifdef _DEBUG
CExample001Doc* CExample001View::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExample001Doc)));
return (CExample001Doc*)m_pDocument;
}
#endif //_DEBUG
// CExample001View 消息处理程序
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -