MapleStory Finger Point

πŸ”΅ C,C++,C#/C++ (MFC) κ°œλ…μ •λ¦¬

RAW

HYEJU01 2021. 12. 5. 23:40


●Invalidate() -> View

이 ν•¨μˆ˜λŠ” CWndμ—μ„œ νŒŒμƒλœ ν•¨μˆ˜λ‘œμ¨ View(CWndμ—μ„œ νŒŒμƒλœ ν΄λž˜μŠ€μ—μ„œ) ν΄λž˜μŠ€ μ•ˆμ—μ„œ μ‹€ν–‰μ΄ κ°€λŠ₯ν•˜λ‹€. 
View클래슀 μ•ˆμ—μžˆλŠ” OnDraw() ν•¨μˆ˜λŠ” WM_PAINT λ©”세지에 μ˜ν•΄ ν˜ΈμΆœλ˜λ„둝 λ§Œλ“€μ–΄μ Έ μžˆλ‹€. μ΄λŸ¬ν•œ λ©”세지λ₯Ό μ‚¬μš©μžκ°€ μ›ν•˜λŠ” μ‹œμ μ— μž„μ˜λ‘œ ν˜ΈμΆœν•  μˆ˜ μžˆκ²Œ ν•΄μ£ΌλŠ” λ°©λ²•μ€‘ ν•˜λ‚˜κ°€ Invalidate() ν•¨μˆ˜λΌκ³  ν•  μˆ˜ μžˆκ² λ‹€.
이 ν•¨μˆ˜λŠ” ν˜ΈμΆœν•œ ν΄λΌμ΄μ–ΈνŠΈ μœˆλ„μš°μ˜ ν™”면을 λ¬΄νš¨ν™”μ‹œν‚¨λ‹€. ν™”면이 λ¬΄νš¨ν™”λ˜λ©΄ μ‹œμŠ€ν…œμ€ WM_PAINT λ©”세지λ₯Ό λ°œμƒμ‹œν‚¨λ‹€. μ¦‰ μ›ν•˜λŠ” μœˆλ„μš°μ˜ ν™”면을 κ°•μ œλ‘œ κ°±μ‹ ν•  λ•Œ μ‚¬μš©ν•œλ‹€.


●UpdateAllViews() -> Docu

κ·Έλ ‡λ‹€λ©΄ View ν΄λž˜μŠ€κ°€ μ•„λ‹Œ Document ν΄λž˜μŠ€μ—μ„œλŠ” Invalidate() ν•¨μˆ˜λ₯Ό μ–΄λ–»κ²Œ μ‹€ν–‰μ‹œν‚¬μˆ˜ μžˆμ„κΉŒ?
CWndν΄λž˜μŠ€μ—μ„œ νŒŒμƒλœκ²ƒμ΄ μ•„λ‹Œ Document ν΄λž˜μŠ€λŠ” Invalidate()λ₯Ό μ‚¬μš©ν•  μˆ˜λŠ” μ—†λ‹€.
ν•˜μ§€λ§Œ Invalidate() ν•¨μˆ˜μ™€ λ§ˆμ°¬κ°€μ§€λ‘œ ν΄λΌμ΄μ–ΈνŠΈμ˜ μ˜μ—­μ„ λ¬΄νš¨ν™” μ‹œν‚€λŠ” UpdateAllViews() ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•  μˆ˜ μžˆλ‹€.


● RAW 파일 읽기

MDI λͺ¨λ“œ
λΉ„μ£Όμ–Ό μŠ€νƒ€μΌ λ° μƒ‰ : Windows μ›ν˜•/κΈ°λ³Έ
λ¬Έμ„œν…œν”Œλ¦Ώ μ†μ„±  : νŒŒμΌν™•μž₯λͺ… : RAW
μƒμ„±λœ ν΄λž˜μŠ€ : κΈ°λ³Έν΄λž˜μŠ€ -> CScrollView

Docu μ„ μ–Έ

public:
unsigned char m_InImg[256][256];
unsigned char m_OutImg[256][256];


μ΄ˆκΈ°ν™”

m_InImg[256][256] = NULL
m_OutImg[256][256] = NULL


Draw()μ—μ„œ

for (int i = 0; i < 256; i++)
{
for (int j = 0; j < 256; j++)
{
unsigned char InVal = pDoc->m_InImg[i][j];
unsigned char OutVal = pDoc->m_OutImg[i][j];
pDC->SetPixel(j, i, RGB(InVal, InVal, InVal));
pDC->SetPixel(j+300, i, RGB(OutVal, OutVal, OutVal));
}
}

● 파일 역상 

 

메뉴에 Reverse ν•˜λ‚˜ λ§Œλ“€κ³ 
속성을
ID : IDW_REVERSE_IMG
Caption : μ—­μƒκ³„μ‚°(Doc)
Prompt : μ΄λ―Έμ§€μ˜ μ—­μƒκ°’을 κ³„μ‚°


