Fix incorrect page preview in Page Settings dialog when the worksheet contains a bitmap

This commit is contained in:
jean-pierre charras 2020-11-27 15:42:27 +01:00
parent ef75ce9035
commit 4f651901aa
2 changed files with 15 additions and 3 deletions

View File

@ -732,6 +732,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
{
double scaleW = (double) lyWidth / clamped_layout_size.x;
double scaleH = (double) lyHeight / clamped_layout_size.y;
double scale = std::min( scaleW, scaleH );
// Prepare DC.
wxSize example_size( lyWidth + 1, lyHeight + 1 );
@ -739,7 +740,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
memDC.SelectObject( *m_page_bitmap );
memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
memDC.Clear();
memDC.SetUserScale( scaleW, scaleH );
memDC.SetUserScale( scale, scale );
// Get logical page size and margins.
PAGE_INFO pageDUMMY;

View File

@ -398,8 +398,19 @@ void WS_DRAW_ITEM_BITMAP::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint
{
WS_DATA_ITEM_BITMAP* bitmap = (WS_DATA_ITEM_BITMAP*) GetPeer();
if( bitmap->m_ImageBitmap )
bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset );
if( !bitmap->m_ImageBitmap )
return;
// We are using here internal unit = 1 mil for historical reason
// the PixelScaleFactor in mils is:
double pix_scale = 1000.0 / bitmap->GetPPI();
double ps = bitmap->m_ImageBitmap->GetPixelScaleFactor(); // Store initial value
bitmap->m_ImageBitmap->SetPixelScaleFactor( pix_scale );
bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset );
bitmap->m_ImageBitmap->SetPixelScaleFactor( ps ); // restore initial value
}