|
1 /* |
|
2 * Name : IconLoader.cpp |
|
3 * Description : |
|
4 * Project : This file is part of OpenMAR, an Open Mobile Augmented Reality browser |
|
5 * Website : http://OpenMAR.org |
|
6 * |
|
7 * Copyright (c) 2010 David Caabeiro |
|
8 * |
|
9 * All rights reserved. This program and the accompanying materials are made available |
|
10 * under the terms of the Eclipse Public License v1.0 which accompanies this |
|
11 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html |
|
12 * |
|
13 */ |
|
14 |
|
15 #include "IconLoader.h" |
|
16 |
|
17 #include <AknIconUtils.h> |
|
18 #include <GulIcon.h> |
|
19 |
|
20 CGulIcon* CreateIconL(const TDesC& aIconFile, TInt aBitmapId, TInt aMaskId, const TSize& aSize) |
|
21 { |
|
22 CFbsBitmap* bitmap = 0; |
|
23 CFbsBitmap* mask = 0; |
|
24 |
|
25 AknIconUtils::CreateIconL(bitmap, mask, aIconFile, aBitmapId, aMaskId); |
|
26 |
|
27 AknIconUtils::PreserveIconData(bitmap); |
|
28 |
|
29 TSize size; |
|
30 |
|
31 if (aSize.iHeight == -1 || aSize.iWidth == -1) |
|
32 AknIconUtils::GetContentDimensions(bitmap, size); |
|
33 else |
|
34 size = aSize; |
|
35 |
|
36 AknIconUtils::SetSize(bitmap, size, EAspectRatioPreserved); |
|
37 AknIconUtils::SetSize(mask, size, EAspectRatioPreserved); |
|
38 |
|
39 AknIconUtils::DestroyIconData(bitmap); |
|
40 |
|
41 CleanupStack::PushL(bitmap); |
|
42 CleanupStack::PushL(mask); |
|
43 |
|
44 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
45 |
|
46 CleanupStack::Pop(2, bitmap); |
|
47 |
|
48 return icon; |
|
49 } |