Bitmaps: respect source DPI
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13565
This commit is contained in:
parent
f81642bbb3
commit
369c0efade
|
@ -137,6 +137,17 @@ bool BITMAP_BASE::ReadImageFile( const wxString& aFullFilename )
|
||||||
m_originalImage = new wxImage( *m_image );
|
m_originalImage = new wxImage( *m_image );
|
||||||
rebuildBitmap();
|
rebuildBitmap();
|
||||||
|
|
||||||
|
// Todo: eventually we need to support dpi / scaling in both dimensions
|
||||||
|
int dpiX = m_originalImage->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
|
||||||
|
|
||||||
|
if( dpiX > 1 )
|
||||||
|
{
|
||||||
|
if( m_originalImage->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
|
||||||
|
m_ppi = KiROUND( dpiX * 2.54 );
|
||||||
|
else
|
||||||
|
m_ppi = dpiX;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,13 @@ SCH_BITMAP& SCH_BITMAP::operator=( const SCH_ITEM& aItem )
|
||||||
|
|
||||||
bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename )
|
bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename )
|
||||||
{
|
{
|
||||||
return m_image->ReadImageFile( aFullFilename );
|
if( m_image->ReadImageFile( aFullFilename ) )
|
||||||
|
{
|
||||||
|
m_image->SetPixelSizeIu( 254000.0 / m_image->GetPPI() );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,13 @@ PCB_BITMAP& PCB_BITMAP::operator=( const BOARD_ITEM& aItem )
|
||||||
|
|
||||||
bool PCB_BITMAP::ReadImageFile( const wxString& aFullFilename )
|
bool PCB_BITMAP::ReadImageFile( const wxString& aFullFilename )
|
||||||
{
|
{
|
||||||
return m_image->ReadImageFile( aFullFilename );
|
if( m_image->ReadImageFile( aFullFilename ) )
|
||||||
|
{
|
||||||
|
m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,4 +244,4 @@ static struct PCB_BITMAP_DESC
|
||||||
// For future use
|
// For future use
|
||||||
const wxString greyscale = _HKI( "Greyscale" );
|
const wxString greyscale = _HKI( "Greyscale" );
|
||||||
}
|
}
|
||||||
} _PCB_BITMAP_DESC;
|
} _PCB_BITMAP_DESC;
|
||||||
|
|
Loading…
Reference in New Issue