diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index 441aa06f61..88698ed8a8 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -393,9 +393,9 @@ const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const auto* bitmap = static_cast( m_peer ); wxSize bm_size = bitmap->m_ImageBitmap->GetSize(); - // Size is in mils, convert to iu (0.001 mm) - bm_size.x *= 25.4; - bm_size.y *= 25.4; + // bm_size is in Eeschma unit (100nm), convert to iu (0.001 mm) + bm_size.x /= 10; + bm_size.y /= 10; EDA_RECT bbox; bbox.SetSize( bm_size ); diff --git a/common/page_layout/ws_painter.cpp b/common/page_layout/ws_painter.cpp index 81792df01c..2ffeec787d 100644 --- a/common/page_layout/ws_painter.cpp +++ b/common/page_layout/ws_painter.cpp @@ -316,9 +316,10 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const { m_gal->Save(); + auto* bitmap = static_cast( aItem->GetPeer() ); + VECTOR2D position = aItem->GetPosition(); m_gal->Translate( position ); - auto* bitmap = static_cast( aItem->GetPeer() ); // When the image scale factor is not 1.0, we need to modify the actual scale // as the image scale factor is similar to a local zoom @@ -328,6 +329,21 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) con m_gal->Scale( VECTOR2D( img_scale, img_scale ) ); m_gal->DrawBitmap( *bitmap->m_ImageBitmap ); + +#if 0 // For bounding box debug purpose only + EDA_RECT bbox = aItem->GetBoundingBox(); + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( true ); + m_gal->SetFillColor( COLOR4D( 1, 1, 1, 0.4 ) ); + m_gal->SetStrokeColor( COLOR4D( 0, 0, 0, 1 ) ); + + if( img_scale != 1.0 ) + m_gal->Scale( VECTOR2D( 1.0, 1.0 ) ); + + m_gal->DrawRectangle( VECTOR2D( bbox.GetOrigin() ) - position, + VECTOR2D( bbox.GetEnd() ) - position ); +#endif + m_gal->Restore(); }