μœ„μ €λ“œ Docμ—μ„œ IDW_REVERSE_IMGλ₯Ό μΆ”κ°€

void CWinTestDoc::OnIdwReverseImg()
{
// TODO: 여기에λͺ…λ Ήμ²˜λ¦¬κΈ°μ½”λ“œλ₯ΌμΆ”κ°€ν•©λ‹ˆλ‹€.
AfxMessageBox(_T("역상계산"));  //메뉴와 ν•¨μˆ˜ μ—°κ²° 확인
}


void CWinTestDoc::OnIdwReverseImg()
{
// TODO: 여기에λͺ…λ Ήμ²˜λ¦¬κΈ°μ½”λ“œλ₯ΌμΆ”κ°€ν•©λ‹ˆλ‹€.
for (int i = 0; i < 256; i++)
for (int j = 0; j < 256; j++)
m_OutImg[i][j] = 255 - m_InImg[i][j];
UpdateAllViews(NULL);
}



Viewμ—μ„œ μž‘μ—…

void CWinTestView::OnReaveseView()
{
CWinTestDoc* pDoc = GetDocument(); 2. 
//Doc κ°’ μ£Όκ³ λ°›μœΌλ €λ©΄ ν”„λ‘œμ νŠΈλͺ…에 λŒ€ν•œ onDraw에 μžˆλŠ”  pDC = getDocument() λ₯Ό 값이 ν•„μš”ν•¨

for (int i = 0; i < 256; i++)
	for (int j = 0; j < 256; j++)
		pDoc->m_OutImg[i][j] = 255 - pDoc->m_InImg[i][j];

Invalidate(); //ν˜„μž¬ν™”λ©΄μ„ μ§€μš°κ³  λ‹€μ‹œκ·Έλ¦Ό 
}

 

 

//밝기

void CMFCApplication3Doc::OnLight_40() //-40
{
	// TODO: 여기에 λͺ…λ Ή 처리기 μ½”λ“œλ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (m_InImg[i][j] - 40 <= 0) //0~255 
				m_OutImg[i][j] = 0; 
			else				
				m_OutImg[i][j] = m_InImg[i][j] - 40; 

	UpdateAllViews(NULL);
}
/////////////
void CMFCApplication3View::OnLight30() //+30
{
	// TODO: 여기에 λͺ…λ Ή 처리기 μ½”λ“œλ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.
	CMFCApplication3Doc* pDoc = GetDocument();
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (pDoc->m_InImg[i][j] + 30 > 255) //0~255 
				pDoc->m_OutImg[i][j] = 255; 
			else
				pDoc->m_OutImg[i][j] = pDoc->m_InImg[i][j] + 30;

	Invalidate();

 

● X 그리기 

 

Viewμ—μ„œ μž‘μ—…

void DrawX(CPoint point);

void CMFCApplication1View::DrawX(CPoint point)
{
CClientDC dc(this);

dc.MoveTo(point.x - 10, point.y - 10);
dc.LineTo(point.x + 10, point.y + 10);
dc.MoveTo(point.x - 10, point.y + 10);
dc.LineTo(point.x + 10, point.y - 10);
}


void CMFCApplication2View::OnLButtonDown(UINT nFlags, CPoint point)
{
DrawX(point);  // 확인
}


Docu.h μ— μ„ μ–Έ

public:
int m_nCount;  //μƒμ„±μžμ— 0으둜 μ΄ˆκΈ°ν™”
CPoint m_ptData[100];


LButtonDown을 μ•„λž˜ μ½”λ“œλ‘œ λ³€κ²½
if (pDoc->m_nCount < 100)
{
pDoc->m_ptData[pDoc->m_nCount] = point
pDoc->m_nCount++;
DrawX(point);
}


Viewμ—μ„œ μž‘μ—…

μ§€μ›Œμ§ 방지λ₯Ό μœ„ν•΄ OnDraw에(λ„νμ—μ„œ 이벀트 λ§ˆλ‹€ λ‹€μ‹œ 데이터 κ°€μ Έμ˜΄)

for (int i = 0; i<pDoc->m_nCount; i++)
DrawX(pDoc->m_ptData[i]);



데이터 μ €μž₯

void CMFCApplication1Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: 여기에저μž₯μ½”λ“œλ₯ΌμΆ”κ°€ν•©λ‹ˆλ‹€.
ar << m_nCount;
for (int i = 0; i < m_nCount; i++)
{
ar << m_ptData[i];
}
}
else
{
// TODO: μ—¬κΈ°μ—λ‘œλ”©μ½”λ“œλ₯ΌμΆ”κ°€ν•©λ‹ˆλ‹€.
ar >> m_nCount;
for (int i = 0; i < m_nCount; i++)
{
ar >> m_ptData[i];
}
}
}