Keep image sizes when loading/saving 7.0- schematic file formats.

Previously, images were assumed to have 300 PPI density when loading from
schematic, but not after initial placement.


(cherry picked from commit bd4758e4df)
This commit is contained in:
Alex 2023-02-17 03:41:57 +03:00 committed by dsa-t
parent 7949c09183
commit b63d0a3138
2 changed files with 20 additions and 2 deletions

View File

@ -2976,6 +2976,14 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage()
}
}
// 20230121 or older file format versions assumed 300 image PPI at load/save.
// Let's keep compatibility by changing image scale.
if( m_requiredVersion <= 20230121 )
{
BITMAP_BASE* image = bitmap->GetImage();
image->SetScale( image->GetScale() * image->GetPPI() / 300.0 );
}
return bitmap.release();
}

View File

@ -920,8 +920,18 @@ void SCH_SEXPR_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap, int aNestLevel )
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
aBitmap->GetPosition().y ).c_str() );
if( aBitmap->GetImage()->GetScale() != 1.0 )
m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
double scale = aBitmap->GetImage()->GetScale();
// 20230121 or older file format versions assumed 300 image PPI at load/save.
// Let's keep compatibility by changing image scale.
if( SEXPR_SCHEMATIC_FILE_VERSION <= 20230121 )
{
BITMAP_BASE* image = aBitmap->GetImage();
scale = scale * 300.0 / image->GetPPI();
}
if( scale != 1.0 )
m_out->Print( 0, " (scale %g)", scale );
m_out->Print( 0, "\n" );