In this code for Nokia 6600
class CPageRegionPrinter : public MPageRegionPrinter
{
public:
CFbsBitmap* iBitmap;
void PrintBandL(CGraphicsDevice* aLayoutDevice, TInt aPageNo, const TBandAttributes& aBand);
};
void CPageRegionPrinter::PrintBandL(CGraphicsDevice* aLayoutDevice, TInt aPageNo, const TBandAttributes& aBand)
{
// Set up the GC and push to cleanup stack
CFbsBitGc* gc;
((CFbsDevice*)aLayoutDevice)->CreateContext(gc);
CleanupStack::PushL(gc);
// Call some function to do the drawing: here we pass the graphics context,
// device, page number, offset, and display rectangle
TPoint pos(0, 0);
gc->BitBlt(pos, iBitmap);
CleanupStack::PopAndDestroy(); // cleanup the GC
}
class CBtPrinterPort : public CPrinterPort
{
public:
void WriteRequest(const TDesC8& aBuf, TRequestStatus& aRequestStatus);
void Cancel();
};
void CBtPrinterPort::WriteRequest(const TDesC8& aBuf, TRequestStatus& aRequestStatus)
{
aRequestStatus = KErrCancel;
};
void CBtPrinterPort::Cancel()
{
};
void CSnapShotContainer::PrintImage()
{
if (iPeriodicTimer->IsActive())
iPeriodicTimer->Cancel();
CPrintSetup* iPrintSetup = CPrintSetup::NewL();
_LIT(KSearchPath,"\\system\\printers\\*"😉;
iPrintSetup->AddPrinterDriverDirL(KSearchPath);
RFs iFs;
iFs.Connect();
RFs& rFs = iFs;
CPrinterModelList* modelList = iPrintSetup->ModelNameListL(rFs);
CleanupStack::PushL(iPrintSetup);
iPrintSetup->CreatePrinterDeviceL((*modelList)[0].iUid, rFs);
CleanupStack::Pop(); // cleanup iPrintSetup
iPrintSetup->FreeModelList();
TPageSpec spec;
spec.iPortraitPageSize = KA4PaperSizeInTwips;
spec.iOrientation = TPageSpec::EPortrait;
iPrintSetup->PrinterDevice()->SelectPageSpecInTwips(spec);
TPrintParameters params;
params.iFirstPage = 0;
params.iLastPage = 0;
params.iNumCopies = 1;
CBtPrinterPort* btpp = new (ELeave) CBtPrinterPort();
CPageRegionPrinter* prp = new (ELeave) CPageRegionPrinter();
prp->iBitmap = iBitmap;
CleanupStack::PushL(iPrintSetup);
iPrintSetup->StartPrintL(params, (*prp), btpp, NULL);
CleanupStack::PopAndDestroy(); // cleanup iPrintSetup
iFs.Close();
delete btpp;
delete prp;
delete iPrintSetup;
}
I have a problem. While runing/debugging StartPrintL function raises Memory Fault. On fact, on emulator, StartprintL does not call neither prp, neither btpp, but faults as if it was mad.
May be someone can help me or smbody had to write Bluetooth printing applications 4 Nokia S60?