方法一,绘制其中的bitmap:
wxBitmap bitmap(300,400,-1);
wxMemoryDC dc;
dc.SelectObject(bitmap);
wxPen pen(wxColor(255,255,255),1,wxSOLID);
dc.SetPen(pen);
dc.DrawLine(0,0,50,50);//在memerydc中绘直线
wxRect rect(0,0,dc.GetSize().GetWidth(),dc.GetSize().GetHeight());//获取Memorydc的矩形大小
wxBitmap bitm = dc.GetAsBitmap(&rect);//得到Memorydc的bitmap
wxClientDC clienDC(this);
clienDC.DrawBitmap(bitm,50,50);//在目标dc中绘制该bitmap
dc.SelectObject(wxNullBitmap);
方法二:直接在目标dc中绘制源dc
wxBitmap bitmap(300,400,-1);
wxMemoryDC dc;
dc.SelectObject(bitmap);
wxPen pen(wxColor(255,255,255),1,wxSOLID);
dc.SetPen(pen);
dc.DrawLine(0,0,50,50);//在memerydc中绘直线
wxClientDC clienDC(this);
clienDC.Blit(10,10,//在clientDC中(10,10)位置开始绘图
bitmap.GetWidth(),bitmap.GetHeight(),//绘图的大小
&dc,//所要绘制的源dc
0,0,//从源dc的0,0位置开始绘制
wxCOPY,
true);//考虑mask
dc.SelectObject(wxNullBitmap);
方法三:
wxMemoryDC mDc;
wxPen penm(wxColor(255,0,0),1,wxSOLID);
mDc.SetPen(penm);
bitmap = wxBitmap(viewWindowHeight,viewWindowHeight,-1);
mDc.SetBackground(*wxBLACK_BRUSH);
mDc.Clear();
mDc.SelectObject(bitmap);
dis.DisplayPolygon(&mDc,polygonList,viewWindowHeight);
if(polygonList)
{
delete polygonList;
}
wxImage image = bitmap.ConvertToImage();
image.SaveFile(wxT("result.bmp"),wxBITMAP_TYPE_BMP);
if(image.Ok())
{
(new DSImageFrame(this, wxBitmap(image)))->Show();
}