예제 #1
0
/**
 Extracts data from aFrameData, packs them and then it sends this package to the player
*/
void RBitmapAnim::SetFrameL(const CBitmapFrameData& aFrameData, TInt aOpCode)
	{
	TPckgBuf<TFrameData> dataFrameArg;
	CFbsBitmap* bitmap = aFrameData.Bitmap();
	dataFrameArg().iBitmapHandle=( (bitmap) ? bitmap->Handle() : 0 );
	CFbsBitmap* mask = aFrameData.Mask();
	dataFrameArg().iMaskBitmapHandle=( (mask) ? mask->Handle() : 0 );
	dataFrameArg().iIntervalInMilliSeconds=aFrameData.IntervalInMilliSeconds();
	dataFrameArg().iPosition=aFrameData.Position();
	User::LeaveIfError(CommandReply(aOpCode, dataFrameArg));
	}
예제 #2
0
EXPORT_C TInt AknsUtils::GetAppIcon(
    MAknsSkinInstance* aInstance, TUid aAppUid, TSize aSize,
    CApaMaskedBitmap& aAppBitmap )
    {
    AKNS_TRACE_OBSOLETE("AknsUtils::GetAppIcon (4 param)");

    __ASSERT_DEBUG( aAppBitmap.Mask(),
        AKNS_DEBUG_PANIC( EAknsDPanicInvalidParameter ) );

    CFbsBitmap* bitmap = NULL;
    CFbsBitmap* mask = NULL;

    TInt ret = KErrNone;
    TBool configuredIcon = EFalse;

    if ( !configuredIcon )
        {
        ret = GetAppIconFromSkin( aInstance, aAppUid, aSize, bitmap, mask );
        if( ret == KErrNone )
            {
            if( bitmap && mask && bitmap->Handle() && mask->Handle() )
                {
                ret = aAppBitmap.Duplicate( bitmap->Handle() );
                ret |= aAppBitmap.Mask()->Duplicate( mask->Handle() );
                delete bitmap;
                delete mask;
                return ret;
                }
            else
                {
                // Delete bitmaps and proceed
                delete bitmap;
                bitmap = NULL; 
                delete mask;
                mask = NULL; 
                }
            }
        }

    RApaLsSession lsSession;
    ret = lsSession.Connect();
    if( ret == KErrNone )
        {
        ret = lsSession.GetAppIcon( aAppUid, aSize, aAppBitmap );
        lsSession.Close();
        if(ret == KErrNone) //icon case
        	AknInternalIconUtils::SetAppIcon(bitmap); //icon case
        }

    return ret;
    } //lint !e1746 GetAppIcon syntax
예제 #3
0
// -----------------------------------------------------------------------------
// CMaskedBitmap::Copy
// -----------------------------------------------------------------------------
TInt CMaskedBitmap::Copy( const CFbsBitmap& aBitmap, const CFbsBitmap& aMask, TBool aDuplicate )
    {
    Reset();

    TInt bitmapHandle( aBitmap.Handle() );
    TInt maskHandle( aMask.Handle() );
    if( bitmapHandle && maskHandle &&
        aBitmap.SizeInPixels() != aMask.SizeInPixels() )
        {
        return KErrArgument;
        }

    TInt err( KErrNone );
    if( bitmapHandle )
        {
        if( aDuplicate )
            {
            err = iBitmap->Duplicate( bitmapHandle );
            }
        else
            {
            err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap );
            }
        }

    if( !err && maskHandle )
        {
        if( aDuplicate )
            {
            err = iMask->Duplicate( maskHandle );
            }
        else
            {
            err = BitmapUtil::CopyBitmap( aMask, *iMask );
            }
        if( err )
            {
            iBitmap->Reset();
            }
        }
    return err;
    }
예제 #4
0
int CAfStorageClient::getThumbnail(const TDesC &imagePath, void *userData)
{
    lastMethodCalled = CAfStorageClient::GetThumbnailMethod;
    delete lastCallThumbnailPath;
    lastCallThumbnailPath = imagePath.Alloc();
    lastCallUserData = userData;
    CFbsBitmap *bitmap = new (ELeave)CFbsBitmap();
    CleanupStack::PushL(bitmap);
    User::LeaveIfError(bitmap->Create(TSize(128, 128), EColor4K));
    mObserver.getThumbnailRequestCompleted(CAfStorageClient::expectedReturnCode, bitmap->Handle(), userData);
    CleanupStack::PopAndDestroy(bitmap);
    return CAfStorageClient::expectedReturnCode;
}
예제 #5
0
void CTestStepVidPlayerDRMGetFrame::MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError)
	{
	iError = aError;
	if (aError==KErrNone)
		{
		if (aFrame.Handle() == NULL || aFrame.SizeInPixels() != TSize(KFrameWidth,KFrameHeight) )
			iError = KErrArgument;
		else
			{
				iError = KErrNone;
				INFO_PRINTF1(_L("MvpuoFrameReady: GetFrameL() COMPLETED OK"));
			}
		}
	CActiveScheduler::Stop();
	}
