Ejemplo n.º 1
0
void TDrawer::DrawTitleBackground(CWsBitmap* aBackUpBitmap, CWsBitmap* aResourceBitmap)
{
    TRect resourceRect = ipBitMapPosition->GetPosition(TBitMapPosition::EGameTitle, 0);
    TBitmapUtil objectUtil(aResourceBitmap);
    TBitmapUtil backUpUtil(aBackUpBitmap);
    //
    objectUtil.Begin(TPoint(0, 0));
    backUpUtil.Begin(TPoint(0, 0));
    R8G8B8* addr1 = (R8G8B8*) aResourceBitmap->DataAddress();// 对象
    R8G8B8* addr2 = (R8G8B8*) aBackUpBitmap->DataAddress();// 背景
    TSize desSize = aBackUpBitmap->SizeInPixels();
    TSize sourceSize;
    sourceSize.SetSize(resourceRect.iBr.iX - resourceRect.iTl.iX + 1, resourceRect.iBr.iY - resourceRect.iTl.iY + 1);
    TSize srcSize = aResourceBitmap->SizeInPixels();
    R8G8B8* addr22;
    R8G8B8* addr11;
    //TInt iCounts = desSize.iWidth * sourceSize.iWidth;
    TInt iWidthSpan = srcSize.iWidth - sourceSize.iWidth;
    addr22 = addr2;
    addr11 = addr1 + resourceRect.iTl.iY * srcSize.iWidth + resourceRect.iTl.iX;
    for (TInt j = 0; j < sourceSize.iHeight; j++)
    {
        for (TInt i = 0; i < desSize.iWidth; i++)
        {
            *addr22 = *addr11;
            addr22++;
            addr11++;
        }
        addr11 = addr11 + iWidthSpan;
    }
    backUpUtil.End();
    objectUtil.End();
}
Ejemplo n.º 2
0
/** Gets the character metrics and the glyph bitmap. 
@param aCode The character code in Unicode. 
@param aMetrics On return, contains the character metrics. 
@param aBitmap On return, contains a pointer to the compressed glyph bitmap. 
@param aBitmapSize The size of the returned glyph bitmap in pixels. This is 
not necessarily the same as the size implied by the returned metrics, which 
may incorporate algorithmic multiplication. 
@publishedAll 
@released
*/
EXPORT_C CFont::TCharacterDataAvailability CFbsFont::DoGetCharacterData(TUint aCode,TOpenFontCharMetrics& aMetrics,
		const TUint8*& aBitmap,TSize& aBitmapSize) const
	{
	aBitmap = NULL;
	if (!iHandle)
		return CFont::ENoCharacterData;

	CBitmapFont* bitmap_font = Address();

	if (!bitmap_font->GetCharacterData(iFbs->ServerSessionHandle(),aCode,aMetrics,aBitmap))
		{
		TPckgBuf<TRasterizeParams> paramsBuf;
		TIpcArgs args(iHandle, aCode, &paramsBuf);
		
		if(iFbs->SendCommand(EFbsMessRasterize, args))
			{				
			// Translate the offsets sent to the server back to pointers relative to
			// the heap base of the current process
			const TOpenFontCharMetrics* metrics = (const TOpenFontCharMetrics*)OffsetToPointer(paramsBuf().iMetricsOffset, iFbs->HeapBase());
			if (metrics)
				{
				aMetrics = *metrics;
				}
			aBitmap = static_cast<TUint8*>(OffsetToPointer(paramsBuf().iBitmapPointerOffset, iFbs->HeapBase()));			
			}
		else
			{
			return CFont::ENoCharacterData;
			}
		}

	aBitmapSize.SetSize(aMetrics.Width(),aMetrics.Height());

	if (!bitmap_font->IsOpenFont())
		{
		TAlgStyle null_style;
		if (!(bitmap_font->iAlgStyle == null_style))
			{
			const int width_factor = bitmap_font->iAlgStyle.WidthFactor();
			const int height_factor = bitmap_font->iAlgStyle.HeightFactor();
			const int bold_addition =	bitmap_font->iAlgStyle.IsBold() ? width_factor : 0;
			const int italic_addition = bitmap_font->iAlgStyle.IsItalic() ? width_factor : 0;

			aMetrics.SetWidth(aMetrics.Width() * width_factor + bold_addition + italic_addition);
			aMetrics.SetHeight(aMetrics.Height() * height_factor);
			aMetrics.SetHorizBearingX(aMetrics.HorizBearingX() * width_factor);
			aMetrics.SetHorizBearingY(aMetrics.HorizBearingY() * height_factor);
			aMetrics.SetVertBearingX(aMetrics.VertBearingX() * width_factor);
			aMetrics.SetVertBearingY(aMetrics.VertBearingY() * height_factor);
			if (bitmap_font->iAlgStyle.IsMono())
				aMetrics.SetHorizAdvance(bitmap_font->CBitmapFont::DoMaxNormalCharWidthInPixels() + bold_addition);
			else
				aMetrics.SetHorizAdvance(aMetrics.HorizAdvance() * width_factor + bold_addition);
			aMetrics.SetVertAdvance(aMetrics.VertAdvance() * height_factor);
			}
		}
	return CFont::EAllCharacterData;
	}
Ejemplo n.º 3
0
//Gets the Size dimension the RWindow is using as per orientation
TSize RWindows::GetOrientedSize()
	{
	TSize orientedSize;
	if (iOrientation&1)
	orientedSize.SetSize(iEpocBitmapSize.iHeight,iEpocBitmapSize.iWidth);
	else
	orientedSize = iEpocBitmapSize;

	return orientedSize;
	}
Ejemplo n.º 4
0
void CSupImageHandler::LoadFileL(const TFileName& aFileName, TInt aSelectedFrame)
	{
	__ASSERT_ALWAYS(!IsActive(),User::Invariant());
	// create a CImageDecoder to read the specified file
	delete iLoadUtil;
	iLoadUtil = NULL;
	iLoadUtil = CImageDecoder::FileNewL(iFs, aFileName);
	// store the frame information and frame count
	iFrameInfo = iLoadUtil->FrameInfo(aSelectedFrame);
	iFrameCount = iLoadUtil->FrameCount();

	// resize the destination bitmap to fit the required size
	//TRect bitmapSize = iFrameInfo.iFrameCoordsInPixels;

	TSize bitmapSize = iFrameInfo.iOverallSizeInPixels;

	// Calculate scale factor,
	// if required
	if (bitmapSize.iWidth > KImageWidthThreshold || bitmapSize.iHeight > KImageHeightThreshold)
	{
		TUint hScaleFactor = bitmapSize.iWidth/KImageWidthThreshold;
		TUint vScaleFactor = bitmapSize.iHeight/KImageHeightThreshold;
		// apply the same scale factor to both horizontal and vertical
		TUint scaleFactor = 1;
		if (hScaleFactor <= vScaleFactor)
			scaleFactor = hScaleFactor;
		else
			scaleFactor = vScaleFactor;

		if (scaleFactor >= 4)
			scaleFactor = 4;
		else if (scaleFactor >= 2)
			scaleFactor = 2;
		else
			scaleFactor = 1;

		// we need a correction pixel on each coordinate if the size is not divisible with scale factor; the
		// decoder will not work otherwise
		TUint hCorrection = 0;
		if (bitmapSize.iWidth % scaleFactor)
			hCorrection = 1;
		TUint vCorrection = 0;
		if (bitmapSize.iHeight % scaleFactor)
			vCorrection = 1;
		// the magic formula for calculating the final size
		bitmapSize.SetSize(bitmapSize.iWidth/scaleFactor + hCorrection, bitmapSize.iHeight/scaleFactor + vCorrection);

	}

	//iBitmap.Resize(bitmapSize.Size());
	iBitmap.Resize(bitmapSize);
	// start reading the bitmap: RunL called when complete
	iLoadUtil->Convert(&iStatus, iBitmap, aSelectedFrame);
	SetActive();
	}
Ejemplo n.º 5
0
TBool CDataWrapperBase::GetSizeFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TSize& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;

	TInt	width;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagSizeWidth);
	TBool	ret=GetIntFromConfig(aSectName, tempStore, width);

	TInt	height;
	tempStore.Format(KFormatEntryField, &aKeyName, &KTagSizeHeight);
	if ( !GetIntFromConfig(aSectName, tempStore, height) )
		{
		ret=EFalse;
		}

	if ( ret )
		{
		aResult.SetSize(width, height);
		}

	return ret;
	}
Ejemplo n.º 6
0
void TDrawer::DrawLifeValue(CWsBitmap* aBackUpBitmap, CWsBitmap* aResourceBitmap, TInt aLifeValue)
{
    if (aLifeValue < 1)
    {
        return;
    }
    //
    TRect srcRect = ipBitMapPosition->GetPosition(TBitMapPosition::ELifeValue, aLifeValue - 1);
    TBitmapUtil objectUtil(aResourceBitmap);
    TBitmapUtil backUpUtil(aBackUpBitmap);
    objectUtil.Begin(TPoint(0, 0));
    backUpUtil.Begin(TPoint(0, 0));
    R8G8B8* addr1 = (R8G8B8*) aResourceBitmap->DataAddress();// 对象
    R8G8B8* addr2 = (R8G8B8*) aBackUpBitmap->DataAddress();// 背景
    TSize desSize = aBackUpBitmap->SizeInPixels();
    TSize srcSize = aResourceBitmap->SizeInPixels();
    TSize elementSize;
    elementSize.SetSize(srcRect.iBr.iX - srcRect.iTl.iX + 1, srcRect.iBr.iY - srcRect.iTl.iY + 1);
    R8G8B8* addr22;
    R8G8B8* addr11;
    //TInt iCounts = desSize.iWidth * sourceSize.iWidth;
    TInt iWidthSpanSrc = srcSize.iWidth - elementSize.iWidth;
    TInt iWidthSpanDes = desSize.iWidth - elementSize.iWidth;
    addr22 = addr2 + desSize.iWidth * LIFE_BEGIN_Y + LIFE_BEGIN_X;
    addr11 = addr1 + srcRect.iTl.iY * srcSize.iWidth + srcRect.iTl.iX;
    for (TInt j = 0; j < elementSize.iHeight; j++)
    {
        for (TInt i = 0; i < elementSize.iWidth; i++)
        {
            *addr22 = *addr11;
            addr22++;
            addr11++;
        }
        addr11 = addr11 + iWidthSpanSrc;
        addr22 = addr22 + iWidthSpanDes;
    }
    backUpUtil.End();
    objectUtil.End();
}