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

📄 readbarcappview.cpp

📁 barcode readers [ from Image]
💻 CPP
字号:
/* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

#include "EikonEnvironment.h"
#include "Rgb2Gray.h"
#include "SnapShotAppView.h"

using namespace BackwoodsProgrammer;

// Standard Epoc construction sequence
CSnapShotAppView* CSnapShotAppView::NewL(const TRect& aRect)
    {
    CSnapShotAppView* self = CSnapShotAppView::NewLC(aRect);
    CleanupStack::Pop();
    return self;
    }

CSnapShotAppView* CSnapShotAppView::NewLC(const TRect& aRect)
    {
    CSnapShotAppView* self = new (ELeave) CSnapShotAppView;
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    return self;
    }

void CSnapShotAppView::ConstructL(const TRect& aRect)
    {
    iCameraManager = CCameraManager::NewL(*this);
	iImageDll = BackwoodsProgrammer::CImageDll::NewL();

    iBitmap = new (ELeave) CFbsBitmap();

    // Create a window for this application view
    CreateWindowL();

    // Set the windows size
    SetRect(aRect);

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

CSnapShotAppView::CSnapShotAppView()
    {
    // Add any construction code that can not leave here
    }


CSnapShotAppView::~CSnapShotAppView()
    {
    delete iCameraManager;
    iCameraManager = NULL;

	delete iImageDll;
	iImageDll = NULL;

    delete iBitmap;
    iBitmap = NULL;
    }

TBool CSnapShotAppView::IsCameraReady()
    {
    ASSERT(iCameraManager != NULL);
    return  iCameraManager->IsReady();
    }

void CSnapShotAppView::Snap()
    {
    ASSERT(iCameraManager != NULL);
    iCameraManager->Snap(*iBitmap);
    }

void CSnapShotAppView::Draw(const TRect& /*aRect*/) const
    {
    ASSERT(iCameraManager != NULL);

    // Clear the screen
    CWindowGc& gc = SystemGc();
    gc.Clear(Rect());

	//if the bitmap is not currently being processed in any way
	// AND a valid bitmap exists, then draw it
	if ( (iCameraManager->IsReady()) && (iBitmap->Handle()) )
		{
			CFbsImage* pImage = iImageDll->GetFbsImage()(*iBitmap);
			CleanupStack::PushL(pImage);
			CRgb2Gray* pRgb2Gray = iImageDll->GetRgb2Gray()();
			CleanupStack::PushL(pRgb2Gray);
			pRgb2Gray->PushL(pImage);
			gc.DrawBitmap(Rect(), iBitmap, iBitmap->SizeInPixels());
			CleanupStack::PopAndDestroy();
			CleanupStack::PopAndDestroy();
		}
    }


void CSnapShotAppView::PictureTaken()
    {
    DrawDeferred();
    }


_LIT (KEmulatorError, "Snapshot is not currently supported by this emulator.");
_LIT (KErrorMessage,  "CCamera server error : %d");

void CSnapShotAppView::Error(TInt aError)
    {
#ifdef __WINS__
    if (aError == KErrNotFound)
		{
		NEikonEnvironment::MessageBox (KEmulatorError);
		return;
		}
#endif
	TBuf<32> cameraError;
	cameraError.Format (KErrorMessage, aError);
	NEikonEnvironment::MessageBox (cameraError);
    }

⌨️ 快捷键说明

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