sl@0: // Copyright (c) 2007-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 "directgdiimageref.h" sl@0: #include sl@0: sl@0: CDirectGdiImageRef::CDirectGdiImageRef() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Second phase construction. If the object has not been opened before, sl@0: the passed RSgImage handle is shared with the member RSgImage and the size of the sl@0: shared RSgImage is stored. sl@0: sl@0: @return KErrNone if successful, otherwise an error from RSgDrawable::Open() or sl@0: RSgImage::GetInfo() sl@0: */ sl@0: TInt CDirectGdiImageRef::Construct(const RSgImage& aSgImage) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: // Share the passed RSgImage handle with our own RSgImage sl@0: err = iSgImage.Open(aSgImage.Id(), ESgDoNotRestrictUsage); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: // Save our image size, only need to do this the first time we are created sl@0: TSgImageInfo info; sl@0: err = iSgImage.GetInfo(info); sl@0: if (err == KErrNone) sl@0: { sl@0: iImageSize = info.iSizeInPixels; sl@0: iImagePixelFormat = info.iPixelFormat; sl@0: iSgImageOpen = ETrue; sl@0: } sl@0: else sl@0: { sl@0: iSgImage.Close(); sl@0: } sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: Destructor, close the RSgImage being held open if it had been opened it successfully. sl@0: */ sl@0: CDirectGdiImageRef::~CDirectGdiImageRef() sl@0: { sl@0: if (iSgImageOpen) sl@0: { sl@0: iSgImage.Close(); sl@0: } sl@0: }