90 Displayable window. |
93 Displayable window. |
91 @param aScreenRect |
94 @param aScreenRect |
92 Portion of the screen to which view finder data is to be |
95 Portion of the screen to which view finder data is to be |
93 transferred. This is in screen co-ordinates and may be modified if, for example, |
96 transferred. This is in screen co-ordinates and may be modified if, for example, |
94 the camera requires the destination to have a certain byte alignment. |
97 the camera requires the destination to have a certain byte alignment. |
95 */ |
98 @leave KErrGeneral Init error. |
96 void CWebCameraVfActive::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect, TRect& aClipRect) |
99 */ |
97 { |
100 void CWebCameraVfActive::StartViewFinderDirectL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow, TRect& aScreenRect, TRect& aClipRect, TUint8* aChunkBase, TInt& aChunkSize) |
|
101 { |
|
102 |
98 iScreenRect = aScreenRect; |
103 iScreenRect = aScreenRect; |
99 iClipRect = aClipRect; |
104 iClipRect = aClipRect; |
100 |
105 iChuckBase = aChunkBase; |
|
106 |
101 // create buffer for view finder data |
107 // create buffer for view finder data |
102 iVfBuf = HBufC8::NewL(KMaxBufSize); |
108 iVfBuf = HBufC8::NewL(KMaxBufSize); |
103 |
109 |
104 // create DirectScreenAccess |
110 // create DirectScreenAccess |
105 delete iDSA; |
111 delete iDSA; |
106 iDSA = NULL; |
112 iDSA = NULL; |
107 iViewFinderActive = EFalse; |
113 iViewFinderActive = EFalse; |
108 iDSA = CDirectScreenAccess::NewL(aWs, aScreenDevice, aWindow, *this); |
114 iDSA = CDirectScreenAccess::NewL(aWs, aScreenDevice, aWindow, *this); |
113 if (!iClipRect.IsEmpty()) |
119 if (!iClipRect.IsEmpty()) |
114 { |
120 { |
115 iDSA->Gc()->SetClippingRect(iClipRect); |
121 iDSA->Gc()->SetClippingRect(iClipRect); |
116 } |
122 } |
117 |
123 |
118 // start view finder |
124 // init camera device. |
119 // The division transfer is going to support in the next version. |
125 if (InitViewFinder() != KErrNone) |
120 Start(); |
126 { |
121 } |
127 //TODO The error value is examined. |
122 |
128 User::Leave(KErrGeneral); |
123 /** |
129 } |
124 Stops transfer of view finder data to the screen. |
|
125 */ |
|
126 void CWebCameraVfActive::StopViewFinder() |
|
127 { |
|
128 if (!iViewFinderActive) |
|
129 { |
|
130 return; |
|
131 } |
|
132 |
|
133 iViewFinderActive = EFalse; |
|
134 |
|
135 delete iDSA; |
|
136 iDSA = NULL; |
|
137 |
|
138 delete iVfBuf; |
|
139 iVfBuf = NULL; |
|
140 |
|
141 //Stop view finder |
|
142 iDriver.StopViewFinder(); |
|
143 Cancel(); |
|
144 } |
|
145 |
|
146 /** |
|
147 Queries whether the view finder is active. |
|
148 |
|
149 @return ETrue if the view finder is active. EFalse if the view finder is not |
|
150 active. |
|
151 */ |
|
152 TBool CWebCameraVfActive::ViewFinderActive() |
|
153 { |
|
154 return iViewFinderActive; |
|
155 } |
|
156 |
|
157 /** |
|
158 Start viewfinder process. |
|
159 */ |
|
160 void CWebCameraVfActive::Start() |
|
161 { |
|
162 RDebug::Print(_L("CWebCameraVfActive::Start")); |
|
163 |
|
164 iVfBufPtr.Set(iVfBuf->Des()); |
|
165 iVfBufPtr.SetLength(0); |
|
166 //Start view finder |
|
167 iDriver.StartViewFinder(iStatus, iVfBufPtr); |
|
168 |
|
169 SetActive(); |
|
170 } |
|
171 |
|
172 /** |
|
173 Draw the image of the view finder on screen. |
|
174 */ |
|
175 void CWebCameraVfActive::UpdateViewL() |
|
176 { |
|
177 RDebug::Print(_L("CWebCameraVfActive::UpdateViewL")); |
|
178 |
|
179 delete iVfBitmap; |
130 delete iVfBitmap; |
180 iVfBitmap = NULL; |
131 iVfBitmap = NULL; |
181 |
132 |
182 CFbsBitmap* image = new (ELeave) CFbsBitmap(); |
133 CFbsBitmap* image = new (ELeave) CFbsBitmap(); |
183 CleanupStack::PushL(image); |
134 CleanupStack::PushL(image); |
184 User::LeaveIfError(image->Create(TSize(KVfWidth, KVfHeight), EColor16M)); |
135 User::LeaveIfError(image->Create(TSize(KVfWidth, KVfHeight), EColor16M)); |
185 CleanupStack::Pop(image); |
136 CleanupStack::Pop(image); |
186 |
137 |
187 iVfBitmap = image; |
138 iVfBitmap = image; |
188 |
139 |
189 // output received data log |
140 // start view finder |
190 // RDebug::Print(_L("CWebCameraVfActive::UpdateView iVfBufLength[%d]"), iVfBufPtr.Length()); |
141 // The division transfer is going to support in the next version. |
191 // TBuf<256> hexBuf; |
142 Start(); |
192 // for (TInt i = 0; i < iVfBufPtr.Length(); i++) |
143 } |
193 // { |
144 |
194 // hexBuf.AppendFormat(_L("%02X "), iVfBufPtr[i]); |
145 /** |
195 // if ((i % 16) == 15) |
146 Stops transfer of view finder data to the screen. |
196 // { |
147 */ |
197 // RDebug::Print(hexBuf); |
148 void CWebCameraVfActive::StopViewFinder() |
198 // hexBuf = KNullDesC; |
149 { |
199 // } |
150 if (!iViewFinderActive) |
200 // } |
151 { |
201 // RDebug::Print(hexBuf); |
152 return; |
202 |
153 } |
203 // convert buffer data to Bitmap |
154 |
204 for (TInt height=0; height<KVfHeight; height++) |
155 iViewFinderActive = EFalse; |
205 { |
156 |
206 TInt pos = height * KVfLineBytes; |
157 delete iDSA; |
207 TPtrC8 posptr = iVfBuf->Mid(pos, KVfLineBytes); |
158 iDSA = NULL; |
208 TBuf8<KVfLineBytes> buf; |
159 |
209 buf.Copy(posptr); |
160 delete iVfBuf; |
210 iVfBitmap->SetScanLine(buf, (KVfHeight-1)-height); |
161 iVfBuf = NULL; |
211 } |
162 |
|
163 //Stop view finder |
|
164 iDriver.StopViewFinder(); |
|
165 Cancel(); |
|
166 } |
|
167 |
|
168 /** |
|
169 Queries whether the view finder is active. |
|
170 |
|
171 @return ETrue if the view finder is active. EFalse if the view finder is not |
|
172 active. |
|
173 */ |
|
174 TBool CWebCameraVfActive::ViewFinderActive() |
|
175 { |
|
176 return iViewFinderActive; |
|
177 } |
|
178 |
|
179 /** |
|
180 Start viewfinder process. |
|
181 */ |
|
182 void CWebCameraVfActive::Start() |
|
183 { |
|
184 iDriver.StartViewFinder(iStatus, iChuckRemSize); |
|
185 |
|
186 SetActive(); |
|
187 } |
|
188 |
|
189 /** |
|
190 Draw the image of the view finder on screen. |
|
191 */ |
|
192 void CWebCameraVfActive::UpdateViewL() |
|
193 { |
|
194 iVfBufPtr.Set(iVfBuf->Des()); |
|
195 iVfBufPtr.SetLength(0); |
|
196 iVfBufPtr.Copy(iChuckBase,iChuckRemSize); |
|
197 BitmapDataSet(iVfBufPtr, *iVfBitmap); |
212 |
198 |
213 // view position setting for test application |
199 // view position setting for test application |
214 iScreenRect.iTl.iY = 50; |
200 iScreenRect.iTl.iY = 50; |
215 iScreenRect.iBr.iY = 169; |
201 iScreenRect.iBr.iY = 169; |
216 |
|
217 // update view |
202 // update view |
218 iDSA->Gc()->DrawBitmap(iScreenRect, iVfBitmap); |
203 iDSA->Gc()->DrawBitmap(iScreenRect, iVfBitmap); |
219 iDSA->ScreenDevice()->Update(); |
204 iDSA->ScreenDevice()->Update(); |
220 } |
205 } |
221 |
206 |
|
207 /** |
|
208 Bitmap data is set in CFbsBitmap. |
|
209 |
|
210 @param aBitmap [in] Bitmap data. |
|
211 aVfBitmap [out] After Bitmap data is set in CFbsBitmap. |
|
212 @return KErrNone. |
|
213 */ |
|
214 TInt CWebCameraVfActive::BitmapDataSet(TDes8& aBitmap, CFbsBitmap& aVfBitmap) |
|
215 { |
|
216 TUint32 *wData = aVfBitmap.DataAddress(); |
|
217 Mem::Copy(wData, aBitmap.Ptr(), (KVfHeight * KVfLineBytes)); |
|
218 return KErrNone; |
|
219 } |
|
220 |
222 /** |
221 /** |
223 from MAbortDirectScreenAccess |
222 from MAbortDirectScreenAccess |
224 |
223 |
225 This function is called by the window server when direct screen access must stop |
224 This function is called by the window server when direct screen access must stop |
226 (for example because a dialogue is moved in front of the area where direct screen access is taking place). |
225 (for example because a dialogue is moved in front of the area where direct screen access is taking place). |