Question printing a bitmap
Atreides
atreides at it.sunsite.dk
Tue Mar 11 15:11:21 PDT 2008
I wrote the attached code to print a bitmap (PNG format). The pointer
bitmapImage points to a valid bitmap. Compiling and running the code
(release , unicode, 8.2.7, Windows XP) I am observing two pages in the
preview window, the first one contains the bitmap and the second one
seems empty. Printing I got no problem, but only one page is printed.
Compiling in debug mode I got ( using the preview and changing the
previewed page from the first page to the second ) the following assert
error.
..\..\include/wx/dynarray.h(813): assert "uiIndex < m_nCount" failed in
Item().
I got this assert even printing the image.
Rescaling the bitmap (making it smaller) I get only one page in the
preview and no assert.
Please could you help me to understand where I am doing programming
mistakes in the following code?
void PngViewer::OnPrint( wxCommandEvent& event )
{
wxRichTextCtrl ctrl(this);
wxRichTextPrinting *ctrlPrinting = new
wxRichTextPrinting(wxT("Printing PNG Image"),this);
wxPrintData *pPrintData = ctrlPrinting->GetPrintData();
pPrintData->SetOrientation(wxLANDSCAPE);
pPrintData->SetPaperId(wxPAPER_A4);
pPrintData->SetQuality(wxPRINT_QUALITY_HIGH);
pPrintData->SetPrinterName(wxEmptyString);
ctrl.Clear();
ctrl.BeginSuppressUndo();
ctrl.WriteImage(*bitmapImage,wxBITMAP_TYPE_PNG);
ctrl.EndSuppressUndo();
ctrlPrinting->PreviewBuffer(ctrl.GetBuffer());
return;
}
Thanks
Max
More information about the wx-users
mailing list