cpictureloader.cpp

来自「This package includes a 3-D game engine 」· C++ 代码 · 共 126 行

CPP
126
字号
    /*
    *
============================================================================
    *  Name     : CPictureLoader.h
    *  Part of  : Example3D
    *  Created  : 12/14/2003 by Forum Nokia
    *  Description:
    *     This is the project specification file for Example3D.
    *     Initial content was generated by Series 60 AppWizard.
    *
    *  Version  : 1.0.0
    *  Copyright: Forum Nokia
    *
============================================================================
    */

// INCLUDES
#include "CPictureLoader.h"
#include <eikenv.h>
#include <eikappui.h>
#include <eikapp.h>

// MEMBER FUNCTIONS

CPictureLoader* CPictureLoader::NewL()
	{
	CPictureLoader* self = new( ELeave )CPictureLoader();
	CleanupStack::PushL( self );
	self->ConstructL();
	CleanupStack::Pop( self );
	return self;
	}


CPictureLoader::~CPictureLoader()
	{

	}


void CPictureLoader::ConstructL()
	{
	TFileName appFullName = CEikonEnv::Static()->EikAppUi()->Application()->AppFullName();
	TParse parse;

	//On WINS the application is on the z drive
#ifdef __WINS__
    parse.Set(_L("c:"), &appFullName, NULL);
#else
    parse.Set( appFullName, NULL, NULL);
#endif
    iPath = parse.DriveAndPath();
	}


CPictureLoader::CPictureLoader()
	{

	}


TBitmap CPictureLoader::LoadL( const TFileName& aFileName, TDisplayMode aDisplayMode )
	{
	TFileName file( iPath );
	file.Append( aFileName );

	CFbsBitmap bitmap;

	iStatus = KErrNone;
	CMdaImageFileToBitmapUtility* util;
	util = CMdaImageFileToBitmapUtility::NewL( *this ) ;
	
	CleanupStack::PushL( util );
	
	util->OpenL( file );
	CActiveScheduler::Start();
	User::LeaveIfError( iStatus );

	TFrameInfo frameInfo;
	util->FrameInfo( 0, frameInfo );
	
	User::LeaveIfError( bitmap.Create( frameInfo.iOverallSizeInPixels, aDisplayMode ) );
	
	util->ConvertL( bitmap );	
	CActiveScheduler::Start();
	User::LeaveIfError( iStatus );

	CleanupStack::PopAndDestroy( util );

	TBitmap bm;

	bm.iSize = bitmap.SizeInPixels();	

	TInt pixels = bm.iSize.iWidth * bm.iSize.iHeight;
	bm.iData = new( ELeave )TUint16[ pixels ];
	
	TInt y;
	for( y=0; y<bm.iSize.iHeight; y++ )
		{
		TPtr8 ydata( ((TUint8*)bm.iData) + y * bm.iSize.iWidth * 2, bm.iSize.iWidth * 2 );
		bitmap.GetScanLine( ydata, TPoint( 0, y ), bm.iSize.iWidth, aDisplayMode );
		}

	return bm;
	}


void CPictureLoader::MiuoConvertComplete( TInt aError )
	{
	iStatus = aError;
	CActiveScheduler::Stop();
	}


void CPictureLoader::MiuoCreateComplete( TInt /*aError*/ )
	{
	// manual create...
	}


void CPictureLoader::MiuoOpenComplete( TInt aError )
	{
	iStatus = aError;
	CActiveScheduler::Stop();
	}

⌨️ 快捷键说明

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