bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext) { DrawingArea::on_draw(poContext); Cairo::RefPtr<Cairo::ImageSurface> poImage; Cairo::RefPtr<Cairo::SurfacePattern> poPattern; Cairo::Matrix oMatrix; const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32); //poContext->set_identity_matrix(); poContext->scale(m_dScaleFactor, m_dScaleFactor); poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24, m_iScaledWidth, m_iScaledHeight, iScaledPitch); //cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop); poPattern = Cairo::SurfacePattern::create(poImage); poPattern->set_filter(Cairo::FILTER_NEAREST); //poPattern->set_matrix (oMatrix); poContext->set_source_rgb(0.0, 0.0, 0.0); poContext->paint(); poContext->set_source(poPattern); poContext->paint(); return true; }
void ImageWidget::redrawWithoutChanges(Cairo::RefPtr<Cairo::Context> cairo, unsigned width, unsigned height) { if(_isInitialized) { cairo->set_source_rgb(1.0, 1.0, 1.0); cairo->set_line_width(1.0); cairo->rectangle(0, 0, width, height); cairo->fill(); int destWidth = width - (int) floor(_leftBorderSize + _rightBorderSize), destHeight = height - (int) floor(_topBorderSize + _bottomBorderSize), sourceWidth = _imageSurface->get_width(), sourceHeight = _imageSurface->get_height(); cairo->save(); cairo->translate((int) round(_leftBorderSize), (int) round(_topBorderSize)); cairo->scale((double) destWidth / (double) sourceWidth, (double) destHeight / (double) sourceHeight); Cairo::RefPtr<Cairo::SurfacePattern> pattern = Cairo::SurfacePattern::create(_imageSurface); pattern->set_filter(_cairoFilter); cairo->set_source(pattern); cairo->rectangle(0, 0, sourceWidth, sourceHeight); cairo->clip(); cairo->paint(); cairo->restore(); cairo->set_source_rgb(0.0, 0.0, 0.0); cairo->rectangle(round(_leftBorderSize), round(_topBorderSize), destWidth, destHeight); cairo->stroke(); if(_showColorScale) _colorScale->Draw(cairo); if(_showXYAxes) { _vertScale->Draw(cairo); _horiScale->Draw(cairo); } if(_plotTitle != 0) _plotTitle->Draw(cairo); } }