// draw_view static void draw_view(image_view const& vw, wx_window * wxwin) { // create paint DC wxPaintDC dc(wxwin->win); // clip view if neccessary int w = vw.width(), h = vw.height(); image_view sub_vw; // clip view if (wxwin->is_toplevel) { sub_vw = vw; } else { if (wx_window * parent = static_cast<wx_window *>(wxwin->parent)) { w = std::min(w, parent->width - wxwin->x); h = std::min(h, parent->height - wxwin->y); } int tlx = 0, tly = 0; if (wxwin->x < 0) { tlx += -wxwin->x; w -= -wxwin->x; } if (wxwin->y < 0) { tly += -wxwin->y; w -= -wxwin->y; } sub_vw = image_view(w, h, vw.xy_at(tlx, tly)); } // FIXME: too slow // copy into wxBitmap wxImage wximg(sub_vw.width(), sub_vw.height()); boost::gil::copy_pixels( sub_vw, boost::gil::interleaved_view( wximg.GetWidth(), wximg.GetHeight(), (boost::gil::rgb8_pixel_t *) wximg.GetData(), wximg.GetWidth() * 3 ) ); wxBitmap bmp(wximg); // draw onto the screen dc.DrawBitmap(bmp, 0, 0, false); }
static void draw_view(image_view const& vw, msw_window * mswwin) { // create dc HDC hdc = ::GetDC(mswwin->handle); // clip view int w = vw.width(), h = vw.height(); image_view sub_vw; // clip view if (mswwin->is_toplevel) { sub_vw = vw; } else { if (msw_window * parent = static_cast<msw_window *>(mswwin->parent)) { w = std::min(w, parent->width - mswwin->x); h = std::min(h, parent->height - mswwin->y); } int tlx = 0, tly = 0; if (mswwin->x < 0) { tlx += -mswwin->x; w -= -mswwin->x; } if (mswwin->y < 0) { tly += -mswwin->y; w -= -mswwin->y; } sub_vw = image_view(w, h, vw.xy_at(tlx, tly)); } // create the BITMAPINFO structure BITMAPINFO bmi; memset(&bmi, 0, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = sub_vw.width(); bmi.bmiHeader.biHeight = sub_vw.height(); bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biCompression = BI_RGB; // draw view ::StretchDIBits( hdc, 0, 0, sub_vw.width(), sub_vw.height(), 0, 0, sub_vw.width(), sub_vw.height(), boost::gil::interleaved_view_get_raw_data(sub_vw), &bmi, DIB_RGB_COLORS, SRCCOPY ); ::ReleaseDC(mswwin->handle, hdc); }