Example #1
0
void wxHtmlImageCell::Draw(wxDC& dc, int x, int y,
                           int WXUNUSED(view_y1), int WXUNUSED(view_y2),
                           wxHtmlRenderingInfo& WXUNUSED(info))
{
    if ( m_showFrame )
    {
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.SetPen(*wxBLACK_PEN);
        dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height);
        x++, y++;
    }
    if ( m_bitmap )
    {
        // We add in the scaling from the desired bitmap width
        // and height, so we only do the scaling once.
        double imageScaleX = 1.0;
        double imageScaleY = 1.0;
        if (m_Width != m_bitmap->GetWidth())
            imageScaleX = (double) m_Width / (double) m_bitmap->GetWidth();
        if (m_Height != m_bitmap->GetHeight())
            imageScaleY = (double) m_Height / (double) m_bitmap->GetHeight();

        double us_x, us_y;
        dc.GetUserScale(&us_x, &us_y);
        dc.SetUserScale(us_x * imageScaleX, us_y * imageScaleY);

        dc.DrawBitmap(*m_bitmap, (int) ((x + m_PosX) / (imageScaleX)),
                                 (int) ((y + m_PosY) / (imageScaleY)), true);
        dc.SetUserScale(us_x, us_y);
    }
}
Example #2
0
void wxPDFViewPage::Draw(wxPDFViewPagesClient* client, wxDC& dc, wxGraphicsContext& gc, const wxRect& rect)
{
	// Calculate the required bitmap size
	wxSize bmpSize = rect.GetSize();
	double scaleX, scaleY;
	dc.GetUserScale(&scaleX, &scaleY);
	bmpSize.x *= scaleX;
	bmpSize.y *= scaleY;

	double screenScale = dc.GetContentScaleFactor();
	bmpSize.x *= screenScale;
	bmpSize.y *= screenScale;

	wxBitmap bmp = client->GetCachedBitmap(m_index, bmpSize);
	if (bmp.IsOk())
	{
		gc.DrawBitmap(bmp, rect.x, rect.y, rect.width, rect.height);
	} else {
		// Draw empty page
		gc.SetBrush(*wxWHITE_BRUSH);
		gc.SetPen(wxNullPen);
		gc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
	}
}