From d0d19423e0c0d8b4d102a99e9e2f53f839a8beb5 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 4 Aug 2022 14:25:52 +0200 Subject: [PATCH] Eeschema: Try to fix bitmap printing in wx version > 3.1.5 We had on a regular basis problems when printing bitmaps. Probably due to issues in wx and in our code. --- common/bitmap_base.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 707c3f09e6..0c03af5fb9 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -248,7 +248,17 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos ) aDC->GetUserScale( &scale, &scale ); aDC->GetLogicalOrigin( &logicalOriginX, &logicalOriginY ); + // We already have issues to draw a bitmap on the wxDC, depending on wxWidgets version. + // Now we have an issue on wxWidgets 3.1.6 and later to fix the clipboard + // and the bitmap position when using TransformMatrix + // So for version >= 3.1.6 do not use it + // Be carefull before changing the code. bool useTransform = aDC->CanUseTransformMatrix(); + + #if wxCHECK_VERSION( 3, 1, 6 ) + useTransform = false; + #endif + wxAffineMatrix2D init_matrix = aDC->GetTransformMatrix(); wxPoint clipAreaPos; @@ -259,15 +269,12 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos ) matrix.Translate( pos.x, pos.y ); matrix.Scale( GetScalingFactor(), GetScalingFactor() ); aDC->SetTransformMatrix( matrix ); - - // Looks like wxWidgets 3.1.6 and 3.1.7 has a bug to fix the clipboard position - // So for 3.1.6 and 3.1.7, clipAreaPos.x = clipAreaPos.y = 0 - #if !wxCHECK_VERSION( 3, 1, 6 ) || wxCHECK_VERSION( 3, 2, 0 ) + // Needed on wx <= 3.1.5, and this is strange... + // Nevertheless, this code has problem (the bitmap is not seen) + // with wx version > 3.1.5 clipAreaPos.x = pos.x; clipAreaPos.y = pos.y; - #else - clipAreaPos.x = clipAreaPos.y = 0; - #endif + pos.x = pos.y = 0; } else