예제 #6
0
// -----------------------------------------------------------------------------
// AknsUtils::CreateMaskedBitmapL
// -----------------------------------------------------------------------------
//
EXPORT_C CApaMaskedBitmap* AknsUtils::CreateMaskedBitmapL(
    MAknsSkinInstance* aInstance, const TAknsItemID& aID,
    const TDesC& aFilename,
    const TInt aFileIndex, const TInt aFileMaskIndex )
    {
    AKNS_TRACE_OBSOLETE("AknsUtils::CreateMaskedBitmapL (5 param)");

    CFbsBitmap* bitmap = NULL;
    CFbsBitmap* mask = NULL;

    CreateIconLC( aInstance, aID, bitmap, mask,
        aFilename, aFileIndex, aFileMaskIndex );

    // Bitmap and mask always exist here
    CApaMaskedBitmap* maskedBitmap = CApaMaskedBitmap::NewLC();
    // Note that these calls leave with SVG-originating icons
    User::LeaveIfError( maskedBitmap->Duplicate( bitmap->Handle() ) );
    User::LeaveIfError( maskedBitmap->Mask()->Duplicate( mask->Handle() ) );
    CleanupStack::Pop( maskedBitmap );

    CleanupStack::PopAndDestroy( 2 ); // bitmap, mask

    return maskedBitmap;
    }
예제 #7
0
// -----------------------------------------------------------------------------
// CMaskedBitmap::Copy
// -----------------------------------------------------------------------------
TInt CMaskedBitmap::Copy( const CFbsBitmap& aBitmap, TBool aDuplicate )
    {
    Reset();

    TInt err( KErrNone );
    TInt bitmapHandle( aBitmap.Handle() );
    if( bitmapHandle )
        {
        if( aDuplicate )
            {
            err = iBitmap->Duplicate( bitmapHandle );
            }
        else
            {
            err = BitmapUtil::CopyBitmap( aBitmap, *iBitmap );
            }
        }
    return err;
    }
예제 #8
0
/**
	@SYMTestCaseID
	GRAPHICS-FBSERV-0512

	@SYMTestCaseDesc
	Creates bitmaps in different ways and checks if memory allocation succeeded 

	@SYMTestActions
	Creates normal size bitmaps, large bitmaps, loads bitmaps, loads shared bitmaps,
	duplicated bitmaps, resizes bitmaps, compresses bitmaps, externalized bitmaps to write store, 
	internalizes bitmaps back again from write store. All ways of creating bitmaps are tested
	against Out Of Memory error conditions	

	@SYMTestExpectedResults
	Test should pass
*/
void CTAlloc::BitmapsL()
	{
	TInt heapMarkCheckFlag;	
	if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) )
		{
		INFO_PRINTF1(_L("Error reading ini file"));
		User::Leave(KErrNotFound);
		}
	
	CFbsBitmap iBitmap;
	CFbsBitmap iBitmap2;

	iTestBitmapName = KTestBitmapOnZ;
	TInt ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);

	ret = iBitmap.Create(KLargeSize,EColor256); // Expand server caches
	TEST2(ret, KErrNone);
	iBitmap.Reset();

	TInt count;

// Create bitmap
	INFO_PRINTF1(_L("CFbsBitmap::Create()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}
		ret = iBitmap.Create(KSmallSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret=iBitmap.Create(KSmallSize,EGray2);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Create (large)
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load
	INFO_PRINTF1(_L("CFbsBitmap::Load()\r\n"));
	ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load (shared)
	INFO_PRINTF1(_L("CFbsBitmap::Load() - shared \r\n"));
	
	// Do an initial load to ensure the StreamId cache does not get updated whilst OOM testing
	ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);	
			
		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();	
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);		
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);

		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
// Duplicate
	CFbsBitmap bmpalt;
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Duplicate()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==1);
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	bmpalt.Reset();
	TEST(iFbs->ResourceCount()==0);

// Resize
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Resize()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KSmallSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KLargeSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Compress
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// WriteStore creation
	RFs fs;
	ret=fs.Connect();
	TEST2(ret, KErrNone);
	CDirectFileStore* writestore=NULL;

	//Construct filename using the thread id to enable concurrent test runs.
	_LIT(KSbmFileName,"c:\\tall_");
	TBuf<36> buf(KSbmFileName);
	TThreadId threadId = RThread().Id();
	TUint64 id = threadId.Id();
	TBuf<20> threadIdBuf;
	threadIdBuf.Num(id);
	buf.Append(threadIdBuf);
	buf.Append(_L(".sbm"));
	
	TRAP(ret,writestore=CDirectFileStore::ReplaceL(fs,buf,EFileStream|EFileWrite));
	TEST2(ret, KErrNone);
	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
	TRAP(ret,writestore->SetTypeL(uidtype));
	TEST2(ret, KErrNone);

	RStoreWriteStream writestrm;
	TStreamId headerid(0);
	TRAP(ret,headerid=writestrm.CreateL(*writestore));
	TEST2(ret, KErrNone);
	TRAP(ret,writestore->SetRootL(headerid));
	TEST2(ret, KErrNone);

// Externalize
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeL(writestrm));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	TEST(iFbs->ResourceCount()==0);

// ExternalizeRectangle
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeRectangleL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeRectangleL(writestrm,TRect(3,3,7,7)));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	writestrm.Close();
	delete writestore;
	iBitmap.Reset();
	TEST(iFbs->ResourceCount()==0);

// Internalize
	INFO_PRINTF1(_L("CFbsBitmap::InternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		// ReadStore creation
		CDirectFileStore* readstore=NULL;
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		RStoreReadStream readstrm;
		headerid=readstore->Root();
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		// ReadStore re-creation
		CDirectFileStore* readstore=NULL;
//		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,_L("c:\\tall.sbm"),EFileStream|EFileRead|EFileShareAny));
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		headerid=readstore->Root();
		RStoreReadStream readstrm;
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	fs.Delete(buf);
	fs.Close();
	}