This page was last modified 14:23, 8 December 2007.
Saving Symbian bitmap images to files
From Forum Nokia Wiki
CJpgSaver illustrates a simplified image saver which with you can save Symbian bitmap images into the JPG files. With this example image saving is implemented by using CImageEncoder API’s FileNewL()-function, for saving the bitmap to other types of image files you could change the MIME type constant used with the FileNewL.
CImageEncoder also allows saving images to buffers, to change this example to save images to buffers, just change the FileNewL() to be DataNewL and supply modifiable buffer into the function instead of the filename.
You could also save images to MBM files by using the Save()- function defined in CFbsBitmap, note that this function only saves one image to a file, thus you can not have multiple images in the MBM when using this function.
You could also save Symbian bitmap images into the stores for more information, see Dictionary store example Dictionary store example
SaveJPG.cpp
CJpgSaver* CJpgSaver::NewL(CFbsBitmap& aBitmap,const TDesC& aFileName,MImageSavedCallBack& aCallBack)
{
CJpgSaver* self = new (ELeave) CJpgSaver(aBitmap,aCallBack);
CleanupStack::PushL( self );
self->ConstructL(aFileName);
CleanupStack::Pop();
return self;
}
CJpgSaver::~CJpgSaver()
{
Cancel();
delete iEncoder;
delete iBitmapSave;
}
CJpgSaver::CJpgSaver(CFbsBitmap& aBitmap,MImageSavedCallBack& aCallBack)
:CActive(EPriorityStandard),iBitmap(aBitmap),iCallBack(aCallBack)
{
}
void CJpgSaver::ConstructL(const TDesC& aFileName)
{
CActiveScheduler::Add( this );
iEncoder = CImageEncoder::FileNewL(CCoeEnv::Static()->FsSession(),aFileName, KMimeType);
iEncoder->Convert( &iStatus, *iBitmapSave );
SetActive();
}
void CJpgSaver::DoCancel()
{
iEncoder->Cancel();
}
void CJpgSaver::RunL()
{
iCallBack.ImageSavedL(iStatus.Int());
}
SaveJPG.h
#include <f32file.h>
#include <e32std.h>
#include <gdi.h>
_LIT8(KMimeType,"image/jpeg");
class MImageSavedCallBack
{
public:
virtual void ImageSavedL(const TInt& aError) = 0;
};
class CJpgSaver : public CActive
{
public:
static CJpgSaver* NewL(CFbsBitmap& aBitmap,const TDesC& aFileName,MImageSavedCallBack& aCallBack);
virtual ~CJpgSaver();
protected:
void DoCancel() ;
void RunL() ;
private:
CJpgSaver(CFbsBitmap& aBitmap,MImageSavedCallBack& aCallBack);
void ConstructL(const TDesC& aFileName);
private: //data
CFbsBitmap& iBitmap;
MImageSavedCallBack& iCallBack;
CImageEncoder* iEncoder;
};
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A question about display pictures... | tntfighter-2002 | General Symbian C++ | 4 | 2002-10-17 00:24 |
| Series 60 v1 v2 v3 themes compatibility issue | nicolassaliba | Graphics & Video & Streaming | 2 | 2006-08-30 16:22 |
| CCamera in device | Isaiah | General Symbian C++ | 2 | 2007-12-10 09:11 |
| 使用CImageDecoder处理icon显示listbox产生的WSERV 7 | isarc | Symbian | 3 | 2007-10-08 09:42 |
| how to show bmp image in S60 v3 | kamaljaiswal | General Symbian C++ | 10 | 2007-05-08 15:58 |
