-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ported lab03/samples_old -> lab02/image_processing #19
Open
8migrannik
wants to merge
2
commits into
alexey-malov:master
Choose a base branch
from
8migrannik:ported_labs_03
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
labs/05/samples_win_32/sample01_blur_filter_wtl/AboutDlg.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// aboutdlg.cpp : implementation of the CAboutDlg class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "stdafx.h" | ||
#include "resource.h" | ||
|
||
#include "aboutdlg.h" | ||
|
||
LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
{ | ||
CenterWindow(GetParent()); | ||
return TRUE; | ||
} | ||
|
||
LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
{ | ||
EndDialog(wID); | ||
return 0; | ||
} |
25 changes: 25 additions & 0 deletions
25
labs/05/samples_win_32/sample01_blur_filter_wtl/AboutDlg.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// aboutdlg.h : interface of the CAboutDlg class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
|
||
class CAboutDlg : public CDialogImpl<CAboutDlg> | ||
{ | ||
public: | ||
enum { IDD = IDD_ABOUTBOX }; | ||
|
||
BEGIN_MSG_MAP(CAboutDlg) | ||
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) | ||
COMMAND_ID_HANDLER(IDOK, OnCloseCmd) | ||
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) | ||
END_MSG_MAP() | ||
|
||
// Handler prototypes (uncomment arguments if needed): | ||
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) | ||
|
||
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); | ||
LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); | ||
}; |
21 changes: 21 additions & 0 deletions
21
labs/05/samples_win_32/sample01_blur_filter_wtl/BlurFilter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "StdAfx.h" | ||
#include "BlurFilter.h" | ||
|
||
CBlurFilter::CBlurFilter(void) | ||
{ | ||
/* | ||
�������������� ���� ������� ��������� �������� 3*3 | ||
|1 3 1| | ||
1/20 * |3 4 3| | ||
|1 3 1| | ||
*/ | ||
static const float blurMatrix[3][3] = | ||
{ | ||
{1, 3, 1}, | ||
{3, 4, 3}, | ||
{1, 3, 1} | ||
}; | ||
InitializeMatrix(3, 3, &blurMatrix[0][0], 1.0f / 20); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
#include "matrixfilter.h" | ||
|
||
class CBlurFilter : public CMatrixFilter | ||
{ | ||
public: | ||
CBlurFilter(void); | ||
}; |
83 changes: 83 additions & 0 deletions
83
labs/05/samples_win_32/sample01_blur_filter_wtl/MainFrm.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// MainFrm.cpp : implmentation of the CMainFrame class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "stdafx.h" | ||
#include "resource.h" | ||
|
||
#include "aboutdlg.h" | ||
#include "MainView.h" | ||
#include "MainFrm.h" | ||
|
||
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) | ||
{ | ||
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg)) | ||
return TRUE; | ||
|
||
return m_view.PreTranslateMessage(pMsg); | ||
} | ||
|
||
BOOL CMainFrame::OnIdle() | ||
{ | ||
UIUpdateToolBar(); | ||
return FALSE; | ||
} | ||
|
||
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
{ | ||
CreateSimpleToolBar(); | ||
|
||
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); | ||
|
||
UIAddToolBar(m_hWndToolBar); | ||
UISetCheck(ID_VIEW_TOOLBAR, 1); | ||
|
||
// register object for message filtering and idle updates | ||
CMessageLoop* pLoop = _Module.GetMessageLoop(); | ||
ATLASSERT(pLoop != NULL); | ||
pLoop->AddMessageFilter(this); | ||
pLoop->AddIdleHandler(this); | ||
|
||
return 0; | ||
} | ||
|
||
LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) | ||
{ | ||
// unregister message filtering and idle updates | ||
CMessageLoop* pLoop = _Module.GetMessageLoop(); | ||
ATLASSERT(pLoop != NULL); | ||
pLoop->RemoveMessageFilter(this); | ||
pLoop->RemoveIdleHandler(this); | ||
|
||
bHandled = FALSE; | ||
return 1; | ||
} | ||
|
||
LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
{ | ||
PostMessage(WM_CLOSE); | ||
return 0; | ||
} | ||
|
||
LRESULT CMainFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
{ | ||
// TODO: add code to initialize document | ||
|
||
return 0; | ||
} | ||
|
||
LRESULT CMainFrame::OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
{ | ||
BOOL bVisible = !::IsWindowVisible(m_hWndToolBar); | ||
::ShowWindow(m_hWndToolBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE); | ||
UISetCheck(ID_VIEW_TOOLBAR, bVisible); | ||
UpdateLayout(); | ||
return 0; | ||
} | ||
|
||
LRESULT CMainFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
{ | ||
CAboutDlg dlg; | ||
dlg.DoModal(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// MainFrm.h : interface of the CMainFrame class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
|
||
class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>, | ||
public CMessageFilter, public CIdleHandler | ||
{ | ||
public: | ||
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME) | ||
|
||
CMainView m_view; | ||
|
||
virtual BOOL PreTranslateMessage(MSG* pMsg); | ||
virtual BOOL OnIdle(); | ||
|
||
BEGIN_UPDATE_UI_MAP(CMainFrame) | ||
UPDATE_ELEMENT(ID_VIEW_TOOLBAR, UPDUI_MENUPOPUP) | ||
END_UPDATE_UI_MAP() | ||
|
||
BEGIN_MSG_MAP(CMainFrame) | ||
MESSAGE_HANDLER(WM_CREATE, OnCreate) | ||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy) | ||
COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit) | ||
COMMAND_ID_HANDLER(ID_FILE_NEW, OnFileNew) | ||
COMMAND_ID_HANDLER(ID_VIEW_TOOLBAR, OnViewToolBar) | ||
COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout) | ||
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>) | ||
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>) | ||
END_MSG_MAP() | ||
|
||
// Handler prototypes (uncomment arguments if needed): | ||
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) | ||
|
||
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); | ||
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); | ||
LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); | ||
LRESULT OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); | ||
LRESULT OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); | ||
LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); | ||
}; |
49 changes: 49 additions & 0 deletions
49
labs/05/samples_win_32/sample01_blur_filter_wtl/MainView.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// sample01_blur_filter_wtlView.cpp : implementation of the CMainView class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "stdafx.h" | ||
#include "resource.h" | ||
|
||
#include "MainView.h" | ||
#include "BlurFilter.h" | ||
|
||
using namespace Gdiplus; | ||
|
||
CMainView::CMainView() | ||
{ | ||
Image img(L"car.jpg"); | ||
if (img.GetLastStatus() == Ok) | ||
{ | ||
m_pSrcPicture.reset(new Bitmap(img.GetWidth(), img.GetHeight(), img.GetPixelFormat())); | ||
|
||
Graphics g(m_pSrcPicture.get()); | ||
g.DrawImage(&img, 0, 0, img.GetWidth(), img.GetHeight()); | ||
|
||
CBlurFilter blur; | ||
|
||
m_pDstPicture = blur.ApplyFilter(*m_pSrcPicture.get()); | ||
} | ||
} | ||
|
||
BOOL CMainView::PreTranslateMessage(MSG* pMsg) | ||
{ | ||
pMsg; | ||
return FALSE; | ||
} | ||
|
||
LRESULT CMainView::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
{ | ||
CPaintDC dc(m_hWnd); | ||
|
||
// ���� �������� � ������������ ����������� ������, �� �������� �� ����� ���� � ������ | ||
if ((m_pSrcPicture.get() != NULL) && (m_pDstPicture.get() != NULL)) | ||
{ | ||
Graphics g(dc); | ||
g.DrawImage(m_pSrcPicture.get(), 0, 0, m_pSrcPicture->GetWidth(), m_pSrcPicture->GetHeight()); | ||
|
||
g.DrawImage(m_pDstPicture.get(), m_pSrcPicture->GetWidth(), 0, m_pDstPicture->GetWidth(), m_pDstPicture->GetHeight()); | ||
} | ||
|
||
return 0; | ||
} |
35 changes: 35 additions & 0 deletions
35
labs/05/samples_win_32/sample01_blur_filter_wtl/MainView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// sample01_blur_filter_wtlView.h : interface of the CMainView class | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
|
||
class CMainView : public CWindowImpl<CMainView> | ||
{ | ||
public: | ||
CMainView(); | ||
|
||
DECLARE_WND_CLASS(NULL) | ||
|
||
BOOL PreTranslateMessage(MSG* pMsg); | ||
|
||
BEGIN_MSG_MAP(CMainView) | ||
MESSAGE_HANDLER(WM_PAINT, OnPaint) | ||
END_MSG_MAP() | ||
|
||
// Handler prototypes (uncomment arguments if needed): | ||
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) | ||
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) | ||
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) | ||
|
||
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); | ||
private: | ||
// �������� ����������� | ||
std::auto_ptr<Gdiplus::Bitmap> m_pSrcPicture; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. auto_ptr был удалён в C++17. При переходе на новый стандарт C++ код не будет компилироваться. Нужно во всех местах заменить auto_ptr на unique_ptr |
||
|
||
// ������������ ����������� | ||
std::auto_ptr<Gdiplus::Bitmap> m_pDstPicture; | ||
|
||
|
||
|
||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Этот и другие файлы .h/.cpp следует сохранить в кодировке UTF-8 without BOM