home *** CD-ROM | disk | FTP | other *** search
- // mfcdevw.cpp : implementation of the CMfcdemoView class
- // Copyright (C) 1996 LEAD Technologies, Inc.
- // All rights reserved.
-
- #include "stdafx.h"
-
- #include "mfcdemo.h"
- #include "mfcdedoc.h"
- #include "mfcdevw.h"
- #include "mainfrm.h"
- #include "rangedlg.h"
- #include "listdlg.h"
- #include "dualrang.h"
- #include "resizedl.h"
- #include "floatdlg.h"
- #include "colorres.h"
- #include "underlay.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- extern CMfcdemoApp theApp;
-
- #define SZ_COMPASS _T("North|North-East|East|South-East|South|South-West|West|North-West|")
- #define SZ_SHIFTDIFF _T("Diagonal|Horizontal|Vertical|")
- #define SZ_LINESEG _T("Horizontal|Vertical|Left to Right|Right to Left|")
- #define SZ_LAPLACE _T("Filter 1|Filter 2|Filter 3|Diagonal|Horizontal|Vertical|")
- #define SZ_HORZVERT _T("Horizontal|Vertical|");
- #define SZ_BINARY _T("Omnidirectional|Horizontal|Vertical|Diagonal|")
-
- static int aGradientFlt[] = {
- CLead::FLT_GRADIENT_N,
- CLead::FLT_GRADIENT_NE,
- CLead::FLT_GRADIENT_E,
- CLead::FLT_GRADIENT_SE,
- CLead::FLT_GRADIENT_S,
- CLead::FLT_GRADIENT_SW,
- CLead::FLT_GRADIENT_W,
- CLead::FLT_GRADIENT_NW
- };
-
- static int aLaplaceFlt[] = {
- CLead::FLT_LAPLACE_1,
- CLead::FLT_LAPLACE_2,
- CLead::FLT_LAPLACE_3,
- CLead::FLT_LAPLACE_DIAG,
- CLead::FLT_LAPLACE_HORZ,
- CLead::FLT_LAPLACE_VERT,
- };
-
- static int aSobelFlt[] = {
- CLead::FLT_SOBEL_HORZ,
- CLead::FLT_SOBEL_VERT,
- };
-
-
- static int aPrewittFlt[] = {
- CLead::FLT_PREWITT_HORZ,
- CLead::FLT_PREWITT_VERT,
- };
-
- static int aShiftDiffFlt[] = {
- CLead::FLT_SHIFTDIFF_DIAG,
- CLead::FLT_SHIFTDIFF_HORZ,
- CLead::FLT_SHIFTDIFF_VERT,
- };
-
- static int aLineSegFlt[] = {
- CLead::FLT_LINESEG_HORZ,
- CLead::FLT_LINESEG_VERT,
- CLead::FLT_LINESEG_LTOR,
- CLead::FLT_LINESEG_RTOL,
- };
-
- static int aErosionFlt[] = {
- CLead::BFLT_EROSION_OMNI,
- CLead::BFLT_EROSION_HORZ,
- CLead::BFLT_EROSION_VERT,
- CLead::BFLT_EROSION_DIAG,
- };
-
- static int aDilationFlt[] = {
- CLead::BFLT_DILATION_OMNI,
- CLead::BFLT_DILATION_HORZ,
- CLead::BFLT_DILATION_VERT,
- CLead::BFLT_DILATION_DIAG,
- };
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView
-
- IMPLEMENT_DYNCREATE(CMfcdemoView, CView)
-
- BEGIN_MESSAGE_MAP(CMfcdemoView, CView)
- //{{AFX_MSG_MAP(CMfcdemoView)
- ON_MESSAGE(WM_DOREALIZE, OnDoRealize)
- ON_COMMAND(ID_IMAGE_FLIP, OnImageFlip)
- ON_COMMAND(ID_IMAGE_REVERSE, OnImageReverse)
- ON_COMMAND(ID_IMAGE_ROTATE_180CLOCKWISE, OnImageRotate180clockwise)
- ON_COMMAND(ID_IMAGE_ROTATE_270CLOCKWISE, OnImageRotate270clockwise)
- ON_COMMAND(ID_IMAGE_ROTATE_90CLOCKWISE, OnImageRotate90clockwise)
- ON_COMMAND(ID_COLOR_GRAYSCALE, OnColorGrayscale)
- ON_COMMAND(ID_COLOR_HISTOGRAMEQUALIZE, OnColorHistogramequalize)
- ON_COMMAND(ID_COLOR_INVERT, OnColorInvert)
- ON_COMMAND(ID_COLOR_STRETCHINTENSITY, OnColorStretchintensity)
- ON_COMMAND(ID_IMAGE_EFFECTS_POSTERIZE, OnImageEffectsPosterize)
- ON_COMMAND(ID_COLOR_BRIGHTNESS, OnColorBrightness)
- ON_COMMAND(ID_COLOR_CONTRAST, OnColorContrast)
- ON_COMMAND(ID_COLOR_HISTOCONTRAST, OnColorHistocontrast)
- ON_COMMAND(ID_COLOR_HUE, OnColorHue)
- ON_COMMAND(ID_COLOR_SATURATION, OnColorSaturation)
- ON_COMMAND(ID_IMAGE_EFFECTS_ADDNOISE, OnImageEffectsAddnoise)
- ON_COMMAND(ID_IMAGE_EFFECTS_AVERAGE, OnImageEffectsAverage)
- ON_COMMAND(ID_IMAGE_EFFECTS_DESPECKLE, OnImageEffectsDespeckle)
- ON_COMMAND(ID_IMAGE_EFFECTS_MEDIAN, OnImageEffectsMedian)
- ON_COMMAND(ID_IMAGE_EFFECTS_MOSAIC, OnImageEffectsMosaic)
- ON_COMMAND(ID_IMAGE_EFFECTS_SHARPEN, OnImageEffectsSharpen)
- ON_COMMAND(ID_IMAGE_BINARYFILTERS_DILATION, OnImageBinaryfiltersDilation)
- ON_COMMAND(ID_IMAGE_BINARYFILTERS_EROSION, OnImageBinaryfiltersErosion)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_GRADIENT, OnImageSpatialfiltersGradient)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_LAPLACIAN, OnImageSpatialfiltersLaplacian)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_LINESEGMENT, OnImageSpatialfiltersLinesegment)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_PREWITT, OnImageSpatialfiltersPrewitt)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_SHIFTANDDIFFERENCE, OnImageSpatialfiltersShiftanddifference)
- ON_COMMAND(ID_IMAGE_SPATIALFILTERS_SOBEL, OnImageSpatialfiltersSobel)
- ON_COMMAND(ID_COLOR_GAMMACORRECT, OnColorGammacorrect)
- ON_COMMAND(ID_COLOR_INTENSITYDETECT, OnColorIntensitydetect)
- ON_COMMAND(ID_IMAGE_RESIZE, OnImageResize)
- ON_COMMAND(ID_IMAGE_ROTATE_ANYANGLE, OnImageRotateAnyangle)
- ON_COMMAND(ID_IMAGE_SHEAR, OnImageShear)
- ON_COMMAND(ID_COLOR_COLORRESOLUTION, OnColorColorresolution)
- ON_COMMAND(ID_VIEW_ZOOM, OnViewZoom)
- ON_COMMAND(ID_VIEW_NORMAL, OnViewNormal)
- ON_COMMAND(ID_VIEW_PAINTEFFECTS, OnViewPainteffects)
- ON_COMMAND(ID_VIEW_SNAPWINDOWTOIMAGE, OnViewSnapwindowtoimage)
- ON_COMMAND(ID_VIEW_FITIMAGETOWINDOW, OnViewFitimagetowindow)
- ON_WM_ERASEBKGND()
- ON_COMMAND(ID_IMAGE_EFFECTS_EMBOSS, OnImageEffectsEmboss)
- ON_COMMAND(ID_COLOR_HALFTONE, OnColorHalftone)
- ON_COMMAND(ID_COLOR_FILL, OnColorFill)
- ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
- ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
- ON_COMMAND(ID_COLOR_SEPARATION, OnColorSeparation)
- ON_COMMAND(ID_IMAGE_EFFECTS_EDGEENHANCE, OnImageEffectsEdgeenhance)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_EFFECTS_EDGEENHANCE, OnUpdateImageEffectsEdgeenhance)
- ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
- ON_COMMAND(ID_IMAGE_DESKEW, OnImageDeskew)
- ON_COMMAND(ID_IMAGE_EFFECTS_UNDERLAY, OnImageEffectsUnderlay)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_DESKEW, OnUpdateImageDeskew)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_BINARYFILTERS_DILATION, OnUpdateImageBinaryfiltersDilation)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_BINARYFILTERS_EROSION, OnUpdateImageBinaryfiltersErosion)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_EFFECTS_DESPECKLE, OnUpdateImageEffectsDespeckle)
- ON_COMMAND(IDM_TOOLNONE, OnToolnone)
- ON_UPDATE_COMMAND_UI(IDM_TOOLNONE, OnUpdateToolnone)
- ON_COMMAND(IDM_TOOLELLIPSE, OnToolellipse)
- ON_UPDATE_COMMAND_UI(IDM_TOOLELLIPSE, OnUpdateToolellipse)
- ON_COMMAND(IDM_TOOLFREEHAND, OnToolfreehand)
- ON_UPDATE_COMMAND_UI(IDM_TOOLFREEHAND, OnUpdateToolfreehand)
- ON_COMMAND(IDM_TOOLRECT, OnToolrect)
- ON_UPDATE_COMMAND_UI(IDM_TOOLRECT, OnUpdateToolrect)
- ON_COMMAND(IDM_TOOLRNDRECT, OnToolrndrect)
- ON_UPDATE_COMMAND_UI(IDM_TOOLRNDRECT, OnUpdateToolrndrect)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_REGIONTRANSFORMATIONS_CANCEL, OnUpdateImageRegiontransformationsCancel)
- ON_COMMAND(ID_IMAGE_REGIONTRANSFORMATIONS_CANCEL, OnImageRegiontransformationsCancel)
- ON_UPDATE_COMMAND_UI(ID_IMAGE_SHEAR, OnUpdateImageShear)
- ON_WM_SIZE()
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView construction/destruction
-
- CMfcdemoView::CMfcdemoView()
- {
- m_pPalette = NULL;
- m_nEffect = CLead::EFX_EFFECT_NONE;
- m_nRegionTool = IDM_TOOLNONE;
- m_nRegionType = 0;
-
- m_bMovingFloater = FALSE;
- }
-
- CMfcdemoView::~CMfcdemoView()
- {
- if(m_pPalette)
- delete m_pPalette;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView drawing
-
- void CMfcdemoView::OnDraw(CDC* pDC)
- {
- CRect rcClip;
- CSize winext;
- CSize viewext;
- CSize paintext;
-
- CMfcdemoDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- if(pDC->IsPrinting())
- {
- pDC->SaveDC();
- ::GetWindowExtEx(pDC->m_hDC, &winext);
- ::GetViewportExtEx(pDC->m_hDC, &viewext);
- paintext.cx = MulDiv((int) m_Lead.GetBitmapWidth(), viewext.cx, winext.cx);
- paintext.cy = MulDiv((int) m_Lead.GetBitmapHeight(), viewext.cy, winext.cy);
- ::SetMapMode(pDC->m_hDC, MM_TEXT);
- m_Lead.Render((OLE_HANDLE) pDC->m_hDC, (float) 0, (float) 0, (float) paintext.cx, (float) paintext.cy);
- pDC->RestoreDC(-1);
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView printing
-
- BOOL CMfcdemoView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
-
- void CMfcdemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
-
- void CMfcdemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView diagnostics
-
- #ifdef _DEBUG
- void CMfcdemoView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMfcdemoView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMfcdemoDoc* CMfcdemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMfcdemoDoc)));
- return (CMfcdemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMfcdemoView message handlers
-
- void CMfcdemoView::BeginProcessing()
- {
- BeginWaitCursor();
- GetUndoLead()->SetBitmap(GetDocLead()->GetBitmap());
- }
-
- void CMfcdemoView::EndProcessing(int nRet)
- {
- EndWaitCursor();
- theApp.DisplayLEADError(nRet);
- }
-
- void CMfcdemoView::OnChanged()
- {
- CMfcdemoDoc* pDoc = GetDocument();
-
- pDoc->SetModifiedFlag();
- pDoc->UpdateAllViews(NULL, (LPARAM) 0);
- }
-
- void CMfcdemoView::SetZoom(float nZoom)
- {
- CMfcdemoDoc* pDoc = GetDocument();
- m_nZoom = nZoom;
- OnUpdate(NULL, 0, NULL);
- }
-
- CLead* CMfcdemoView::GetDocLead()
- {
- CMfcdemoDoc* pDoc = GetDocument();
- return(&pDoc->m_Lead);
- }
-
- CLead* CMfcdemoView::GetUndoLead()
- {
- CMfcdemoDoc* pDoc = GetDocument();
- return(&pDoc->m_LeadUndo);
- }
-
- void CMfcdemoView::OnInitialUpdate()
- {
- CMfcdemoDoc* pDoc = GetDocument();
- SetZoom(100.0f);
- CView::OnInitialUpdate();
- }
-
- LRESULT CMfcdemoView::OnDoRealize(WPARAM wParam, LPARAM lParam)
- {
- if(lParam)
- {
- return m_Lead.SendMessage(WM_PALETTECHANGED, wParam);
- }
- else
- {
- UINT nColorsChanged = 0;
- CDC* pdc;
-
- pdc = theApp.m_pMainWnd->GetDC();
- HPALETTE hpal = (HPALETTE)m_Lead.GetPalette((OLE_HANDLE) pdc->m_hDC);
- if(hpal)
- {
- CPalette pal;
-
- pal.Attach(hpal);
- CPalette* oldPalette = pdc->SelectPalette(&pal, (BOOL) lParam);
- nColorsChanged = pdc->RealizePalette();
- if (nColorsChanged > 0)
- m_Lead.InvalidateRect(NULL, FALSE);
- pdc->SelectPalette(oldPalette, TRUE);
- }
- theApp.m_pMainWnd->ReleaseDC(pdc);
- return ((LRESULT) (BOOL) (nColorsChanged > 0));
- }
- }
-
- void CMfcdemoView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
- {
- CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
- if (bActivate)
- {
- ASSERT(pActivateView == this);
- OnDoRealize((WPARAM)theApp.m_pMainWnd->m_hWnd, (LPARAM) FALSE); // same as SendMessage(WM_DOREALIZE);
- }
- }
-
- void CMfcdemoView::OnImageFlip()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsFlip();
- }
- else
- {
- BeginProcessing();
- int nRet = GetDocLead()->Flip();
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageReverse()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsReverse();
- }
- else
- {
- BeginProcessing();
- int nRet = GetDocLead()->Reverse();
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageRotate180clockwise()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsRotate((long) 18000);
- }
- else
- {
- BeginProcessing();
- int nRet = GetDocLead()->Rotate(18000, TRUE, RGB(0, 0, 0));
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageRotate270clockwise()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsRotate((long) 27000);
- }
- else
- {
- BeginProcessing();
- int nRet = GetDocLead()->Rotate(27000, TRUE, RGB(0, 0, 0));
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageRotate90clockwise()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsRotate((long) 9000);
- }
- else
- {
- BeginProcessing();
- int nRet = GetDocLead()->Rotate(9000, TRUE, RGB(0, 0, 0));
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
-
- void CMfcdemoView::OnColorGrayscale()
- {
- BeginProcessing();
- int nRet = GetDocLead()->Grayscale(8);
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnColorHistogramequalize()
- {
- BeginProcessing();
- int nRet = GetDocLead()->HistoEqualize();
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnColorInvert()
- {
- BeginProcessing();
- int nRet = GetDocLead()->Invert();
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnColorStretchintensity()
- {
- BeginProcessing();
- int nRet = GetDocLead()->StretchIntensity();
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnImageEffectsPosterize()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Posterize");
- dlg.m_strLabel = _T("&Levels");
- dlg.m_nValue = 2;
- dlg.m_nMin = 2;
- dlg.m_nMax = 64;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Posterize(dlg.m_nValue);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnColorBrightness()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Brightness");
- dlg.m_strLabel = _T("&Change");
- dlg.m_nMin = -100;
- dlg.m_nMax = 100;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Intensity(dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnColorContrast()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Contrast");
- dlg.m_strLabel = _T("&Change");
- dlg.m_nMin = -100;
- dlg.m_nMax = 100;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Contrast(dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
-
- void CMfcdemoView::OnColorHistocontrast()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Histo-Contrast");
- dlg.m_strLabel = _T("&Change");
- dlg.m_nMin = -100;
- dlg.m_nMax = 100;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->HistoContrast(dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnColorHue()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Hue");
- dlg.m_strLabel = _T("&Angle");
- dlg.m_nMin = -359;
- dlg.m_nMax = 359;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Hue(dlg.m_nValue);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnColorSaturation()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Saturation");
- dlg.m_strLabel = _T("&Change");
- dlg.m_nMin = -100;
- dlg.m_nMax = 100;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Saturation(dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnImageEffectsAddnoise()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Add Noise");
- dlg.m_strLabel = _T("&Level");
- dlg.m_fShowCombo = TRUE;
- dlg.m_strComboLabel = _T("&Channel");
- dlg.m_strComboInit = _T("Master|Red|Green|Blue|");
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->AddNoise(dlg.m_nValue * 10, dlg.m_nComboValue);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageEffectsAverage()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Average");
- dlg.m_strLabel = _T("&Size");
- dlg.m_nValue = 3;
- dlg.m_nMin = 3;
- dlg.m_nMax = 11;
- dlg.m_nPage = 2;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Average(dlg.m_nValue);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageEffectsDespeckle()
- {
- BeginProcessing();
- int nRet = GetDocLead()->Despeckle();
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnImageEffectsMedian()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Median");
- dlg.m_strLabel = _T("&Size");
- dlg.m_nValue = 3;
- dlg.m_nMin = 3;
- dlg.m_nMax = 11;
- dlg.m_nPage = 2;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Median(dlg.m_nValue);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageEffectsMosaic()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Mosaic");
- dlg.m_strLabel = _T("&Size");
- dlg.m_nValue = 2;
- dlg.m_nMin = 2;
- dlg.m_nMax = 64;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Mosaic(dlg.m_nValue);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnImageEffectsSharpen()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Sharpen");
- dlg.m_strLabel = _T("&Change");
- dlg.m_nMin = -100;
- dlg.m_nMax = 100;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Sharpen(dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnImageBinaryfiltersDilation()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Dilation");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_BINARY;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->BinaryFilter(aDilationFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageBinaryfiltersErosion()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Erosion");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_BINARY;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->BinaryFilter(aErosionFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersGradient()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Gradient");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_COMPASS;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aGradientFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersLaplacian()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Laplacian");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_LAPLACE;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aLaplaceFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersLinesegment()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Line Segment");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_LINESEG;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aLineSegFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersPrewitt()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Prewitt");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_HORZVERT;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aPrewittFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersShiftanddifference()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Shift and Difference");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_SHIFTDIFF;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aShiftDiffFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageSpatialfiltersSobel()
- {
- CListDlg dlg;
-
- dlg.m_strTitle = _T("Sobel");
- dlg.m_strLabel = _T("&Filter Type");
- dlg.m_strInit = SZ_HORZVERT;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->SpatialFilter(aSobelFlt[dlg.m_nValue]);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnColorGammacorrect()
- {
- CFloatDlg dlg;
-
- dlg.m_strTitle = _T("Gamma Correct");
- dlg.m_strLabel = _T("&Value");
- dlg.m_fltValue = 1.0f;
- dlg.m_fltMin = .01f;
- dlg.m_fltMax = 4.99f;
- dlg.m_fltStep = .01f;
- dlg.m_fltPage = .10f;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->GammaCorrect((int) (dlg.m_fltValue * 100));
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
-
- void CMfcdemoView::OnImageResize()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsResize();
- }
- else
- {
- CResizeDlg dlg;
-
- dlg.m_nWidth = (int) GetDocLead()->GetBitmapWidth();
- dlg.m_nHeight = (int) GetDocLead()->GetBitmapHeight();
- if(dlg.DoModal() == IDOK)
- {
- int nRet;
-
- BeginProcessing();
- if(dlg.m_fResample)
- nRet = GetDocLead()->Size((float) dlg.m_nWidth, (float) dlg.m_nHeight, CLead::RESIZE_RESAMPLE);
- else
- nRet = GetDocLead()->Size((float) dlg.m_nWidth, (float) dlg.m_nHeight, CLead::RESIZE_NORMAL);
- OnChanged();
- EndProcessing(nRet);
- }
- }
- }
-
- void CMfcdemoView::OnImageRotateAnyangle()
- {
- if(m_Lead.GetHasRgn())
- {
- OnImageRegiontransformationsRotate();
- }
- else
- {
- CFloatDlg dlg;
-
- dlg.m_strTitle = _T("Rotate");
- dlg.m_strLabel = _T("&Angle");
- dlg.m_strCheck = _T("&Resize");
- dlg.m_fCheck = TRUE;
- dlg.m_fShowCheck = TRUE;
- dlg.m_fltMin = -360.0f;
- dlg.m_fltMax = 360.0f;
- dlg.m_fltScale = 10.0f;
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Rotate((long) (dlg.m_fltValue * 100), dlg.m_fCheck, RGB(255, 255, 255));
- OnChanged();
- EndProcessing(nRet);
- }
- }
- }
-
- void CMfcdemoView::OnImageShear()
- {
- CFloatDlg dlg;
-
- dlg.m_strTitle = _T("Shear");
- dlg.m_strLabel = _T("&Angle");
- dlg.m_strCheck = _T("&Horizontal");
- dlg.m_fCheck = TRUE;
- dlg.m_fShowCheck = TRUE;
- dlg.m_fltMin = (float) -45.0;
- dlg.m_fltMax = (float) 45.0;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Shear((int) (dlg.m_fltValue * 100), dlg.m_fCheck, RGB(255, 255, 255));
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnColorColorresolution()
- {
- CColorResDlg dlg;
-
- dlg.m_nBitsPerPixel = GetDocLead()->GetBitmapBits();
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->ColorRes(dlg.m_nBitsPerPixel,
- dlg.m_nPalette, dlg.m_nDither, 0);
- OnChanged();
- EndProcessing(nRet);
- }
- }
- void CMfcdemoView::OnColorIntensitydetect()
- {
- CDualRangeDlg dlg;
-
- dlg.m_strTitle = _T("Intensity Detect");
- dlg.m_strLabel1 = _T("&Min");
- dlg.m_strLabel2 = _T("&Max");
- dlg.m_nValue1 = 0;
- dlg.m_nValue2 = 255;
- dlg.m_nMin = 0;
- dlg.m_nMax = 255;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->IntensityDetect(dlg.m_nValue1, dlg.m_nValue2);
- OnChanged();
- EndProcessing(nRet);
- }
- }
- void CMfcdemoView::OnViewZoom()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Zoom");
- dlg.m_strLabel = _T("&Amount");
- dlg.m_nValue = (int)m_nZoom;
- dlg.m_nMin = 1;
- dlg.m_nMax = 800;
- dlg.m_nPage = 100;
-
- if(dlg.DoModal() == IDOK)
- {
- SetZoom((float)dlg.m_nValue);
- }
- }
-
- void CMfcdemoView::OnViewNormal()
- {
- SetZoom(100.0f);
- }
-
- static int nEffectIndex[] =
- {
- CLead::EFX_EFFECT_WIPE_CLASS, CLead::EFX_EFFECT_WIPE_MAX,
- CLead::EFX_EFFECT_WIPE_RECTANGLE_CLASS, CLead::EFX_EFFECT_WIPE_RECTANGLE_MAX,
- CLead::EFX_EFFECT_WIPE_CIRCLE_CLASS, CLead::EFX_EFFECT_WIPE_CIRCLE_MAX,
- CLead::EFX_EFFECT_PUSH_CLASS, CLead::EFX_EFFECT_PUSH_MAX,
- CLead::EFX_EFFECT_SLIDE_CLASS, CLead::EFX_EFFECT_SLIDE_MAX,
- CLead::EFX_EFFECT_ROLL_CLASS, CLead::EFX_EFFECT_ROLL_MAX,
- CLead::EFX_EFFECT_ROTATE_CLASS, CLead::EFX_EFFECT_ROTATE_MAX,
- CLead::EFX_EFFECT_ZOOM_CLASS, CLead::EFX_EFFECT_ZOOM_MAX,
- CLead::EFX_EFFECT_DRIP_CLASS, CLead::EFX_EFFECT_DRIP_MAX,
- CLead::EFX_EFFECT_BLIND_CLASS, CLead::EFX_EFFECT_BLIND_MAX,
- CLead::EFX_EFFECT_RANDOM_CLASS, CLead::EFX_EFFECT_RANDOM_MAX,
- CLead::EFX_EFFECT_CHECKERBOARD_CLASS, CLead::EFX_EFFECT_CHECKERBOARD_MAX,
- CLead::EFX_EFFECT_BLOCKS_CLASS, CLead::EFX_EFFECT_BLOCKS_MAX,
- CLead::EFX_EFFECT_CIRCLE_CLASS, CLead::EFX_EFFECT_CIRCLE_MAX,
- CLead::EFX_EFFECT_ELLIPSE_CLASS, CLead::EFX_EFFECT_ELLIPSE_MAX,
- };
-
- void CMfcdemoView::OnViewPainteffects()
- {
- CClientDC cdc(this);
- DWORD dw;
- BOOL bOLDErase;
- int i;
-
- BeginWaitCursor();
- bOLDErase=m_Lead.GetBackErase();
- m_Lead.SetBackErase(TRUE);
- for (i = 0; i < sizeof(nEffectIndex) / sizeof(nEffectIndex[0]); i += 2)
- {
- for (m_nEffect = nEffectIndex[i]; m_nEffect <= nEffectIndex[i+1]; m_nEffect++)
- {
- m_Lead.SetPaintEffect(m_nEffect);
- dw = GetTickCount ();
- while ((GetTickCount () - dw) < 1000);
- }
- }
- m_Lead.SetBackErase(bOLDErase);
- m_nEffect = CLead::EFX_EFFECT_NONE;
- m_Lead.SetPaintEffect(m_nEffect);
- EndWaitCursor();
- }
-
- void CMfcdemoView::OnViewSnapwindowtoimage()
- {
- CWnd* pFrame = GetParent();
- CRect rcWindow;
- CRect rcClient;
-
- pFrame->ShowWindow(SW_NORMAL);
- GetClientRect(&rcClient);
- pFrame->GetWindowRect(&rcWindow);
-
- pFrame->GetParent()->ScreenToClient (rcWindow);
-
- pFrame->MoveWindow (rcWindow.left, rcWindow.top,
- rcWindow.Width() + (int) m_Lead.GetDstWidth() - rcClient.Width(),
- rcWindow.Height() + (int) m_Lead.GetDstHeight() - rcClient.Height());
-
- }
-
- void CMfcdemoView::OnViewFitimagetowindow()
- {
- float cxZoom, cyZoom;
- cxZoom = m_Lead.GetScaleWidth() * 100.0f / m_Lead.GetBitmapWidth();
- cyZoom = m_Lead.GetScaleHeight() * 100.0f / m_Lead.GetBitmapHeight();
- SetZoom(max(min(cxZoom, cyZoom), 1));
- }
-
- BOOL CMfcdemoView::OnEraseBkgnd(CDC* pDC)
- {
- // return CView::OnEraseBkgnd(pDC);
- return TRUE;
- }
-
- void CMfcdemoView::OnImageEffectsEmboss()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Emboss");
- dlg.m_strLabel = _T("&Level");
- dlg.m_nValue = 50;
- dlg.m_fShowCombo = TRUE;
- dlg.m_strComboLabel = _T("&Direction");
- dlg.m_strComboInit = SZ_COMPASS;
-
- if(dlg.DoModal() == IDOK && dlg.m_nValue)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Emboss(dlg.m_nComboValue, dlg.m_nValue * 10);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnColorHalftone()
- {
- CRangeDlg dlg;
-
- dlg.m_strTitle = _T("Halftone");
- dlg.m_strLabel = _T("&Angle");
- dlg.m_nMin = -359;
- dlg.m_nMax = 359;
- dlg.m_fShowCombo = TRUE;
- dlg.m_strComboLabel = _T("&Type");
- dlg.m_strComboInit = _T("Print|View|");
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Halftone(dlg.m_nComboValue, (LONG) dlg.m_nValue * 100);
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnColorFill()
- {
- CColorDialog dlg;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Fill(dlg.GetColor());
- OnChanged();
- EndProcessing(nRet);
- }
-
- }
-
- void CMfcdemoView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
- {
- CMfcdemoDoc* pDoc = GetDocument();
- OLE_HANDLE hRegion;
-
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetPaintPalette(theApp.m_fAutoPalette ? CLead::PAINTPALETTE_AUTO : CLead::PAINTPALETTE_FIXED);
- m_Lead.SetPaintDither(theApp.m_fOrderedDither ? CLead::PAINTDITHER_ORDERED : CLead::PAINTDITHER_DIFFUSION);
- m_Lead.SetBitonalScaling(theApp.m_nBitonalScaling);
- m_Lead.SetPaintZoomFactor(m_nZoom);
- if( GetDocLead()->GetBitmapListCount() > 1 )
- m_Lead.SetBitmapList(GetDocLead()->GetBitmapList());
- else
- m_Lead.SetBitmap(GetDocLead()->GetBitmap());
- /* copy the region from the document control */
- if( GetDocLead()->GetHasRgn() )
- {
- hRegion = GetDocLead()->GetRgnHandle();
- m_Lead.SetRgnHandle(hRegion,0.0f,0.0f,CLead::L_RGN_SET);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead.DeleteRgnHandle(hRegion);
- }
- else
- {
- if( !m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS) )
- {
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- m_Lead.FreeRgn();
- }
- }
- if( m_Lead.GetBitmapListCount() > 1 )
- {
- m_Lead.SetAnimationWidth(GetDocLead()->GetAnimationWidth());
- m_Lead.SetAnimationHeight(GetDocLead()->GetAnimationHeight());
- m_Lead.SetAnimationBitsPerPixel(GetDocLead()->GetAnimationBitsPerPixel());
- m_Lead.SetAnimationBackColor(GetDocLead()->GetAnimationBackColor());
- m_Lead.SetAnimationLoop(GetDocLead()->GetAnimationLoop());
- for(int i = 0; i < (1 << m_Lead.GetAnimationBitsPerPixel() ); i++)
- {
-
- m_Lead.SetAnimationPalette(i, GetDocLead()->GetAnimationPalette(i));
- }
- m_Lead.SetAnimationEnable(TRUE);
- }
- m_Lead.SetAutoRepaint(TRUE);
- }
-
- void CMfcdemoView::OnEditUndo()
- {
- BeginWaitCursor();
- GetDocLead()->SetBitmap(GetUndoLead()->GetBitmap());
- GetUndoLead()->SetBitmap(0);
- OnChanged();
- EndWaitCursor();
- }
-
- void CMfcdemoView::OnUpdateEditUndo(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(GetUndoLead()->GetBitmap() != 0);
- }
-
- void CMfcdemoView::OnEditCopy()
- {
- BeginWaitCursor();
- GetDocLead()->Copy(CLead::COPY_DIB | CLead::COPY_DDB | CLead::COPY_PALETTE);
- EndWaitCursor();
- }
-
- void CMfcdemoView::OnColorSeparation()
- {
- CListDlg dlg;
- int i, nPlanes;
-
- dlg.m_strTitle = _T("Separation");
- dlg.m_strLabel = _T("&Color Space");
- dlg.m_strInit = _T("RGB|CMYK|HSV|HLS|CMY|");
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->ColorSeparate(dlg.m_nValue);
- if(!nRet)
- {
- nPlanes = (dlg.m_nValue == CLead::COLORSEP_CMYK) ? 4 : 3;
- for(i = 0; i < nPlanes; i++)
- {
- theApp.m_Bitmap = GetDocLead()->GetColorPlanes(i);
- theApp.OpenDocument(OPENMODE_BITMAP);
- GetDocLead()->SetColorPlanes(i, 0);
- }
- }
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnImageEffectsEdgeenhance()
- {
- BeginProcessing();
-
- int nRet = m_Lead.SpatialFilter(CLead::FLT_LAPLACE_1);
- if(!nRet)
- {
- nRet = GetDocLead()->Combine(0.0f, 0.0f, m_Lead.GetBitmapWidth(), m_Lead.GetBitmapHeight(),
- m_Lead.GetBitmap(), 0.0f, 0.0f, CLead::CB_OP_ADD);
- }
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnUpdateImageEffectsEdgeenhance(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(GetDocLead()->GetBitmapBits() > 8);
- }
-
-
- void CMfcdemoView::OnImageDeskew()
- {
- BeginProcessing();
- int nRet = GetDocLead()->Deskew();
- OnChanged();
- EndProcessing(nRet);
- }
-
- void CMfcdemoView::OnImageEffectsUnderlay()
- {
- CUnderLayDlg dlg;
-
- if(dlg.DoModal() == IDOK)
- {
- BeginProcessing();
- int nRet = GetDocLead()->Underlay(((CMfcdemoDoc*)dlg.m_pDocument)->m_Lead.GetBitmap(), dlg.m_fTile ? CLead::UNDERLAY_TILE : CLead::UNDERLAY_STRETCH);
- OnChanged();
- EndProcessing(nRet);
- }
- }
-
- void CMfcdemoView::OnUpdateImageDeskew(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable((GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_EXP||GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_MEDICAL)
- && !m_Lead.GetHasRgn());
- }
-
- void CMfcdemoView::OnUpdateImageShear(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!m_Lead.GetHasRgn());
- }
-
- void CMfcdemoView::OnUpdateImageBinaryfiltersDilation(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_EXP||GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_MEDICAL);
- }
-
- void CMfcdemoView::OnUpdateImageBinaryfiltersErosion(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_EXP||GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_MEDICAL);
- }
-
- void CMfcdemoView::OnUpdateImageEffectsDespeckle(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_EXP||GetDocLead()->GetVersionLevel() == CLead::VERSIONLEVEL_MEDICAL);
- }
-
- void CMfcdemoView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
-
- m_Lead.MoveControl(CRect( 0, 0, cx, cy));
-
- }
-
- int CMfcdemoView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- CRect rcClient;
- GetClientRect(rcClient);
- m_Lead.CreateInstance(&m_LeadContainer, this, rcClient);
- INIT_LEAD_MAPS(m_Lead);
- UNLOCKSUPPORT(m_Lead);
-
- m_Lead3.CreateInstance(&m_LeadContainer, this, rcClient);
- m_Lead3.ShowWindow(SW_HIDE);
- m_Lead3.SetAutoRepaint(FALSE);
-
- return 0;
- }
-
- void CMfcdemoView::OnToolnone()
- {
- SetRegionTool( IDM_TOOLNONE );
- }
-
- void CMfcdemoView::OnUpdateToolnone(CCmdUI* pCmdUI)
- {
- // pCmdUI->Enable(!m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS));
- pCmdUI->SetCheck(m_nRegionTool == IDM_TOOLNONE);
- }
-
- void CMfcdemoView::OnToolellipse()
- {
- SetRegionTool( IDM_TOOLELLIPSE );
- }
-
- void CMfcdemoView::OnUpdateToolellipse(CCmdUI* pCmdUI)
- {
- // pCmdUI->Enable(!m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS));
- pCmdUI->SetCheck(m_nRegionTool == IDM_TOOLELLIPSE);
- }
-
- void CMfcdemoView::OnToolfreehand()
- {
- SetRegionTool( IDM_TOOLFREEHAND );
- }
-
- void CMfcdemoView::OnUpdateToolfreehand(CCmdUI* pCmdUI)
- {
- // pCmdUI->Enable(!m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS));
- pCmdUI->SetCheck(m_nRegionTool == IDM_TOOLFREEHAND);
- }
-
- void CMfcdemoView::OnToolrect()
- {
- SetRegionTool( IDM_TOOLRECT );
- }
-
- void CMfcdemoView::OnUpdateToolrect(CCmdUI* pCmdUI)
- {
- // pCmdUI->Enable(!m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS));
- pCmdUI->SetCheck(m_nRegionTool == IDM_TOOLRECT);
- }
-
- void CMfcdemoView::OnToolrndrect()
- {
- SetRegionTool( IDM_TOOLRNDRECT );
- }
-
- void CMfcdemoView::OnUpdateToolrndrect(CCmdUI* pCmdUI)
- {
- // pCmdUI->Enable(!m_Lead.IsSupportLocked(CLead::L_SUPPORT_EXPRESS));
- pCmdUI->SetCheck(m_nRegionTool == IDM_TOOLRNDRECT);
- }
-
- void CMfcdemoView::SetRegionTool( int nNewRegionTool )
- {
- m_nRegionTool = nNewRegionTool;
- }
-
- BEGIN_LEAD_DISPATCH_MAP(CMfcdemoView, m_Lead)
- // Place the functions handling Lead control messages here
- DISP_FUNCTION_ID(CMfcdemoView, "MouseDown", 0xFFFFFDA3, OnMouseDownLeadctrl1, VT_EMPTY, VTS_I2 VTS_I2 VTS_I4 VTS_I4 )
- DISP_FUNCTION_ID(CMfcdemoView, "MouseMove", 0xFFFFFDA2, OnMouseMoveLeadctrl1, VT_EMPTY, VTS_I2 VTS_I2 VTS_I4 VTS_I4 )
- DISP_FUNCTION_ID(CMfcdemoView, "MouseUp", 0xFFFFFDA1, OnMouseUpLeadctrl1, VT_EMPTY, VTS_I2 VTS_I2 VTS_I4 VTS_I4 )
- DISP_FUNCTION_ID(CMfcdemoView, "RgnChange", 0x00000007, OnRgnChangeLeadctrl1, VT_EMPTY, VTS_NONE )
- END_LEAD_DISPATCH_MAP()
-
-
-
- void CMfcdemoView::OnRgnChangeLeadctrl1()
- {
- if(GetDocument()->m_Lead2.GetBitmap() == NULL)
- SaveBackground();
- }
-
- void CMfcdemoView::OnMouseDownLeadctrl1(short Button, short Shift, long x, long y)
- {
-
- if( Button != 1 )
- return; /* nothing to do! */
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- if( m_Lead.GetHasRgn() && m_Lead.IsPtInRgn((x - m_Lead.GetDstLeft()) * m_Lead.GetSrcWidth() / m_Lead.GetDstWidth(), (y - m_Lead.GetDstTop()) * m_Lead.GetSrcHeight() / m_Lead.GetDstHeight()) )
- {
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_NONE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- m_xStart = x;
- m_yStart = y;
- // we put the floater into the bitmap only when we select another region
- // if we have a floater at this point, it's because we clicked INSIDE the floater
- m_Lead.SetFloaterVisible(FALSE);
- m_Lead.SetFloater(m_Lead.GetBitmap());
- // the floater coordinates are relative to the window, while the
- // ocx region coordinates are relative to the bitmap. Adding m_Lead.DstLeft
- // converts m_Lead.RgnLeft to window coordinates
- m_rcFloater.left = (int) ((m_Lead.GetRgnLeft() * m_Lead.GetDstWidth() + m_Lead.GetSrcWidth() - 1) / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft());
- m_rcFloater.top = (int) (m_Lead.GetRgnTop() * m_Lead.GetDstHeight() / m_Lead.GetSrcHeight() + m_Lead.GetDstTop());
- m_rcFloater.right = (int) (((m_Lead.GetFloaterWidth() + m_Lead.GetRgnLeft()) * m_Lead.GetDstWidth() + m_Lead.GetSrcWidth() - 1) / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft());
- m_rcFloater.bottom = (int) ((m_Lead.GetFloaterHeight() + m_Lead.GetRgnTop()) * m_Lead.GetDstHeight() / m_Lead.GetSrcHeight() + m_Lead.GetDstTop());
- m_Lead.SetFloaterDstRect((float) m_rcFloater.left, (float) m_rcFloater.top,
- (float) m_rcFloater.Width(), (float) m_rcFloater.Height());
- if( GetDocument()->m_Lead2.GetBitmap() != NULL )
- {
- m_Lead.Combine(m_Lead.GetRgnLeft(),
- m_Lead.GetRgnTop(),
- m_Lead.GetFloaterWidth(),
- m_Lead.GetFloaterHeight(),
- GetDocument()->m_Lead2.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY );
- // RepaintRect uses window coordinates like the floater bitmap
- m_Lead.RepaintRect(m_Lead.GetFloaterDstLeft(),
- m_Lead.GetFloaterDstTop(),
- m_Lead.GetFloaterDstWidth(),
- m_Lead.GetFloaterDstHeight(),
- FALSE);
- }
- m_Lead.SetFloaterVisible(TRUE);
- m_bMovingFloater = TRUE;
- }
- else if (m_nRegionTool != IDM_TOOLNONE)
- {
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
-
- switch(m_nRegionTool)
- {
- case IDM_TOOLRECT:
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_RECT);
- break;
- case IDM_TOOLELLIPSE:
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_ELLIPSE);
- break;
- case IDM_TOOLRNDRECT:
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_ROUNDRECT);
- break;
- case IDM_TOOLFREEHAND:
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_FREEHAND);
- break;
- }
- }
-
- GetDocument()->m_Lead2.SetBitmap(0); // the background bitmap is not needed anymore
-
- SetCursor(hOldCursor);
- }
-
- void CMfcdemoView::OnMouseMoveLeadctrl1(short Button, short Shift, long x, long y)
- {
- if( (Button == 1) && m_bMovingFloater )
- {
- m_Lead.SetFloaterDstRect((float) (m_rcFloater.left + x - m_xStart), (float) (m_rcFloater.top + y - m_yStart),
- m_Lead.GetFloaterDstWidth(), m_Lead.GetFloaterDstHeight());
- }
- }
-
- void CMfcdemoView::OnMouseUpLeadctrl1(short Button, short Shift, long x, long y)
- {
- OLE_HANDLE hRegion;
- long dx, dy;
- if (Button != 1)
- return; /* nothing to do ! */
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- if( m_Lead.GetRgnMarkingMode() != CLead::RGNMARK_NONE )
- {
- m_Lead.SetRgnMarkingMode(CLead::RGNMARK_NONE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
-
- if( m_Lead.GetHasRgn() )
- {
- hRegion = m_Lead.GetRgnHandle();
- GetDocLead()->SetRgnHandle(hRegion,0.0f,0.0f,CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle(hRegion);
- }
- else
- GetDocLead()->FreeRgn();
-
- GetDocument()->UpdateAllViews(this, (LPARAM)0);
- }
- else if(m_bMovingFloater)
- {
- m_bMovingFloater = FALSE;
-
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
-
- // Calculate the region offset
-
- if(x >= m_xStart)
- dx = (x - m_xStart) * (long) m_Lead.GetSrcWidth() / (long) m_Lead.GetDstWidth();
- else
- dx = ((x - m_xStart) * (long) m_Lead.GetSrcWidth() - (long) m_Lead.GetDstWidth() + 1) / (long) m_Lead.GetDstWidth();
- if(y >= m_yStart)
- dy = (y - m_yStart) * (long) m_Lead.GetSrcHeight() / (long) m_Lead.GetDstHeight();
- else
- dy = ((y - m_yStart) * (long) m_Lead.GetSrcHeight() - (long) m_Lead.GetDstHeight() + 1) / (long) m_Lead.GetDstHeight();
-
- m_Lead.OffsetRgn((float) dx, (float) dy);
-
- GetDocument()->m_Lead2.CreateBitmap(m_Lead.GetFloaterWidth(),
- m_Lead.GetFloaterHeight(),
- m_Lead.GetBitmapBits() );
-
- if((m_Lead.GetIsGrayscale() != CLead::GRAY_NO) && (m_Lead.GetBitmapBits()>8))
- GetDocument()->m_Lead2.Grayscale(m_Lead.GetBitmapBits());
-
- GetDocument()->m_Lead2.Combine( 0.0f,
- 0.0f,
- m_Lead.GetFloaterWidth(),
- m_Lead.GetFloaterHeight(),
- m_Lead.GetBitmap(),
- m_Lead.GetRgnLeft(),
- m_Lead.GetRgnTop(),
- CLead::L_SRC_COPY);
-
- // now blend the floater into the bitmap and make it dissapear
- // if we leave it, when we scroll, the floater won't move with the bitmap
- // that's because the floater is independent of the bitmap
- m_Lead.Combine( m_Lead.GetRgnLeft(),
- m_Lead.GetRgnTop(),
- m_Lead.GetFloaterWidth(),
- m_Lead.GetFloaterHeight(),
- m_Lead.GetFloater(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- // free the floater
- m_Lead.SetFloater(NULL);
- m_Lead.SetFloaterVisible(FALSE);
-
- // draw the frame
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead.SetAutoRepaint(TRUE);
-
- /* update the changes back into the master document and all other views */
- UpdateMasterDocument();
- }
-
- SetCursor(hOldCursor);
- }
-
- void CMfcdemoView::OnImageRegiontransformationsFlip()
- {
- OLE_HANDLE hRegion;
- float xCenter;
- float yCenter;
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetFloaterVisible(FALSE);
- m_Lead.SetFloater(m_Lead.GetBitmap());
- RestoreBackground();
- m_Lead3.SetBitmap(m_Lead.GetFloater());
- m_Lead.SetFloater(0);
-
- // do the transformation on the copy
- m_Lead3.Flip();
-
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- hRegion = m_Lead3.GetRgnHandle();
- xCenter = m_Lead.GetRgnLeft() + m_Lead.GetRgnWidth() / 2;
- yCenter = m_Lead.GetRgnTop() + m_Lead.GetRgnHeight() / 2;
- /* The flollowing two statements
- m_Lead.SetRgnHandle(hRegion, CLead::L_RGN_SET);
- m_Lead.OffsetRgn(
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2);
- do exactly the same thing as this statement: */
- m_Lead.SetRgnHandle(hRegion,
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle (hRegion);
- SaveBackground();
- m_Lead.Combine(
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- m_Lead3.GetBitmapWidth(),
- m_Lead3.GetBitmapHeight(),
- m_Lead3.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- m_Lead.RepaintRect(
- m_Lead.GetRgnLeft() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft(),
- m_Lead.GetRgnTop() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstTop(),
- m_Lead.GetRgnWidth() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- m_Lead.GetRgnHeight() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- FALSE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead3.SetBitmap(0);
- m_Lead.SetAutoRepaint(TRUE);
-
-
- /* update the changes back into the master document and all other views */
- UpdateMasterDocument();
-
- SetCursor(hOldCursor);
- }
-
- void CMfcdemoView::OnImageRegiontransformationsResize()
- {
- CResizeDlg dlg;
-
- dlg.m_nWidth = (int) GetDocLead()->GetRgnWidth();
- dlg.m_nHeight = (int) GetDocLead()->GetRgnHeight();
- if(dlg.DoModal() == IDOK)
- {
- int nRet;
- OLE_HANDLE hRegion;
- float xCenter;
- float yCenter;
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetFloaterVisible(FALSE);
- m_Lead.SetFloater(m_Lead.GetBitmap());
- RestoreBackground();
- m_Lead3.SetBitmap(m_Lead.GetFloater());
- m_Lead.SetFloater(0);
-
- // do the transformation on the copy
- if(dlg.m_fResample)
- nRet = m_Lead3.Size((float) dlg.m_nWidth, (float) dlg.m_nHeight, CLead::RESIZE_RESAMPLE);
- else
- nRet = m_Lead3.Size((float) dlg.m_nWidth, (float) dlg.m_nHeight, CLead::RESIZE_NORMAL);
-
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- hRegion = m_Lead3.GetRgnHandle();
- xCenter = m_Lead.GetRgnLeft() + m_Lead.GetRgnWidth() / 2;
- yCenter = m_Lead.GetRgnTop() + m_Lead.GetRgnHeight() / 2;
- m_Lead.SetRgnHandle(hRegion,
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle (hRegion);
- SaveBackground();
- m_Lead.Combine(
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- m_Lead3.GetBitmapWidth(),
- m_Lead3.GetBitmapHeight(),
- m_Lead3.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- m_Lead.RepaintRect(
- m_Lead.GetRgnLeft() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft(),
- m_Lead.GetRgnTop() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstTop(),
- m_Lead.GetRgnWidth() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- m_Lead.GetRgnHeight() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- FALSE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead3.SetBitmap(0);
- m_Lead.SetAutoRepaint(TRUE);
-
- /* update the changes back into the master document and all other views */
- UpdateMasterDocument();
-
- SetCursor(hOldCursor);
- }
- }
-
- void CMfcdemoView::OnImageRegiontransformationsReverse()
- {
- OLE_HANDLE hRegion;
- float xCenter;
- float yCenter;
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetFloaterVisible(FALSE);
- m_Lead.SetFloater(m_Lead.GetBitmap());
- RestoreBackground();
- m_Lead3.SetBitmap(m_Lead.GetFloater());
- m_Lead.SetFloater(0);
-
- // do the transformation on the copy
- m_Lead3.Reverse();
-
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- hRegion = m_Lead3.GetRgnHandle();
- xCenter = m_Lead.GetRgnLeft() + m_Lead.GetRgnWidth() / 2;
- yCenter = m_Lead.GetRgnTop() + m_Lead.GetRgnHeight() / 2;
- m_Lead.SetRgnHandle(hRegion,
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle (hRegion);
- SaveBackground();
- m_Lead.Combine(
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- m_Lead3.GetBitmapWidth(),
- m_Lead3.GetBitmapHeight(),
- m_Lead3.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- m_Lead.RepaintRect(
- m_Lead.GetRgnLeft() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft(),
- m_Lead.GetRgnTop() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstTop(),
- m_Lead.GetRgnWidth() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- m_Lead.GetRgnHeight() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- FALSE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead3.SetBitmap(0);
- m_Lead.SetAutoRepaint(TRUE);
-
- /* update the changes back into the master document and all other views */
- UpdateMasterDocument();
-
- SetCursor(hOldCursor);
- }
-
- void CMfcdemoView::OnImageRegiontransformationsRotate()
- {
- CFloatDlg dlg;
-
- dlg.m_strTitle = _T("Rotate");
- dlg.m_strLabel = _T("&Angle");
- dlg.m_strCheck = _T("&Resize");
- dlg.m_fCheck = TRUE;
- dlg.m_fShowCheck = TRUE;
- dlg.m_fltMin = -360.0f;
- dlg.m_fltMax = 360.0f;
- dlg.m_fltScale = 10.0f;
- if(dlg.DoModal() == IDOK)
- {
- OnImageRegiontransformationsRotate((long) (dlg.m_fltValue * 100), dlg.m_fCheck);
- }
- }
- void CMfcdemoView::OnImageRegiontransformationsRotate(long nAngle, BOOL fResize)
- {
-
- OLE_HANDLE hRegion;
- float xCenter;
- float yCenter;
-
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- m_Lead.SetAutoRepaint(FALSE);
- m_Lead.SetFloaterVisible(FALSE);
- m_Lead.SetFloater(m_Lead.GetBitmap());
- RestoreBackground();
- m_Lead3.SetBitmap(m_Lead.GetFloater());
- m_Lead.SetFloater(0);
-
- // do the transformation on the copy
- m_Lead3.Rotate(nAngle, fResize, RGB(255, 255, 255));
-
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- hRegion = m_Lead3.GetRgnHandle();
- xCenter = m_Lead.GetRgnLeft() + m_Lead.GetRgnWidth() / 2;
- yCenter = m_Lead.GetRgnTop() + m_Lead.GetRgnHeight() / 2;
- m_Lead.SetRgnHandle(hRegion,
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle (hRegion);
- SaveBackground();
- m_Lead.Combine(
- xCenter - m_Lead3.GetBitmapWidth() / 2,
- yCenter - m_Lead3.GetBitmapHeight() / 2,
- m_Lead3.GetBitmapWidth(),
- m_Lead3.GetBitmapHeight(),
- m_Lead3.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- m_Lead.RepaintRect(
- m_Lead.GetRgnLeft() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstLeft(),
- m_Lead.GetRgnTop() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth() + m_Lead.GetDstTop(),
- m_Lead.GetRgnWidth() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- m_Lead.GetRgnHeight() * m_Lead.GetDstWidth() / m_Lead.GetSrcWidth(),
- FALSE);
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_ANIMATED);
- m_Lead3.SetBitmap(0);
- m_Lead.SetAutoRepaint(TRUE);
-
- /* update the changes back into the master document and all other views */
- UpdateMasterDocument();
-
- SetCursor(hOldCursor);
-
- }
-
- void CMfcdemoView::UpdateMasterDocument()
- {
- /* merge the changes back into the master document */
- OLE_HANDLE hRegion = m_Lead.GetRgnHandle();
- GetDocLead()->SetBitmap(m_Lead.GetBitmap());
- GetDocLead()->SetRgnHandle(hRegion,0.0f,0.0f,CLead::L_RGN_SET);
- m_Lead.DeleteRgnHandle(hRegion);
- GetDocument()->UpdateAllViews(this, (LPARAM)0);
- }
-
- void CMfcdemoView::SaveBackground()
- {
- GetDocument()->m_Lead2.CreateBitmap(m_Lead.GetRgnWidth(), m_Lead.GetRgnHeight(), m_Lead.GetBitmapBits());
-
- if((m_Lead.GetIsGrayscale() != CLead::GRAY_NO) && (m_Lead.GetBitmapBits()>8))
- GetDocument()->m_Lead2.Grayscale(m_Lead.GetBitmapBits());
-
- GetDocument()->m_Lead2.Combine(
- 0.0f, 0.0f,
- m_Lead.GetRgnWidth(), m_Lead.GetRgnHeight(),
- m_Lead.GetBitmap(),
- m_Lead.GetRgnLeft(), m_Lead.GetRgnTop(),
- CLead::L_SRC_COPY);
- }
-
- void CMfcdemoView::RestoreBackground()
- {
- if(GetDocument()->m_Lead2.GetBitmap())
- m_Lead.Combine(
- m_Lead.GetRgnLeft(),
- m_Lead.GetRgnTop(),
- m_Lead.GetRgnWidth(),
- m_Lead.GetRgnHeight(),
- GetDocument()->m_Lead2.GetBitmap(),
- 0.0f,
- 0.0f,
- CLead::L_SRC_COPY);
- }
-
- void CMfcdemoView::OnUpdateImageRegiontransformationsCancel(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_Lead.GetHasRgn());
- }
-
- void CMfcdemoView::OnImageRegiontransformationsCancel()
- {
- HCURSOR hOldCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
-
- RestoreBackground();
-
- /* delete the regions from the master document and all other views */
- m_Lead.SetRgnFrameType(CLead::RGNFRAME_NONE);
- m_Lead.FreeRgn();
-
- GetDocLead()->SetBitmap(m_Lead.GetBitmap());
- GetDocLead()->FreeRgn();
- GetDocument()->UpdateAllViews(this, (LPARAM)0);
-
- SetCursor(hOldCursor);
- }
-