📄 rgbcolorview.cpp
字号:
// RGBcolorView.cpp : implementation of the CRGBcolorView class
//
#include "stdafx.h"
#include "RGBcolor.h"
#include "RGBcolorDoc.h"
#include "RGBcolorView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView
IMPLEMENT_DYNCREATE(CRGBcolorView, CScrollView)
BEGIN_MESSAGE_MAP(CRGBcolorView, CScrollView)
//{{AFX_MSG_MAP(CRGBcolorView)
ON_COMMAND(ID_CovertYIQ, OnCovertYIQ)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView construction/destruction
CRGBcolorView::CRGBcolorView()
{
// TODO: add construction code here
}
CRGBcolorView::~CRGBcolorView()
{
}
BOOL CRGBcolorView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView drawing
void CRGBcolorView::OnDraw(CDC* pDC)
{
CRGBcolorDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//RGB color
for(int y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x,y,RGB(pDoc->r_Img[y][x],pDoc->g_Img[y][x],pDoc->b_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+300,y,RGB(pDoc->r_Img[y][x],pDoc->r_Img[y][x],pDoc->r_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+600,y,RGB(pDoc->g_Img[y][x],pDoc->g_Img[y][x],pDoc->g_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+900,y,RGB(pDoc->b_Img[y][x],pDoc->b_Img[y][x],pDoc->b_Img[y][x]));
//YIQ color
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x,y+300,RGB(pDoc->y_Img[y][x],pDoc->i_Img[y][x],pDoc->q_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+300,y+300,RGB(pDoc->y_Img[y][x],pDoc->y_Img[y][x],pDoc->y_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+600,y+300,RGB(pDoc->i_Img[y][x],pDoc->i_Img[y][x],pDoc->i_Img[y][x]));
for(y=0;y<256;y++)
for(int x=0;x<256;x++)
pDC->SetPixel(x+900,y+300,RGB(pDoc->q_Img[y][x],pDoc->q_Img[y][x],pDoc->q_Img[y][x]));
}
void CRGBcolorView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = 2048;
sizeTotal.cy = 1024;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView printing
BOOL CRGBcolorView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CRGBcolorView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CRGBcolorView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView diagnostics
#ifdef _DEBUG
void CRGBcolorView::AssertValid() const
{
CScrollView::AssertValid();
}
void CRGBcolorView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CRGBcolorDoc* CRGBcolorView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRGBcolorDoc)));
return (CRGBcolorDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRGBcolorView message handlers
void CRGBcolorView::OnCovertYIQ()
{
// TODO: Add your command handler code here
CRGBcolorDoc* pDoc;
pDoc=GetDocument();
ASSERT_VALID(pDoc);
pDoc->ConverYIQ();
Invalidate(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -