From f1704fd61a60058acfac0ef411c853f756b65ccc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 8 Jun 2019 12:01:24 -0700 Subject: [PATCH] bitmap2component: Fix logic for alpha mask For POTRACE, black is the foreground and white is the background. We should keep the convention by requiring the pixin to be less than the black threshhold as well as the alpha to be at least the alpha threshhold. Fixes: lp:1821563 * https://bugs.launchpad.net/kicad/+bug/1821563 --- bitmap2component/bitmap2cmp_gui.cpp | 2 +- bitmap2component/bitmap2component.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 3a0e84b94d..11ab195575 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -450,7 +450,7 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) auto alpha = m_Greyscale_Image.HasAlpha() ? m_Greyscale_Image.GetAlpha( x, y ) : wxALPHA_OPAQUE; - if( pixin < threshold || alpha < alpha_thresh ) + if( pixin < threshold && alpha > alpha_thresh ) pixout = 0; else pixout = 255; diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index 5ff61a67b2..3b15b48a0c 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -155,7 +155,6 @@ int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, return 1; } - printf("Step 1\n"); BITMAPCONV_INFO info; info.m_PixmapWidth = aPotrace_bitmap->w; info.m_PixmapHeight = aPotrace_bitmap->h; // the bitmap size in pixels