lafagnosticuifoundation/uigraphicsutils/gulsrc/gulsprite.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <gulsprite.h>
       
    17 #include <gulgcmap.h>
       
    18 #include "GULSTD.H"
       
    19 
       
    20 const TInt KOffScreenValue = -1000;
       
    21 
       
    22 /**
       
    23  * Creates and returns a pointer to a CSpriteSet object clipped to the parent aWindow. The
       
    24  * sprite set is initialized with aSpriteSetMember and the sprite set takes ownership of
       
    25  * this parameter.  aWs is the window session used.  aInvertMask specifies whether the
       
    26  * bitmap/mask pairs which will be added will use an inverted mask.
       
    27  */
       
    28 EXPORT_C CSpriteSet* CSpriteSet::NewL(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice, CGulIcon* aSpriteSetMember, TBool aInvertMask)
       
    29 	{//static
       
    30 	CSpriteSet* self = CSpriteSet::NewLC(aWindow,aWs,aDevice,aSpriteSetMember,aInvertMask);
       
    31 	CleanupStack::Pop();
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 /**
       
    36  * Creates and returns a pointer to a CSpriteSet object clipped to the parent aWindow. The
       
    37  * sprite set is initialized with aSpriteSetMember and the sprite set takes ownership of
       
    38  * this parameter.  aWs is the window session used.  aInvertMask specifies whether the
       
    39  * bitmap/mask pairs which will be added will use an inverted mask.  Leaves the returned
       
    40  * pointer on the cleanup stack.
       
    41  */
       
    42 EXPORT_C CSpriteSet* CSpriteSet::NewLC(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice, CGulIcon* aSpriteSetMember, TBool aInvertMask)
       
    43 	{//static
       
    44 	CSpriteSet* self = new(ELeave) CSpriteSet(aInvertMask);
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL(aWindow,aWs,aDevice);
       
    47 	self->AddMemberL(aSpriteSetMember);
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 /**
       
    52  * Adds aSpriteSetMember to the sprite set.  Panics if a null member is passed in, or
       
    53  * if the argument does not include a bitmap and mask.
       
    54  */
       
    55 EXPORT_C void CSpriteSet::AddMemberL(CGulIcon* aSpriteSetMember)
       
    56 	{
       
    57 	__ASSERT_ALWAYS(aSpriteSetMember != NULL, Panic(EEgulPanicAttemptToAppendNullMember));
       
    58 	__ASSERT_ALWAYS(aSpriteSetMember->Bitmap() && aSpriteSetMember->Mask(), Panic(EEgulPanicAttemptToAppendIncompleteMember));
       
    59 	User::LeaveIfError(iSourceMembers.Append(aSpriteSetMember));
       
    60 	}
       
    61 
       
    62 /**
       
    63  * Removes a member (indexed by aSpriteSetMemberIndex) from the array.
       
    64  * Panics if the member index is not within the existing array's range.
       
    65  */
       
    66 EXPORT_C void CSpriteSet::RemoveMember(TInt aSpriteSetMemberIndex)
       
    67 	{
       
    68 	__ASSERT_ALWAYS((aSpriteSetMemberIndex >= 0) && (aSpriteSetMemberIndex < iSourceMembers.Count()),Panic(EEgulPanicInvalidSpriteIndex));
       
    69 	delete iSourceMembers[aSpriteSetMemberIndex];
       
    70 	iSourceMembers.Remove(aSpriteSetMemberIndex);
       
    71 	}
       
    72 
       
    73 /**
       
    74  * Prepares the sprite in the set of type aSpriteType to be displayed at
       
    75  * aSpritePos with size aSpriteSize.  The sprite will be resized as necessary under the
       
    76  * restriction of aSpriteResizeMode.
       
    77  */
       
    78 EXPORT_C void CSpriteSet::PrepareSpriteForDisplayL(TInt aSpriteType, const TPoint& aSpritePos, const TSize& aSpriteSize, TSpriteResizeMode aSpriteResizeMode)
       
    79 	{
       
    80 	__ASSERT_DEBUG((aSpriteType >= 0) && (aSpriteType < iSourceMembers.Count()),Panic(EEgulPanicInvalidSpriteIndex));
       
    81 	__ASSERT_DEBUG((aSpriteSize.iWidth >= 0) && (aSpriteSize.iHeight >= 0),Panic(EEgulPanicNegativeSpriteSize));
       
    82 	iSpritePosition = aSpritePos;
       
    83 	iMainFbsBitGc->SetOrigin(TPoint(0,0));
       
    84 	TSize spriteSize(aSpriteSize);
       
    85 	const TSize sourceSize(iSourceMembers[aSpriteType]->Bitmap()->SizeInPixels());
       
    86 	AdjustSpriteSizeAccordingToResizeMode(spriteSize, sourceSize, aSpriteResizeMode);
       
    87 	User::LeaveIfError(iMainBmpDevice->Resize(spriteSize));
       
    88 	User::LeaveIfError(iMaskBmpDevice->Resize(spriteSize));
       
    89 	iMainFbsBitGc->Resized();
       
    90 	iMaskFbsBitGc->Resized();
       
    91 	iMaskFbsBitGc->SetBrushColor(KRgbBlack);
       
    92 	iMaskFbsBitGc->Clear();
       
    93 	const TRect translatedClipRect(iClippingRect.iTl - aSpritePos, iClippingRect.Size());
       
    94 	if(!translatedClipRect.IsEmpty())
       
    95 		iMaskFbsBitGc->SetClippingRect(translatedClipRect);
       
    96 	TInternalSpriteResizeMode resizeMode = EHSameVSame;
       
    97 	ComputeInternalResizeMode(resizeMode,aSpriteResizeMode,sourceSize,spriteSize);
       
    98 	RenderSprite(aSpriteType,resizeMode,sourceSize,spriteSize);
       
    99 	iMaskFbsBitGc->CancelClippingRect();
       
   100 	iMainFbsBitGc->SetOrigin(-aSpritePos);
       
   101 	}
       
   102 
       
   103 /**
       
   104  * Brings the sprite onto the visible area of the screen.  Must also call this
       
   105  * if the sprite set member which is being used has changed.
       
   106  */
       
   107 EXPORT_C void CSpriteSet::StartDisplayingSpriteL()
       
   108 	{
       
   109 	iSprite.SetPosition(iSpritePosition);
       
   110 	User::LeaveIfError(iSprite.UpdateMember(0,iSpriteMember));
       
   111 	iFlags |= ESpriteIsCurrentlyDisplayed;
       
   112 	}
       
   113 
       
   114 /**
       
   115  * Stops the display of the sprite on the visible area of the screen.
       
   116  */
       
   117 EXPORT_C void CSpriteSet::StopDisplayingSprite()
       
   118 	{
       
   119 	if(iFlags&ESpriteIsCurrentlyDisplayed)
       
   120 		{
       
   121 		iFlags |= (~ESpriteIsCurrentlyDisplayed);
       
   122 		iSprite.SetPosition(TPoint(KOffScreenValue,KOffScreenValue));
       
   123 		}
       
   124 	}
       
   125 
       
   126 /**
       
   127  * Allows use of the Gc which the sprite uses for it's drawing.  This enables the client
       
   128  * to effectively draw onto the sprite.
       
   129  */
       
   130 EXPORT_C CWindowGc* CSpriteSet::SpriteGc() const
       
   131 	{
       
   132 	__ASSERT_DEBUG(iWindowToBitmapMappingGc,Panic(EEgulPanicNullPointer));
       
   133 	return iWindowToBitmapMappingGc;
       
   134 	}
       
   135 
       
   136 /**
       
   137  * Method for moving the postion of the sprite by aSpritePos from the current position.
       
   138  */
       
   139 EXPORT_C void CSpriteSet::TranslateSpritePosition(const TPoint& aSpritePos)
       
   140 	{
       
   141 	if(iFlags&ESpriteIsCurrentlyDisplayed)
       
   142 		{
       
   143 		iSpritePosition += aSpritePos;
       
   144 		iSprite.SetPosition(iSpritePosition);
       
   145 		}
       
   146 	}
       
   147 
       
   148 /**
       
   149  * Bounds the drawing of the sprite within aRect, stopping it drawing over surrounding
       
   150  * components.
       
   151  */
       
   152 EXPORT_C void CSpriteSet::SetClippingRect(const TRect& aRect)
       
   153 	{
       
   154 	iClippingRect = aRect;
       
   155 	}
       
   156 
       
   157 CSpriteSet::~CSpriteSet()
       
   158 	{
       
   159 	iSprite.Close();
       
   160 	delete iMainFbsBitGc;
       
   161 	delete iMaskFbsBitGc;
       
   162 	delete iMainBmpDevice;
       
   163 	delete iMaskBmpDevice;
       
   164 	iSourceMembers.ResetAndDestroy();
       
   165 	iSourceMembers.Close();
       
   166 	delete iTargetBitmap;
       
   167 	delete iTargetMaskBitmap;
       
   168 	delete iWindowToBitmapMappingGc;
       
   169 	}
       
   170 
       
   171 CSpriteSet::CSpriteSet(TBool aInvertMask)
       
   172 	: iFlags((aInvertMask&EMaskIsInverted) & (~ESpriteIsCurrentlyDisplayed))
       
   173 	{
       
   174 	}
       
   175 
       
   176 void CSpriteSet::ConstructL(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice)
       
   177 	{
       
   178     TInt grayscaleCapabilities;
       
   179 	TInt colorCapabilities;
       
   180 	const TDisplayMode mode=aWs.GetDefModeMaxNumColors(colorCapabilities,grayscaleCapabilities);
       
   181 	iTargetBitmap = new (ELeave) CWsBitmap(aWs);
       
   182 	const TSize zeroSize(0,0);
       
   183 	User::LeaveIfError(iTargetBitmap->Create(zeroSize,mode));
       
   184 	iTargetMaskBitmap = new (ELeave) CWsBitmap(aWs);
       
   185 	User::LeaveIfError(iTargetMaskBitmap->Create(zeroSize,mode));
       
   186 
       
   187 	iSprite=RWsSprite(aWs);
       
   188 	User::LeaveIfError(iSprite.Construct(aWindow, TPoint(KOffScreenValue,KOffScreenValue), ESpriteNoChildClip));
       
   189 	CreateSpriteMember();
       
   190 	iSprite.AppendMember(iSpriteMember);
       
   191 	iSprite.Activate();
       
   192 	iMainFbsBitGc=CFbsBitGc::NewL();	// for the main bitmap
       
   193 
       
   194 	iWindowToBitmapMappingGc = CWindowToBitmapMappingGc::NewL(aDevice,*iMainFbsBitGc);	// takes place of iMainFbsBitGc (not passing ownership of context here !)
       
   195 	iMaskFbsBitGc=CFbsBitGc::NewL();	// for the mask bitmap
       
   196 
       
   197 	iMainBmpDevice=CFbsBitmapDevice::NewL(iTargetBitmap);
       
   198 	iMaskBmpDevice=CFbsBitmapDevice::NewL(iTargetMaskBitmap);
       
   199 
       
   200 	iMainFbsBitGc->Activate(iMainBmpDevice);
       
   201 	iMaskFbsBitGc->Activate(iMaskBmpDevice);
       
   202 	}
       
   203 
       
   204 void CSpriteSet::CreateSpriteMember()
       
   205 	{
       
   206 	iSpriteMember.iBitmap=iTargetBitmap;
       
   207 	iSpriteMember.iMaskBitmap=iTargetMaskBitmap;
       
   208 	iSpriteMember.iInvertMask=iFlags&EMaskIsInverted;
       
   209 	iSpriteMember.iInterval=0;
       
   210 	iSpriteMember.iOffset=TPoint(0,0);
       
   211 	}
       
   212 
       
   213 void CSpriteSet::AdjustSpriteSizeAccordingToResizeMode(TSize& aTargetSize, const TSize& aSourceSize, TSpriteResizeMode aSpriteResizeMode) const
       
   214 	{
       
   215 	// following switch statement limits the 'other' dimension from the stretch line
       
   216 	switch(aSpriteResizeMode)
       
   217 		{
       
   218 	case ENoResizing:
       
   219 		{
       
   220 		aTargetSize = aSourceSize;
       
   221 		break;
       
   222 		}
       
   223 	case EResizeHorizToFit:
       
   224 		{
       
   225 		aTargetSize.iHeight = aSourceSize.iHeight;
       
   226 		break;
       
   227 		}
       
   228 	case EResizeVertToFit:
       
   229 		{
       
   230 		aTargetSize.iWidth = aSourceSize.iWidth;
       
   231 		break;
       
   232 		}
       
   233 	case EResizeHorizAndVertToFit:
       
   234 		{
       
   235 		break;
       
   236 		}
       
   237 	default:
       
   238 		Panic(EEgulPanicInvalidSpriteResizeMode);
       
   239 		break;
       
   240 		}
       
   241 	}
       
   242 
       
   243 void CSpriteSet::ComputeInternalResizeMode(TInternalSpriteResizeMode& aInternalSpriteResizeMode, TSpriteResizeMode aSpriteResizeMode, const TSize& aSourceSize, const TSize& aSpriteSize) const
       
   244 	{
       
   245 	switch(aSpriteResizeMode)
       
   246 		{
       
   247 	case ENoResizing:
       
   248 		{
       
   249 		aInternalSpriteResizeMode = EHSameVSame;
       
   250 		break;
       
   251 		}
       
   252 	case EResizeHorizToFit:
       
   253 		{
       
   254 		if(aSpriteSize.iWidth > aSourceSize.iWidth)
       
   255 			aInternalSpriteResizeMode = EHStretchVSame;
       
   256 		else if(aSpriteSize.iWidth < aSourceSize.iWidth)
       
   257 			aInternalSpriteResizeMode = EHShrinkVSame;
       
   258 		else
       
   259 			aInternalSpriteResizeMode = EHSameVSame;
       
   260 		break;
       
   261 		}
       
   262 	case EResizeVertToFit:
       
   263 		{
       
   264 		if(aSpriteSize.iHeight > aSourceSize.iHeight)
       
   265 			aInternalSpriteResizeMode = EHSameVStretch;
       
   266 		else if(aSpriteSize.iHeight < aSourceSize.iHeight)
       
   267 			aInternalSpriteResizeMode = EHSameVShrink;
       
   268 		else
       
   269 			aInternalSpriteResizeMode = EHSameVSame;
       
   270 		break;
       
   271 		}
       
   272 	case EResizeHorizAndVertToFit:
       
   273 		{
       
   274 		if(aSpriteSize.iWidth > aSourceSize.iWidth)
       
   275 			{
       
   276 			if(aSpriteSize.iHeight > aSourceSize.iHeight)
       
   277 				aInternalSpriteResizeMode = EHStretchVStretch;
       
   278 			else if(aSpriteSize.iHeight < aSourceSize.iHeight)
       
   279 				aInternalSpriteResizeMode = EHStretchVShrink;
       
   280 			else
       
   281 				aInternalSpriteResizeMode = EHStretchVSame;
       
   282 			}
       
   283 		else if(aSpriteSize.iWidth < aSourceSize.iWidth)
       
   284 			{
       
   285 			if(aSpriteSize.iHeight > aSourceSize.iHeight)
       
   286 				aInternalSpriteResizeMode = EHShrinkVStretch;
       
   287 			else if(aSpriteSize.iHeight < aSourceSize.iHeight)
       
   288 				aInternalSpriteResizeMode = EHShrinkVShrink;
       
   289 			else
       
   290 				aInternalSpriteResizeMode = EHShrinkVSame;
       
   291 			}
       
   292 		else
       
   293 			{
       
   294 			if(aSpriteSize.iHeight > aSourceSize.iHeight)
       
   295 				aInternalSpriteResizeMode = EHSameVStretch;
       
   296 			else if(aSpriteSize.iHeight < aSourceSize.iHeight)
       
   297 				aInternalSpriteResizeMode = EHSameVShrink;
       
   298 			else
       
   299 				aInternalSpriteResizeMode = EHSameVSame;
       
   300 			}
       
   301 
       
   302 		break;
       
   303 		}
       
   304 	default:
       
   305 		Panic(EEgulPanicInvalidSpriteResizeMode);
       
   306 		break;
       
   307 		}
       
   308 	}
       
   309 
       
   310 void CSpriteSet::RenderSprite(TInt aSpriteType, TInternalSpriteResizeMode aInternalSpriteResizeMode, const TSize& aSourceSize, const TSize& aSpriteSize)
       
   311 	{
       
   312 	const TInt sourceWidth = aSourceSize.iWidth;
       
   313 	const TInt sourceHeight = aSourceSize.iHeight;
       
   314 	const TInt spriteWidth = aSpriteSize.iWidth;
       
   315 	const TInt spriteHeight = aSpriteSize.iHeight;
       
   316 	const TInt numOfHorizAddedLines = spriteHeight-sourceHeight;
       
   317 	const TInt numOfVertAddedLines = spriteWidth-sourceWidth;
       
   318 	const TPoint posZeroZero(0,0);	// cached for repeated use
       
   319 	CGulIcon* spriteSetMember = iSourceMembers[aSpriteType];
       
   320 	CFbsBitmap* bitmapToUse = spriteSetMember->Bitmap();
       
   321 	CFbsBitmap* maskToUse = spriteSetMember->Mask();
       
   322 	TRect fromRect;
       
   323 	TPoint toPoint;
       
   324 
       
   325 	switch(aInternalSpriteResizeMode)
       
   326 		{
       
   327 	case EHSameVSame:
       
   328 		{
       
   329 		fromRect.SetRect(0,0,sourceWidth,sourceHeight);
       
   330 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   331 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   332 		break;
       
   333 		}
       
   334 	case EHSameVShrink:
       
   335 		{
       
   336 		const TInt halfSpriteHeight = spriteHeight/2;
       
   337 		fromRect.SetRect(0,0,spriteWidth,halfSpriteHeight);
       
   338 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   339 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   340 		fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeight%2),sourceWidth,sourceHeight);
       
   341 		toPoint.SetXY(0,halfSpriteHeight);
       
   342 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   343 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   344 		break;
       
   345 		}
       
   346 	case EHSameVStretch:
       
   347 		{
       
   348 		const TInt halfSourceHeight = sourceHeight/2;
       
   349 		fromRect.SetRect(0,0,sourceWidth,halfSourceHeight);
       
   350 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   351 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   352 		fromRect.SetRect(0,halfSourceHeight,sourceWidth,sourceHeight);
       
   353 		toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeight%2));
       
   354 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   355 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   356 		for(TInt i = 0; i < numOfHorizAddedLines;i++)
       
   357 			{
       
   358 			fromRect.SetRect(0,halfSourceHeight,sourceWidth,(halfSourceHeight)+1);
       
   359 			toPoint.SetXY(0,(halfSourceHeight)+i);
       
   360 			iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   361 			iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   362 			}
       
   363 		break;
       
   364 		}
       
   365 	case EHShrinkVSame:
       
   366 		{
       
   367 		const TInt halfSpriteWidth = spriteWidth/2;
       
   368 		fromRect.SetRect(0,0,halfSpriteWidth,spriteHeight);
       
   369 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   370 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   371 		fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidth%2),0,sourceWidth,sourceHeight);
       
   372 		toPoint.SetXY(halfSpriteWidth,0);
       
   373 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   374 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   375 		break;
       
   376 		}
       
   377 	case EHShrinkVShrink:
       
   378 		{
       
   379 		const TInt halfSpriteWidth = spriteWidth/2;
       
   380 		const TInt halfSpriteHeight = spriteHeight/2;
       
   381 		const TInt spriteHeightModTwo = spriteHeight%2;
       
   382 		const TInt spriteWidthModTwo = spriteWidth%2;
       
   383 		fromRect.SetRect(0,0,halfSpriteWidth,halfSpriteHeight);
       
   384 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   385 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   386 		fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),0,sourceWidth,halfSpriteHeight);
       
   387 		toPoint.SetXY(halfSpriteWidth,0);
       
   388 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   389 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   390 		fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),halfSpriteWidth,sourceHeight);
       
   391 		toPoint.SetXY(0,halfSpriteHeight);
       
   392 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   393 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   394 		fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),sourceWidth,sourceHeight);
       
   395 		toPoint.SetXY(halfSpriteWidth,halfSpriteHeight);
       
   396 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   397 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   398 		break;
       
   399 		}
       
   400 	case EHShrinkVStretch:
       
   401 		{
       
   402 		const TInt halfSourceHeight = sourceHeight/2;
       
   403 		const TInt halfSpriteWidth = spriteWidth/2;
       
   404 		const TInt sourceHeightModTwo = sourceHeight%2;
       
   405 		const TInt spriteWidthModTwo = spriteWidth%2;
       
   406 		fromRect.SetRect(0,0,halfSpriteWidth,halfSourceHeight);	
       
   407 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   408 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   409 		fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),0,sourceWidth,halfSourceHeight);
       
   410 		toPoint.SetXY(halfSpriteWidth,0);
       
   411 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   412 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   413 		fromRect.SetRect(0,sourceHeight - (halfSourceHeight) - (sourceHeightModTwo),halfSpriteWidth,sourceHeight);
       
   414 		toPoint.SetXY(0,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo));
       
   415 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   416 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   417 		fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),sourceHeight - (halfSourceHeight) - (sourceHeightModTwo),sourceWidth,sourceHeight);
       
   418 		toPoint.SetXY(halfSpriteWidth,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo));
       
   419 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   420 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   421 		for(TInt j = 0; j < numOfHorizAddedLines;j++)
       
   422 			{
       
   423 			fromRect.SetRect(0,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo),spriteWidth,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo)+1);
       
   424 			toPoint.SetXY(0,(halfSourceHeight)+j);
       
   425 			iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   426 			iMaskFbsBitGc->BitBlt(toPoint,iTargetMaskBitmap,fromRect);
       
   427 			}
       
   428 		break;
       
   429 		}
       
   430 	case EHStretchVSame:
       
   431 		{
       
   432 		const TInt halfSourceWidth = sourceWidth/2;
       
   433 		fromRect.SetRect(0,0,halfSourceWidth,sourceHeight);
       
   434 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   435 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   436 		fromRect.SetRect(halfSourceWidth,0,sourceWidth,sourceHeight);
       
   437 		toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidth%2),0);
       
   438 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   439 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   440 		for(TInt i = 0; i < numOfVertAddedLines;i++)
       
   441 			{
       
   442 			fromRect.SetRect(halfSourceWidth,0,(halfSourceWidth)+1,sourceHeight);
       
   443 			toPoint.SetXY((halfSourceWidth)+i,0);
       
   444 			iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   445 			iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   446 			}
       
   447 		break;
       
   448 		}
       
   449 	case EHStretchVShrink:
       
   450 		{
       
   451 		const TInt halfSourceWidth = sourceWidth/2;
       
   452 		const TInt halfSpriteHeight = spriteHeight/2;
       
   453 		const TInt sourceWidthModTwo = sourceWidth%2;
       
   454 		const TInt spriteHeightModTwo = spriteHeight%2;
       
   455 		fromRect.SetRect(0,0,halfSourceWidth,halfSpriteHeight);
       
   456 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   457 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   458 		fromRect.SetRect(sourceWidth - (halfSourceWidth) - (sourceWidthModTwo),0,sourceWidth,halfSpriteHeight);
       
   459 		toPoint.SetXY(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),0);
       
   460 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   461 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   462 		fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),halfSourceWidth,sourceHeight);
       
   463 		toPoint.SetXY(0,halfSpriteHeight);
       
   464 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   465 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   466 		fromRect.SetRect(sourceWidth - (halfSourceWidth) - (sourceWidthModTwo),sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),sourceWidth,sourceHeight);
       
   467 		toPoint.SetXY(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),halfSpriteHeight);
       
   468 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   469 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   470 		for(TInt j = 0; j < numOfVertAddedLines;j++)
       
   471 			{
       
   472 			fromRect.SetRect(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),0,spriteWidth - (halfSourceWidth) - (sourceWidthModTwo)+1,spriteHeight);
       
   473 			toPoint.SetXY((halfSourceWidth)+j,0);
       
   474 			iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   475 			iMaskFbsBitGc->BitBlt(toPoint,iTargetMaskBitmap,fromRect);
       
   476 			}
       
   477 		break;
       
   478 		}
       
   479 	case EHStretchVStretch:
       
   480 		{
       
   481 		const TInt halfSourceWidth = sourceWidth/2;
       
   482 		const TInt halfSourceHeight = sourceHeight/2;
       
   483 		const TInt sourceWidthModTwo = sourceWidth%2;
       
   484 		const TInt sourceHeightModTwo = sourceHeight%2;
       
   485 		fromRect.SetRect(0,0,halfSourceWidth,halfSourceHeight);
       
   486 		iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   487 		iMainFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect);
       
   488 		fromRect.SetRect(0,halfSourceHeight,halfSourceWidth,sourceHeight);
       
   489 		toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo));
       
   490 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   491 		iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   492 		fromRect.SetRect(halfSourceWidth,0,sourceWidth,halfSourceHeight);
       
   493 		toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0);
       
   494 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   495 		iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   496 		fromRect.SetRect(halfSourceWidth,halfSourceHeight,sourceWidth,sourceHeight);
       
   497 		toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),spriteHeight-(halfSourceHeight)-(sourceHeightModTwo));
       
   498 		iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   499 		iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect);
       
   500 		for(TInt h = 0; h < numOfVertAddedLines;h++)
       
   501 			{
       
   502 			fromRect.SetRect(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0,spriteWidth-(halfSourceWidth)-(sourceWidthModTwo)+1,spriteHeight);
       
   503 			toPoint.SetXY((halfSourceWidth)+h,0);
       
   504 			iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   505 			iMaskFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   506 			}
       
   507 		for(TInt m = 0; m < numOfHorizAddedLines;m++)
       
   508 			{
       
   509 			fromRect.SetRect(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo),spriteWidth,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)+1);
       
   510 			toPoint.SetXY(0,(halfSourceHeight)+m);
       
   511 			iMaskFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   512 			}
       
   513 		fromRect.SetRect(0,0,halfSourceWidth,halfSourceHeight);
       
   514 		iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect);
       
   515 		fromRect.SetRect(0,halfSourceHeight,halfSourceWidth,sourceHeight);
       
   516 		toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo));
       
   517 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   518 		fromRect.SetRect(halfSourceWidth,0,sourceWidth,halfSourceHeight);
       
   519 		toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0);
       
   520 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   521 		fromRect.SetRect(halfSourceWidth,halfSourceHeight,sourceWidth,sourceHeight);
       
   522 		toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),spriteHeight-(halfSourceHeight)-(sourceHeightModTwo));
       
   523 		iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect);
       
   524 		for(TInt j = 0; j < numOfVertAddedLines;j++)
       
   525 			{
       
   526 			fromRect.SetRect(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0,spriteWidth-(halfSourceWidth)-(sourceWidthModTwo)+1,spriteHeight);
       
   527 			toPoint.SetXY((halfSourceWidth)+j,0);
       
   528 			iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   529 			}
       
   530 		for(TInt i = 0; i < numOfHorizAddedLines;i++)
       
   531 			{
       
   532 			fromRect.SetRect(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo),spriteWidth,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)+1);
       
   533 			toPoint.SetXY(0,(halfSourceHeight)+i);
       
   534 			iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect);
       
   535 			}
       
   536 		break;
       
   537 		}
       
   538 	default:
       
   539 		Panic(EEgulPanicInvalidInternalSpriteResizeMode);
       
   540 		break;
       
   541 		}
       
   542 	}