Wednesday, October 01, 2008

Taking ScreenShot in Symbian

Below are steps we have to take ScreenShot and saving it to the file as .jpeg.

1.Create blank bitmap:
iBitmap = new (ELeave)CFbsBitmap;
iBitmap->Create( TSize(176,208),EColor16M ); // Pass the Window Size to capture

2.Create a rectangle of the window you want to capture:
iScreenRect = TRect(TPoint(0,0),TSize(176,208)); // Pass the Window Size to capture

3. Copy Screen To this bitmap and save it into memory.
iScreenDevice->CopyScreenToBitmap(iBitmap,iScreenRect);

4. Now we have to Encode CFbsBitmap to JPEG Format.

TBuf<50> myBuf;
myBuf.Append(KFileName);
myBuf.AppendNum(iCaptureCount);
myBuf.Append(KExtension);

iEncoder = CImageEncoder::FileNewL(iFsSession, myBuf, CImageEncoder::EOptionAlwaysThread, KImageTypeJPGUid);

TRequestStatus status;
iEncoder->Convert(&status,*iBitmap);
SetActive();

5. The conversion process is asynchronous. When it is completed, RunL() is called. Inside RunL()

Indside RunL():
delete iEncoder;
iEncoder = NULL;

No comments:

stats counter