|
1 // Copyright (c) 2002-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 // BitmapScaling.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "BitmapTransformsBody.h" |
|
19 #include "BitmapTransformsMain.h" |
|
20 #include "BitmapTransforms.h" |
|
21 #include <bitmtrans/bitmtransplugin.h> |
|
22 #include <bitmtrans/bitmtransuids.hrh> |
|
23 |
|
24 #include <ecom/ecom.h> |
|
25 #include <mm/mmpluginutils.h> |
|
26 |
|
27 /* |
|
28 *The function NewL constructs a CBitmapScalerBody |
|
29 * |
|
30 *@return CBitmapScalerBody* |
|
31 */ |
|
32 CBitmapScalerBody* CBitmapScalerBody::NewL() |
|
33 { |
|
34 CBitmapScalerBody* self = new(ELeave) CBitmapScalerBody(); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop(self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 /* |
|
42 * |
|
43 *CBitmapScalerBody() |
|
44 *Constructor for this class. |
|
45 */ |
|
46 CBitmapScalerBody::CBitmapScalerBody() |
|
47 { |
|
48 } |
|
49 |
|
50 /* |
|
51 * |
|
52 *ConstructL() |
|
53 *Performs second phase of construction. |
|
54 */ |
|
55 void CBitmapScalerBody::ConstructL() |
|
56 { |
|
57 TUid interfaceUid = {KUidBitmapScalerPlugin}; |
|
58 iPlugin = |
|
59 static_cast<MBitmapScalerPlugin*> |
|
60 (MmPluginUtils::CreateImplementationL(interfaceUid, iDestructorKey, KBitmTransPluginMatchString, KRomOnlyResolverUid)); |
|
61 } |
|
62 |
|
63 |
|
64 /* |
|
65 * |
|
66 *~CBitmapScalerBody |
|
67 *This is the destructor for the CBitmapScalerBody |
|
68 *and is resposible for deallocating all resources |
|
69 *allocated by the CBitmapScalerBody. |
|
70 */ |
|
71 CBitmapScalerBody::~CBitmapScalerBody() |
|
72 { |
|
73 delete iPlugin; |
|
74 REComSession::DestroyedImplementation(iDestructorKey); |
|
75 REComSession::FinalClose(); |
|
76 } |
|
77 |
|
78 /* |
|
79 * |
|
80 * Begins the bitmap re-scaling operation. |
|
81 * |
|
82 * The scaling factor is based on the relative sizes of the source |
|
83 * and target bitmaps. The operation is asynchronous. When it is |
|
84 * complete, successfully or otherwise, the TRequestStatus & |
|
85 * aStatus is set, passing the state of the operation. |
|
86 * |
|
87 * @param TRequestStatus* aRequestStatus |
|
88 * |
|
89 * @param "CFbsBitmap& aSrcBitmap" |
|
90 * The bitmap to be re-scaled. |
|
91 * @param "CFbsBitmap& aTgtBitmap" |
|
92 * The target location for the re-scaled bitmap. |
|
93 * @param "TBool aMaintainAspectRatio = ETrue" |
|
94 * ETrue - the aspect ratio is retained; |
|
95 * this is the default. The same scaling factor is |
|
96 * applied in both the horizontal and vertical |
|
97 * directions. This is the smaller of the horizontal |
|
98 * scaling factor and the vertical scaling factor. |
|
99 * EFalse - the aspect ratio need not be |
|
100 * retained. |
|
101 * |
|
102 * |
|
103 */ |
|
104 void CBitmapScalerBody::Scale(TRequestStatus* aRequestStatus, |
|
105 CFbsBitmap& aSrcBitmap, |
|
106 CFbsBitmap& aTgtBitmap, |
|
107 TBool aMaintainAspectRatio) |
|
108 { |
|
109 iPlugin->Scale(aRequestStatus, aSrcBitmap, aTgtBitmap, aMaintainAspectRatio); |
|
110 } |
|
111 |
|
112 /* |
|
113 * |
|
114 * CustomCommand |
|
115 * @param aUid |
|
116 * @param aParam |
|
117 * @return 'TInt' an error code indicating success or failure of the |
|
118 * command |
|
119 * |
|
120 */ |
|
121 TInt CBitmapScalerBody::CustomCommand(TUid aUid, TAny* aParam) |
|
122 { |
|
123 return iPlugin->CustomCommand(aUid, aParam); |
|
124 } |