|
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 // |
|
15 |
|
16 #include "BitmapTransforms.h" |
|
17 #include "BitmapTransformsMain.h" |
|
18 #include "BitmapTransformsBody.h" |
|
19 |
|
20 /** |
|
21 Constructs a CBitmapScaler object. |
|
22 |
|
23 @return A pointer to a CBitmapScaler object. |
|
24 */ |
|
25 EXPORT_C CBitmapScaler* CBitmapScaler::NewL() |
|
26 { |
|
27 CBitmapScaler* self = new(ELeave) CBitmapScaler(); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(); |
|
31 return self; |
|
32 } |
|
33 |
|
34 /* |
|
35 @internalTechnology |
|
36 |
|
37 Constructor for this class. |
|
38 */ |
|
39 |
|
40 CBitmapScaler::CBitmapScaler() |
|
41 { |
|
42 } |
|
43 |
|
44 /** |
|
45 @internalTechnology |
|
46 |
|
47 Performs second phase of contruction |
|
48 */ |
|
49 |
|
50 void CBitmapScaler::ConstructL() |
|
51 { |
|
52 iBody = CBitmapScalerBody::NewL(); |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 This is the destructor for the CBitmapScaler |
|
58 and is responsible for deallocating all resources |
|
59 alloctaed by the CBitmapScaler. |
|
60 */ |
|
61 |
|
62 EXPORT_C CBitmapScaler::~CBitmapScaler() |
|
63 { |
|
64 Cancel(); |
|
65 delete iBody; |
|
66 } |
|
67 |
|
68 /** |
|
69 Cancel any outstanding activity. |
|
70 */ |
|
71 |
|
72 EXPORT_C void CBitmapScaler::Cancel() |
|
73 { |
|
74 if (iBody) |
|
75 iBody->Cancel(); |
|
76 } |
|
77 |
|
78 /** |
|
79 Begins the bitmap re-scaling operation. |
|
80 |
|
81 The scaling factor is based on the relative sizes of the source |
|
82 and target bitmaps. The operation is asynchronous. KErrOverFlow status is |
|
83 set if the sizes of input bitmaps are too large for the algorithm to handle. |
|
84 |
|
85 @post |
|
86 The result of the operation is pointed to by aRequestStatus. |
|
87 |
|
88 @param aRequestStatus |
|
89 On return, contains a pointer to the completion status of the rescale of the bitmap. |
|
90 @param aSrcBitmap |
|
91 The bitmap to be re-scaled. |
|
92 @param aTgtBitmap |
|
93 The target location for the re-scaled bitmap. |
|
94 @param aMaintainAspectRatio |
|
95 A boolean indicating if the aspect ratio is maintained. ETrue means the aspect ratio is |
|
96 retained; this is the default. The same scaling factor is applied in both the horizontal |
|
97 and vertical directions. This is the smaller of the horizontal scaling factor and the |
|
98 vertical scaling factor. EFalse means the aspect ratio need not be retained. |
|
99 */ |
|
100 EXPORT_C void CBitmapScaler::Scale(TRequestStatus* aRequestStatus, CFbsBitmap& aSrcBitmap, CFbsBitmap& aTgtBitmap, TBool aMaintainAspectRatio) |
|
101 { |
|
102 ASSERT(iBody); |
|
103 iBody->Scale(aRequestStatus, aSrcBitmap, aTgtBitmap, aMaintainAspectRatio); |
|
104 } |
|
105 |
|
106 /** |
|
107 Begins the bitmap re-scaling operation. |
|
108 |
|
109 The scaling factor is based on the relative value of the source bitmap |
|
110 size and the explicitly supplied size. The operation is asynchronous. |
|
111 When it is complete, successfully or otherwise, the |
|
112 TRequestStatus is set, passing the state of the operation. KErrOverFlow status is set |
|
113 if the sizes of input bitmaps are too large for the algorithm to handle. |
|
114 @param aRequestStatus |
|
115 On return, contains a pointer to the completion status of the rescale of the bitmap. |
|
116 @param aBitmap |
|
117 The bitmap to be re-scaled. This reference is also the |
|
118 target location for the re-scaled bitmap. |
|
119 @param aDestinationSize |
|
120 The requested target size for the re-scaled bitmap. |
|
121 @param aMaintainAspectRatio |
|
122 A boolean indicating if the aspect ratio is maintained. ETrue means the aspect ratio is |
|
123 retained; this is the default. The same scaling factor is applied in both the horizontal |
|
124 and vertical directions. This is the smaller of the horizontal scaling factor and the |
|
125 vertical scaling factor. EFalse means the aspect ratio need not be retained. |
|
126 */ |
|
127 EXPORT_C void CBitmapScaler::Scale(TRequestStatus* aRequestStatus, CFbsBitmap& aBitmap, const TSize& aDestinationSize, TBool aMaintainAspectRatio) |
|
128 { |
|
129 ASSERT(iBody); |
|
130 iBody->Scale(aRequestStatus, aBitmap, aDestinationSize, aMaintainAspectRatio); |
|
131 } |
|
132 |
|
133 /** |
|
134 Provides custom command capabilties on CBitmapScaler. The command is dispatched on aUid and if |
|
135 the command is not known KErrNotSupported will be returned. This function is synchronous. |
|
136 |
|
137 The Default implementation will support one command |
|
138 to enable and disable post processing on the scale operation |
|
139 The uid of this command is published in the header file. |
|
140 Changes to the status of Post Processing Enabled will become |
|
141 effective only after an exising scaling operation has completed. |
|
142 |
|
143 @pre |
|
144 When a command requires parameters aParam is not NULL. |
|
145 |
|
146 @param aUid |
|
147 The ID of the command. |
|
148 @param aParam |
|
149 The command specific information. |
|
150 */ |
|
151 EXPORT_C TInt CBitmapScaler::CustomCommand(TUid aUid, TAny* aParam) |
|
152 { |
|
153 ASSERT(iBody); |
|
154 return iBody->CustomCommand( aUid, aParam ); |
|
155 } |
|
156 |