// 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); }
bool is_solid(image_view<image_data_32> const& view) { if (view.width() > 0 && view.height() > 0) { mapnik::image_view<image_data_32>::pixel_type const* first_row = view.getRow(0); mapnik::image_view<image_data_32>::pixel_type const first_pixel = first_row[0]; for (unsigned y = 0; y < view.height(); ++y) { mapnik::image_view<image_data_32>::pixel_type const * row = view.getRow(y); for (unsigned x = 0; x < view.width(); ++x) { if (first_pixel != row[x]) { return false; } } } } return true; }
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); }