⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rgbcolordoc.cpp

📁 I used MFC. that code is not perfect and have some problem. But its function is Ok. You just fix
💻 CPP
字号:
// RGBcolorDoc.cpp : implementation of the CRGBcolorDoc class
//

#include "stdafx.h"
#include "RGBcolor.h"

#include "RGBcolorDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRGBcolorDoc

IMPLEMENT_DYNCREATE(CRGBcolorDoc, CDocument)

BEGIN_MESSAGE_MAP(CRGBcolorDoc, CDocument)
	//{{AFX_MSG_MAP(CRGBcolorDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRGBcolorDoc construction/destruction

CRGBcolorDoc::CRGBcolorDoc()
{
	// TODO: add one-time construction code here

}

CRGBcolorDoc::~CRGBcolorDoc()
{
}

BOOL CRGBcolorDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CRGBcolorDoc serialization

void CRGBcolorDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		ar.Write(resultImg, 256*256*3);
	}
	else
	{
		// TODO: add loading code here
		CFile *fp=ar.GetFile();
		if(fp->GetLength()==256*256*3)
		{
			ar.Read(inputImg,256*256*3);
			for(int i=0;i<256;i++)
			{
				for(int j=0;j<256;j++)
				{
					r_Img[i][j]=inputImg[0][i][j];
					g_Img[i][j]=inputImg[1][i][j];
					b_Img[i][j]=inputImg[2][i][j];
				}
			}
		}
		else AfxMessageBox("256*256*3 农扁狼 file父 荤侩啊瓷");
	}
}

/////////////////////////////////////////////////////////////////////////////
// CRGBcolorDoc diagnostics

#ifdef _DEBUG
void CRGBcolorDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CRGBcolorDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRGBcolorDoc commands

void CRGBcolorDoc::ConverYIQ()
{
	for(int i=0;i<256;i++)
	{
		for(int j=0;j<256;j++)
		{
			y_Img[i][j]=(unsigned char)(0.3*(int)r_Img[i][j]+0.59*(int)g_Img[i][j]+0.11*(int)b_Img[i][j]);
			if(y_Img[i][j]>255) y_Img[i][j]=255;
			i_Img[i][j]=(unsigned char)(0.6*(int)r_Img[i][j]-0.28*(int)g_Img[i][j]-0.32*(int)b_Img[i][j]);
			if(i_Img[i][j]>255) i_Img[i][j]=255;
			q_Img[i][j]=(unsigned char)(0.21*(int)r_Img[i][j]-0.125*(int)g_Img[i][j]+0.31*(int)b_Img[i][j]);
			if(q_Img[i][j]>255) q_Img[i][j]=255;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -