sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "SCDRAW.H" sl@0: #include "_WININC.H" sl@0: sl@0: TInt CDrawTwelveBppScreenBitmap::InitScreen() sl@0: { sl@0: TRect drawRect; sl@0: GetDrawRect(drawRect); sl@0: RWindows* window = ::WindowHandler(iScreenNo); sl@0: window->iDisplayMode = DisplayMode(); sl@0: window->iEpocBitmapSize = drawRect.Size(); sl@0: window->iEpocBitmapLinePitch = (iScanLineWords*4); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: TBool CDrawTwelveBppScreenBitmap::SetOrientation(TOrientation aOrientation) sl@0: { sl@0: if (aOrientation == iEmulatorOrientation) sl@0: return ETrue; sl@0: sl@0: SetScreenOrientation(aOrientation); sl@0: iEmulatorOrientation = aOrientation; sl@0: iOrientation = aOrientation ; sl@0: return ETrue; sl@0: } sl@0: sl@0: void CDrawTwelveBppScreenBitmap::UpdateRect(const TRect& aRect) const sl@0: { sl@0: ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0); sl@0: #if defined(_DEBUG) sl@0: if (iOrientation&1) sl@0: { sl@0: ASSERT(aRect.iBr.iX <= iSize.iHeight); sl@0: ASSERT(aRect.iBr.iY <= iSize.iWidth); sl@0: } sl@0: else sl@0: { sl@0: ASSERT(aRect.iBr.iX <= iSize.iWidth); sl@0: ASSERT(aRect.iBr.iY <= iSize.iHeight); sl@0: } sl@0: #endif sl@0: TInt scanLineLen=iLongWidth; sl@0: TInt srcPixelStep=1; sl@0: TPoint srcStart(aRect.iTl); sl@0: switch(iOrientation) sl@0: { sl@0: case CFbsDrawDevice::EOrientationRotated90: sl@0: srcPixelStep=scanLineLen; sl@0: scanLineLen=-1; sl@0: srcStart.iX=iSize.iWidth-1-aRect.iTl.iY; sl@0: srcStart.iY=aRect.iTl.iX; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated180: sl@0: srcPixelStep=-1; sl@0: scanLineLen=-scanLineLen; sl@0: srcStart.iX=iSize.iWidth-1-aRect.iTl.iX; sl@0: srcStart.iY=iSize.iHeight-1-aRect.iTl.iY; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated270: sl@0: srcPixelStep=-scanLineLen; sl@0: scanLineLen=1; sl@0: srcStart.iX=aRect.iTl.iY; sl@0: srcStart.iY=iSize.iHeight-1-aRect.iTl.iX; sl@0: break; sl@0: } sl@0: TUint16* srcePtr = CDrawSixteenBppBitmapCommon::PixelAddress(srcStart.iX,srcStart.iY); sl@0: TUint16* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep; sl@0: TInt rowMax = aRect.iTl.iY+aRect.Height(); sl@0: for(TInt row = aRect.iTl.iY; row < rowMax; row++) sl@0: { sl@0: TUint16* tempSrcePtr = srcePtr; sl@0: TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row); sl@0: sl@0: while (tempSrcePtr != srcePtrLimit) sl@0: { sl@0: destPixel[0] = TUint8((*tempSrcePtr & 0x00f)); sl@0: destPixel[0] |= destPixel[0] << 4; sl@0: destPixel[1] = TUint8((*tempSrcePtr & 0x0f0)); sl@0: destPixel[1] |= destPixel[1] >> 4; sl@0: destPixel[2] = TUint8((*tempSrcePtr & 0xf00)>>4); sl@0: destPixel[2] |= destPixel[2] >> 4; sl@0: sl@0: tempSrcePtr+=srcPixelStep; sl@0: sl@0: destPixel += 3; sl@0: } sl@0: sl@0: srcePtr += scanLineLen; sl@0: srcePtrLimit += scanLineLen; sl@0: } sl@0: } sl@0: